Skip to content

Bug: Shared OpenCode host keeps per-directory MCP child processes alive on Windows after switching routed directories/worktrees #21557

@VooDisss

Description

@VooDisss

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

  1. Start one shared OpenCode host.
  2. Use MCP in directory A.
  3. Switch to directory B and use MCP there.
  4. Dispose or disconnect the previous directory instance.
  5. 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.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingcoreAnything pertaining to core functionality of the application (opencode server stuff)windows

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions