GeezerVison is showing github.com — Background service leaks MCP server processes across reconnects and reloads · Issue #53992 · anomalyco/opencode
Background service leaks MCP server processes across reconnects and reloads #53992DescriptionSummary
With the background service running (opencode TUI session kept open), MCP server processes accumulate instead of being reaped. Repeated reconnects and opencode reload spawn additional instances of the same configured server, all children of the single service PID. Servers with startup cost (model loading) then exhaust their resource budget and connections start failing, and the accumulated processes survive service restart for a while.
Environment
opencode v2.0.25 (background service mode, the default)
- Linux, 32 cores
- Local stdio MCP servers configured in the global
~/.config/opencode/opencode.json under mcp.servers
- Observed with a Python MCP server (
paddleocr_mcp) that loads large models at startup, and also with a lightweight one
Reproduction
- Configure one local stdio MCP server with
mcp.servers.
- Start OpenCode (background service is spawned).
- Run
opencode mcp list a few times, and/or opencode reload, and/or start
sessions repeatedly.
- Count the server processes:
pgrep -af "[p]addleocr_mcp"
Observed 4-5 concurrent instances of a single configured server, all sharing
one parent (the service PID).
Impact
- Resource exhaustion. Each instance held ~2 GB of GPU memory in my case;
four instances took 7.8 GB of 8 GB, after which every further connection
failed with a CUDA out-of-memory error surfaced only as
failed: Connection closed: MCP server process exited with code 1.
- Leftovers after restart. Immediately after
opencode service restart
there were still multiple stale instances resident.
- The leak also affects a small server (five instances of a ~300 MB CPU model
server), so it is not model-specific.
Questions / what I would like confirmed
- Is the intended lifecycle that the service owns exactly one process per
configured server, and reaps it on reconnect or on reload?
- Is there a known path where a reconnect spawns a replacement before the old
process has exited, without deduplication?
- Should
opencode reload and service restart terminate MCP child processes
they own?
Notes
- Reproduces with
mcp.servers entries of type local (command arrays).
opencode mcp list appears to trigger a connection attempt, so it is a cheap
way to accumulate instances; I used it as the reproduction driver.
- I can provide
nvidia-smi and ps output showing the shared parent PID if
useful.
Activityopencode-agent commented on Oct 8, 2026 Thanks for the detailed report and the measurements. I think this is a duplicate of #52965: duplicate instances of the same MCP server pile up under a single live service process when you run repeated CLI invocations (including opencode mcp list) or start sessions. The reload/restart part of your report is already tracked in #50758.
Possible duplicates and closely related issues, ordered by likelihood:
Your nvidia-smi/ps output showing the shared parent PID, plus the confirmation that this still happens on 2.0.25, would be a useful data point on #52965 or #50758.
The bot will close this issue as a duplicate in 1 day unless you reply explaining how your problem is different.
opencode-agent commented on Oct 9, 2026 Closing this as a duplicate of #52965, since we haven't heard back in the day since it was flagged. Duplicate instances of the same local MCP server piling up under the service process are tracked there. The opencode reload / service restart part is tracked in #50758, and PR #51730 is open for the reload case.
Your ps/nvidia-smi output showing the shared parent PID, plus confirmation that this still happens on 2.0.25, would help on either of those issues. If your problem turns out to be different, reply here and we can reopen.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|