MCP client failing makes opencode hang. #2172

Open
opened 2026-02-16 17:34:31 -05:00 by yindo · 5 comments
Owner

Originally created by @cvkmohan on GitHub (Oct 18, 2025).

Originally assigned to: @thdxr on GitHub.

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

Originally created by @cvkmohan on GitHub (Oct 18, 2025). Originally assigned to: @thdxr on GitHub. ### 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_
yindo added the bug label 2026-02-16 17:34:31 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Oct 18, 2025):

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.

@github-actions[bot] commented on GitHub (Oct 18, 2025): 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.
Author
Owner

@rekram1-node commented on GitHub (Oct 19, 2025):

I think dax addressed this in a version of opencode that ships next week

@rekram1-node commented on GitHub (Oct 19, 2025): I think dax addressed this in a version of opencode that ships next week
Author
Owner

@venzen commented on GitHub (Nov 14, 2025):

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/ai@5.0.8+d6123d32214422cb/node_modules/ai/dist/index.mjs:8602:19)
      at close (../../node_modules/.bun/@modelcontextprotocol+sdk@1.15.1/node_modules/@modelcontextprotocol/sdk/dist/esm/client/sse.js:137:9)
      at close (../../node_modules/.bun/@modelcontextprotocol+sdk@1.15.1/node_modules/@modelcontextprotocol/sdk/dist/esm/client/sse.js:133:9)
      at close (../../node_modules/.bun/ai@5.0.8+d6123d32214422cb/node_modules/ai/dist/index.mjs:8444:60)
      at close (../../node_modules/.bun/ai@5.0.8+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 commented on GitHub (Nov 14, 2025): 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/ai@5.0.8+d6123d32214422cb/node_modules/ai/dist/index.mjs:8602:19) at close (../../node_modules/.bun/@modelcontextprotocol+sdk@1.15.1/node_modules/@modelcontextprotocol/sdk/dist/esm/client/sse.js:137:9) at close (../../node_modules/.bun/@modelcontextprotocol+sdk@1.15.1/node_modules/@modelcontextprotocol/sdk/dist/esm/client/sse.js:133:9) at close (../../node_modules/.bun/ai@5.0.8+d6123d32214422cb/node_modules/ai/dist/index.mjs:8444:60) at close (../../node_modules/.bun/ai@5.0.8+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?
Author
Owner

@rekram1-node commented on GitHub (Nov 14, 2025):

@venzen if u run opencode upgrade 1.0.65 I think this was fixex

@rekram1-node commented on GitHub (Nov 14, 2025): @venzen if u run `opencode upgrade 1.0.65` I think this was fixex
Author
Owner

@lovato commented on GitHub (Dec 19, 2025):

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.

@lovato commented on GitHub (Dec 19, 2025): 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.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#2172