Description
When a remote MCP server invalidates a streamable-HTTP session (server restart, idle timeout, periodic rotation, etc.), opencode keeps sending the same stale mcp-session-id. The server returns:
Streamable HTTP error: Error POSTing to endpoint: {"error":"Session not found"}
Once this happens, every subsequent tool call against that MCP server fails with the same error for the rest of the opencode session. The only fix is opencode mcp logout && opencode mcp auth and a process restart. There's no retry, no reconnect, no onclose handler.
This is in the same family as #17099 (no retry / reconnect for listTools() failures) but on a different code path: client.callTool() in convertMcpTool (packages/opencode/src/mcp/index.ts). #15209 reported essentially the same bug back in February but was auto-closed for not following the issue template — reopening here properly.
Steps to reproduce
- Configure a remote streamable-HTTP MCP server.
- Use it normally — agent calls a few tools successfully.
- Restart that MCP server (or wait for any server-side session invalidation).
- Have the agent call any tool on that server again.
- →
Streamable HTTP error: Error POSTing to endpoint: {"error":"Session not found"}. All subsequent calls to that server fail until opencode is restarted.
OpenCode version
1.14.30
Operating System
macOS 14 (Sequoia)
Expected
When the server reports the session is gone, opencode rebuilds the transport and replays the call once. If the retry also fails, surface the error normally.
Description
When a remote MCP server invalidates a streamable-HTTP session (server restart, idle timeout, periodic rotation, etc.), opencode keeps sending the same stale
mcp-session-id. The server returns:Once this happens, every subsequent tool call against that MCP server fails with the same error for the rest of the opencode session. The only fix is
opencode mcp logout && opencode mcp authand a process restart. There's no retry, no reconnect, noonclosehandler.This is in the same family as #17099 (no retry / reconnect for
listTools()failures) but on a different code path:client.callTool()inconvertMcpTool(packages/opencode/src/mcp/index.ts). #15209 reported essentially the same bug back in February but was auto-closed for not following the issue template — reopening here properly.Steps to reproduce
Streamable HTTP error: Error POSTing to endpoint: {"error":"Session not found"}. All subsequent calls to that server fail until opencode is restarted.OpenCode version
1.14.30
Operating System
macOS 14 (Sequoia)
Expected
When the server reports the session is gone, opencode rebuilds the transport and replays the call once. If the retry also fails, surface the error normally.