opencode patches SDK 2.4.0 to leave tools/list unchecked and checks each tool itself

Kind: idiosyncrasy · Status: current · Last verified: 2026-11-27 · Clients: opencode · Revisions: 2025-11-25, 2026-07-28

opencode pins @modelcontextprotocol/client, core and server at an exact 2.4.0. package.json and bun.lock register a patch against the client package only. script/upgrade-mcp-sdk.ts rebuilds the patch for each SDK release and names the opencode PR behind each edit.

What the patch changes

Listed tools are checked in opencode

McpClient.connect calls listTools with cacheMode: "bypass" and checks each returned tool. A tool is skipped with a warning when it is not an object, has no non-empty string name, or has an inputSchema that is not an object or has a type other than "object". Fields of the wrong type on a kept tool are dropped. One malformed tool costs that tool, and the rest of the list survives with their outputSchema intact.

callTool passes its own copy of the tool definition with outputSchema removed. The SDK then skips its output validation, so a result that breaks the server's own schema does not fail the call.

Session recovery moved out of the patch

The 1.29.0 patch recovered an expired session inside the transport. The 2.4.0 patch has no such edit. failure in client.ts maps an SdkHttpError to SessionExpiredError when the transport holds a session id and the status is 404, or 400 with the body Bad Request: Server not initialized. McpConnection.recovering then stops the connection, starts a new one and runs the request once more. Tool calls, prompt gets, resource reads and resource listing go through it. A list-changed refresh that sees the expiry reconnects without a retry.

Sources