Description
A local stdio MCP can spawn a wrapper process tree (npm exec, uvx, shell wrappers). Explicit disconnect and dynamic replacement call client.close(), which terminates the direct transport process but leaves its descendants running.
Full instance teardown already enumerates and terminates descendants, so cleanup behavior differs by lifecycle path. I reproduced this with a real stdio MCP fixture: before the fix, the parent exits and the child remains alive past the assertion deadline.
Expected: every MCP client ownership exit terminates the same full local process tree.
Related but distinct from #46035: that report currently shows complete MCP sets with live launchers, while this issue covers descendants left after teardown is invoked. Also related to the memory tracking thread #20695.
Plugins
None
OpenCode version
Current dev at dc4449df0d
Steps to reproduce
- Configure a local stdio MCP whose launcher spawns a long-lived child process.
- Connect it, then call MCP disconnect or replace the server under the same name.
- Observe that the launcher exits while the child process remains alive.
Screenshot and/or share link
N/A; covered by a deterministic PID-based regression test.
Operating System
Linux x64
Terminal
N/A (automated integration test)
Description
A local stdio MCP can spawn a wrapper process tree (
npm exec,uvx, shell wrappers). Explicit disconnect and dynamic replacement callclient.close(), which terminates the direct transport process but leaves its descendants running.Full instance teardown already enumerates and terminates descendants, so cleanup behavior differs by lifecycle path. I reproduced this with a real stdio MCP fixture: before the fix, the parent exits and the child remains alive past the assertion deadline.
Expected: every MCP client ownership exit terminates the same full local process tree.
Related but distinct from #46035: that report currently shows complete MCP sets with live launchers, while this issue covers descendants left after teardown is invoked. Also related to the memory tracking thread #20695.
Plugins
None
OpenCode version
Current
devatdc4449df0dSteps to reproduce
Screenshot and/or share link
N/A; covered by a deterministic PID-based regression test.
Operating System
Linux x64
Terminal
N/A (automated integration test)