Repository navigation
mcp: mcp list reports failed while API reports connected after server reconnect #50725
Copy link
Copy link
Open
Description
Related to #36623 (closed as completed, Jul 14) — but the inverse mismatch with a different trigger: after a server reconnect, opencode mcp list reports failed: Connection closed while GET /api/mcp reports connected, and already-running session catalogs don't refresh after POST /api/experimental/mcp/<name>/connect. The session-catalog half still reproduces today.
Summary
After a local MCP server's connection drops mid-session (server process was up while its backend was down), reconnecting succeeds at the service level — mcp connected server=... tools=152 is logged — but opencode mcp list keeps reporting failed: Connection closed while GET /api/mcp reports connected, and a running session never receives the server's tools.
Environment
- opencode version: v2.0.13
- OS: Linux 6.1.0-53-amd64 (linux x64)
- Terminal: TERM=xterm-256color, COLORTERM=truecolor
- Shell: /bin/bash
- Install/channel: latest
- Active plugins: none found in config
Reproduction
- Configure a local MCP server in the global config (used:
uv tool run --from git+https://github.com/... --with 'mcp<2' freecad-mcpwithenvironment: {FREECAD_MODE: xmlrpc, FREECAD_XMLRPC_PORT: "9875"}). - Start a session — server connects, tools appear in the catalog.
- Kill the backend the server depends on (FreeCAD bridge on port 9875) so the connection closes while the session is running.
- Restart the backend, then
POST /api/experimental/mcp/<server>/connect— log showsmcp connected server=freecad tools=152. - Compare status views, then check the running session.
Expected Behavior
opencode mcp listandGET /api/mcpagree on the server status.- After a successful service-level reconnect, running sessions either receive the server's tools, or there is a documented way to refresh them in-session.
Actual Behavior
opencode mcp list→✗ freecad failed: Connection closedGET /api/mcp→{"name":"freecad","status":{"status":"connected"}}(same moment)- Log confirms repeated successes after the failure:
level=WARN message="mcp connect failed" server=freecad status.error="Connection closed" level=INFO message="mcp connected" server=freecad tools=152 connectionID=9ecf... level=INFO message="mcp connected" server=freecad tools=152 connectionID=0ca0... level=INFO message="mcp connected" server=freecad tools=152 connectionID=523f... - The running session's tool catalog still contains 0 tools for the server namespace (
search({namespace:"freecad"})→ empty) even after the logged reconnects. - Each
connectcall creates a newconnectionID; the session's original connection (the one that failed) appears never to be revived.
Additional Context
- Frequency: consistent — 3 reconnect attempts, same split-brain status each time.
- The MCP server process itself is healthy: a manual stdio handshake (
initialize→tools/list) succeeds outside OpenCode. - Logs show
directory=/home/<user>on the MCP entries while the session workspace is a subdirectory of it — possibly relevant to which status is authoritative. - Workaround that resolves it: starting a new session (picks up the connected service-level server on startup).
/mcpswas attempted but arrived as plain text in this client rather than opening the panel, so in-session reconnect couldn't be tested.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
github-actions commentedon Sep 22, 2026
This issue might be a duplicate of existing issues. Please check:
The split-brain status between
opencode mcp listandGET /api/mcpappears to be a distinct angle not covered by those issues, so this may still warrant a separate report.msamesch commentedon Sep 22, 2026
catalog eventually populated later in the session; split-brain status from mcp list vs API persists