MCP client failing makes `opencode` hang.
Description
Suppose we configure opencode with an MCP server - for example tidewave. Now tidewave will run well as long as phx.server is running fine. For whatever reason, suppose there is a compilation error and at that time, phx.server gets stopped - tidewave also gets stopped. Now, opencode which has in its config a running MCP tidewave server also stops working. I think it is not the desired behavior. If an MCP server fails to init - opencode should ignore it and move on - rather than becoming non-functional.
Steps to reproduce
No response
Screenshot and/or share link
No response
Operating System
No response
Terminal
No response
OpenCode version
No response
This issue might be a duplicate of existing issues. Please check:
- #829: MCP server failed to start (unstable MCP servers) - Describes similar behavior where MCP connection failures during startup cause opencode to give up instead of gracefully handling the failure
- #1195: Some docker based MCPs prevent opencode shutdown - Shows how MCP server failures can prevent normal opencode operation and shutdown
- #504: big mess in terminal when MCP server fails - Documents poor error handling when MCP servers fail to initialize
- #1878: MCPClientError: Attempted to send a request from a closed client - Shows errors when MCP clients become unavailable during operation
Feel free to ignore if none of these address your specific case.
I think dax addressed this in a version of opencode that ships next week
I have a related issue in v0.15.31 where the LLM becomes unresponsive when an MCP connection closes during a session:
8597 | }
8598 | onClose() {
8599 | if (this.isClosed)
8600 | return;
8601 | this.isClosed = true;
8602 | const error = new MCPClientError({
^
MCPClientError: Connection closed
cause: undefined,
vercel.ai.error: true,
vercel.ai.error.AI_MCPClientError: true,
at onClose (../../node_modules/.bun/[email protected]+d6123d32214422cb/node_modules/ai/dist/index.mjs:8602:19)
at close (../../node_modules/.bun/@[email protected]/node_modules/@modelcontextprotocol/sdk/dist/esm/client/sse.js:137:9)
at close (../../node_modules/.bun/@[email protected]/node_modules/@modelcontextprotocol/sdk/dist/esm/client/sse.js:133:9)
at close (../../node_modules/.bun/[email protected]+d6123d32214422cb/node_modules/ai/dist/index.mjs:8444:60)
at close (../../node_modules/.bun/[email protected]+d6123d32214422cb/node_modules/ai/dist/index.mjs:8440:17)
at map (1:11)
at <anonymous> (src/mcp/index.ts:40:7)
at <anonymous> (src/mcp/index.ts:38:11)
Is this expected behavior or shall I open a new bug for this?
@venzen if u run opencode upgrade 1.0.65 I think this was fixex
I dug to find something similar to my problem, and I think this is it. On my company, the MCP server I am testing through OAuth needs both VPN and Proxy (not in prod yet). Fair. But if it happens for my laptop to just be disconnected from the VPN and I just need to do other stuff using opencode, it just hangs, since THAT MCP server isn't reachable right now. I could put helpers to inject/remove the config for this test phase, but maybe there is a better way to approach the problem. On VSCode, all MCP configuration are just configuration bits, and you turn on/off they as you need.