You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(mcp): MCP status shows connected green after server reconnect even though server is down #24855
After a network disruption or server restart causes OpenCode to reconnect, the MCP status indicator continues to show all servers as green (connected), but the underlying MCP server processes may have been lost. The status is stale because Instance.state() in packages/opencode/src/mcp/index.ts caches MCP client state indefinitely per project instance keyed by directory. When Instance.reload() is triggered by reconnect logic, the old cached status and clients maps are preserved even though the server-side processes are gone, resulting in a false-positive 'all online' display.
Steps to Reproduce
Start OpenCode with one or more MCP servers configured and connected.
Observe the MCP status indicator in the bottom status bar shows green.
Cause a reconnect (e.g. network disruption, or restart the OpenCode backend server).
After reconnect completes, the status bar still shows all MCP servers green.
Try to invoke an MCP tool — it may fail because the actual stdio/HTTP transport is no longer alive.
Expected Behavior
When the server reconnects, the MCP cached state should be invalidated so the next status() call re-evaluates actual server connectivity.
Actual Behavior
The cached Instance.state() for MCP survives across server reconnects, displaying stale connected statuses.
Additional Context
Instance.state() uses a ScopedCache keyed by directory without an explicit expiration or invalidation hook on reconnect events. The MCP init callback only runs once per instance, and Instance.reload() disposes the old instance but the new instance may re-use the same directory key before the old cache entry is fully cleared, depending on timing.
If this is a distinct issue (specifically the stale green status indicator after reconnect rather than tool unavailability), please clarify what distinguishes it from the above.
Closing as fixed by #32084. OpenCode now registers client.onclose, removes the closed client and cached tools, marks the MCP status as failed, and publishes the tool-catalog change. General automatic reconnection remains tracked separately in #25287.
Activity
github-actions commentedon Apr 28, 2026
This issue might be a duplicate of existing issues. Please check:
listTools()failure — covers similarInstance.state()/ client eviction mechanics inmcp/index.tsIf this is a distinct issue (specifically the stale green status indicator after reconnect rather than tool unavailability), please clarify what distinguishes it from the above.
rekram1-node commentedon Jun 24, 2026
Closing as fixed by #32084. OpenCode now registers
client.onclose, removes the closed client and cached tools, marks the MCP status as failed, and publishes the tool-catalog change. General automatic reconnection remains tracked separately in #25287.