Description
On Windows, a shared OpenCode host does not clean up old MCP child processes when switching between routed directories/worktrees.
After using MCP in directory A and then directory B, I still see both mcp-server.exe processes alive under one opencode.exe, even after mcp.disconnect(...) or instance.dispose() for the previous directory. This keeps the executable locked and blocks rebuilds.
Steps to reproduce
- Start one shared OpenCode host.
- Use MCP in directory A.
- Switch to directory B and use MCP there.
- Dispose or disconnect the previous directory instance.
- Check running processes.
Expected behavior
The old MCP child exits.
Actual behavior
The old MCP child stays alive.
Notes
The host itself is not exiting here. I attached a markdown file with more detailed investigation.
opencode-shared-host-mcp-lifecycle-issue.md - more context for your agents inside.
Description
On Windows, a shared OpenCode host does not clean up old MCP child processes when switching between routed directories/worktrees.
After using MCP in directory A and then directory B, I still see both
mcp-server.exeprocesses alive under oneopencode.exe, even aftermcp.disconnect(...)orinstance.dispose()for the previous directory. This keeps the executable locked and blocks rebuilds.Steps to reproduce
Expected behavior
The old MCP child exits.
Actual behavior
The old MCP child stays alive.
Notes
The host itself is not exiting here. I attached a markdown file with more detailed investigation.
opencode-shared-host-mcp-lifecycle-issue.md - more context for your agents inside.