Bug Description
When OpenCode exits, MCP server child processes are not killed, leaving orphan processes running indefinitely. Additionally, OpenCode eagerly starts ALL configured stdio-type MCP servers at launch regardless of whether they will be used.
Impact
- 30 orphan node.exe processes accumulated (from just 2 sessions), each consuming 45-75MB RAM
- Total wasted memory: ~1.5GB
- CPU fan noise due to unnecessary load
Root Cause
- Process tree: OpenCode -> cmd /c npx -y -> node(npx-cli.js) -> node(MCP server)
- When OpenCode exits, it does not cascade SIGTERM/kill to child processes
- The cmd /c wrapper exits early (by design of /c), making npx and MCP server orphans
- Windows does not auto-clean orphan processes — they run forever waiting on closed stdin
All MCP servers are started eagerly
Even if a session never uses avily, exa, memory, sequential-thinking, or context7, all of them are launched at startup. This wastes CPU and memory on every session.
Expected Behavior
- On exit: OpenCode should kill all spawned child processes (the entire process tree)
- On startup: MCP servers should be lazily started only when first needed (or at least have a config option for this)
- Alternatively: MCP servers should detect stdin EOF and exit themselves
Environment
- Windows (Win32)
- OpenCode (latest)
- MCP servers launched via: \cmd /c npx -y @modelcontextprotocol/server-sequential-thinking\ (and similar)
Workaround
Users can manually kill orphan processes:
\\powershell
taskkill /f /im node.exe
\\
Or disable unused MCP servers in opencode.json to prevent them from starting.
Bug Description
When OpenCode exits, MCP server child processes are not killed, leaving orphan processes running indefinitely. Additionally, OpenCode eagerly starts ALL configured stdio-type MCP servers at launch regardless of whether they will be used.
Impact
Root Cause
All MCP servers are started eagerly
Even if a session never uses avily, exa, memory, sequential-thinking, or context7, all of them are launched at startup. This wastes CPU and memory on every session.
Expected Behavior
Environment
Workaround
Users can manually kill orphan processes:
\\powershell
taskkill /f /im node.exe
\\
Or disable unused MCP servers in opencode.json to prevent them from starting.