Repository navigation
Closed as duplicate
Closed as duplicate
Copy link
Labels
Description
Summary
Local MCP servers (type: "local", spawned as node <script> with the stdio transport) connect successfully and then die minutes later with MCP server process exited with code 1 and no stderr. OpenCode never reconnects them, so they stay in failed state indefinitely — until the user edits the config file to force a respawn.
Environment
- opencode version: v2.2.6 (channel: latest, global install)
- OS: Windows 10.0.19045.6466 (win32 x64)
- Terminal: Tabby (TERM_PROGRAM=Tabby, TERM=xterm-256color, COLORTERM=truecolor)
- Shell: cmd.exe (COMSPEC), commands executed through Git bash
- Install/channel: latest
- Active plugins: local plugin files under
%USERPROFILE%\.config\opencode\plugins\(bash-alias/,token-tracker-realtime.js,usage-tracker/); nopluginsfield inopencode.json
Reproduction
- Configure three local MCP servers, all spawned as node processes, for example:
{
"mcp": {
"servers": {
"server-a": { "type": "local", "command": ["node", "C:\\path\\to\\a.mjs", "mcp"] },
"server-b": { "type": "local", "command": ["node", "C:\\path\\to\\b.bundle.mjs"] },
"server-c": { "type": "local", "command": ["node", "C:\\path\\to\\c-cli.js"] }
}
}
}- Start OpenCode. All servers connect (
opencode mcp list→connected). - Leave the client idle (no tool calls). Between ~90 seconds and ~1 hour later, every node-based server process dies at the same moment.
opencode mcp listnow reports:
✗ server-a failed: Connection closed: MCP server process exited with code 1
✗ server-b failed: Connection closed: MCP server process exited with code 1
✗ server-c failed: Connection closed: MCP server process exited with code 1
- The servers never reconnect on their own. Touching a server's config entry (saving
opencode.jsontriggersconfig.updated) respawns it;opencode mcp listalone does not retry.
Expected Behavior
OpenCode should detect that a local MCP process exited and reconnect automatically (ideally with backoff), so the server status recovers without the user editing configuration.
Actual Behavior
All node-based local servers die simultaneously and silently (exit code 1, no stderr, no crash in Windows Event Viewer) and remain permanently failed. No reconnect attempt is logged.
Observed deaths within one session (server-side log, role=server):
message="mcp transport error" server=server-a error="MCP server process exited with code 1"
message="mcp transport error" server=server-b error="MCP server process exited with code 1"
message="mcp transport error" server=server-c error="MCP server process exited with code 1"
Additional Context
- A diagnostic wrapper process was placed between OpenCode and each server to record stdin EOF, stdout/stderr EPIPE, child exit code and child stderr. It logged nothing unusual before death (no stdin end, no pipe error, no child error): the processes were terminated from outside, not crashed. When the config was later edited, the same wrapper recorded a clean teardown —
STDIN END (parent closed stdin)→CHILD EXIT code=0— confirming the silent exit-1 deaths are a different path from the graceful reconnect. - Deaths occur for every directory's connection at the same instant. A remote server (
type: "remote") and one native (non-node) local server keep their connections across the same events, so the killer appears to target the node-based stdio children specifically. - Windows Event Viewer shows no
Application Error/Application Hangentries fornode.exeat the death timestamps. - Workaround that helps: save a change in
opencode.json(any edit to the affected server entry forces a respawn). Only the server entries whose config value changed are respawned; unchanged entries stayfailed. - Server processes run as children of
opencode.exe serve --service. - Frequency: intermittent; 4 death events in ~3 hours of interactive use, ~1 minute to ~1 hour after connecting.
Activity
opencodejr commentedon Nov 9, 2026
Thanks for the detailed report and the wrapper diagnostics, @enzoayala32!
I think this is a duplicate of #53226. That issue reports the same thing: a connected local stdio MCP server's process exits unexpectedly (often killed from outside OpenCode), OpenCode logs one
mcp transport error, and the server staysfaileduntil a config write respawns it. Comments there also describe every per-directory connection dying at the same moment, andmcp listshowing the cached status instead of retrying.Possible duplicates and related issues, ordered from most to least likely:
Until that is fixed, #53226 has a workaround that doesn't involve editing the config. It reconnects one directory's connection:
opencode api post '/api/experimental/mcp/<server>/connect?location[directory]=<dir>'The bot will close this issue as a duplicate in 1 day unless you reply explaining how your problem is different. If you find out what is killing the node processes, a comment on #53226 would help.
enzoayala32 commentedon Nov 9, 2026
Thanks for the triage — confirmed as a duplicate of #53226, no need to keep this open.
I have added my wrapper-diagnostics evidence there: #53226 (comment) — the short version is that the node children die with no stdin/pipe/stderr activity (external kill, not a crash), a Rust
.exeserver survived the same events, and the cleanexit code 0teardown on config reload is a separate path.The
/api/experimental/mcp/<server>/connectworkaround noted here is better than the config-edit one from my report — noted for future use. Subscribing to #54378 for the reconnect-with-backoff fix.opencodejr commentedon Nov 9, 2026
Thanks for confirming, @enzoayala32, and for adding the wrapper diagnostics to #53226. Having that evidence on the main issue is useful: the node children were killed from outside with no stdin, pipe or stderr activity, a native
.exeserver survived the same events, and the config-reload teardown takes a separate exit-0 path.This issue will be closed as a duplicate of #53226 as planned. Following #53226 and #54378 is the best way to see progress on reconnecting.
opencodejr commentedon Nov 10, 2026
Closing this as a duplicate of #53226, as agreed. Thanks again, @enzoayala32, for the wrapper diagnostics, and for adding them to #53226. Please follow #53226 for the underlying problem and #54378 for the reconnect-with-backoff change. Until then,
opencode api post '/api/experimental/mcp/<server>/connect?location[directory]=<dir>'reconnects one directory's connection without editing the config.