From 5bab04304fc1aacfbb4d8dcf31ca29768eb8a7bd Mon Sep 17 00:00:00 2001 From: Marcos Date: Wed, 9 Sep 2026 12:18:35 +0200 Subject: [PATCH] Fall back to native Claude Code tools when the OpenCode MCP bridge fails to build MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit buildOpenCodeMcpServer() swallows its own errors (logs a warning and returns undefined) instead of throwing, but bridgeOpenCodeTools was computed independently of that result. When the MCP server failed to build, the session still appended the "Built-in Claude Code tools are disabled, use only mcp__opencode__*" system prompt, emptied `tools`, and locked `allowedTools` to mcp__opencode__* names — while no such tools were ever registered. The agent was left with no filesystem access at all (no Read/Write/Edit/Bash, and no working substitute). Gate bridgeOpenCodeTools on mcpServers actually being truthy so a failed bridge build falls back to Claude Code's native built-in tools instead of a silent full lockout. --- src/proxy.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/proxy.ts b/src/proxy.ts index 8aae174..90c91f5 100644 --- a/src/proxy.ts +++ b/src/proxy.ts @@ -547,7 +547,12 @@ async function handleChatCompletions( ? await buildOpenCodeMcpServer(openCodeTools, pendingTools, notifyPark) : undefined; - const bridgeOpenCodeTools = !isMetaRequest && openCodeTools.length > 0; + // Only bridge to mcp__opencode__* when the MCP server actually built. + // buildOpenCodeMcpServer swallows its own errors (logs a warning, returns + // undefined) — without this guard the session still disables native tools + // and demands mcp__opencode__* even when none were ever registered, + // leaving the agent with no filesystem access at all. + const bridgeOpenCodeTools = !isMetaRequest && openCodeTools.length > 0 && Boolean(mcpServers); const openCodeToolNames = openCodeTools .map((t) => t.function?.name) .filter((n): n is string => typeof n === "string" && n.length > 0);