Description
When a Location is invalidated (config change, plugin reload, opencode reload), its stdio MCP servers are not closed at Location shutdown. LocationLifecycle shutdown closes permissions, forms and RPC, but MCP connections only close when the Location's layer scope is finalised. Running steps keep the old Location graph borrowed until a hand-off point, so the old graph's MCP processes keep running alongside the replacement graph's. On a long-lived server with frequent reloads they accumulate.
This is one of the causes of the process growth in #51003 (which is mainly about global stdio servers being started once per Location); the comment there showing that reload does not reap the previous boot's MCP subprocesses is this problem.
Plugins
Any configuration with local (stdio) MCP servers.
OpenCode version
v2.0.16 (also the current v2 branch)
Steps to reproduce
- Configure a global local MCP server and run
opencode serve.
- Start a session in a directory and keep a step running (or keep the Location otherwise borrowed).
- Trigger a Location reload (edit the config, or
opencode reload).
- The MCP process from the old Location graph is still running next to the new one; repeat to accumulate more.
Screenshot and/or share link
n/a
Operating System
Linux
Terminal
n/a
Description
When a Location is invalidated (config change, plugin reload,
opencode reload), its stdio MCP servers are not closed at Location shutdown.LocationLifecycleshutdown closes permissions, forms and RPC, but MCP connections only close when the Location's layer scope is finalised. Running steps keep the old Location graph borrowed until a hand-off point, so the old graph's MCP processes keep running alongside the replacement graph's. On a long-lived server with frequent reloads they accumulate.This is one of the causes of the process growth in #51003 (which is mainly about global stdio servers being started once per Location); the comment there showing that reload does not reap the previous boot's MCP subprocesses is this problem.
Plugins
Any configuration with local (stdio) MCP servers.
OpenCode version
v2.0.16 (also the current
v2branch)Steps to reproduce
opencode serve.opencode reload).Screenshot and/or share link
n/a
Operating System
Linux
Terminal
n/a