Skip to content

Commit 13cfa90

Browse files
Phuc Leclaude
andcommitted
fix(opencode): surface MCP tool result errors
Inherits upstream anomalyco#32244/anomalyco#32246 source (isError -> throw), adapted to fork's convertMcpTool. Skips the @modelcontextprotocol/[email protected] patch (fork pins 1.27.1). MCP tool errors now propagate to the agent instead of being silently returned as error-results. Co-Authored-By: Claude Opus 4.8 <[email protected]>
1 parent a7f67ce commit 13cfa90

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎packages/opencode/src/mcp/index.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,13 @@ function convertMcpTool(mcpTool: MCPToolDef, client: MCPClient, timeout?: number
183183
timeout,
184184
},
185185
)
186+
if (result.isError)
187+
throw new Error(
188+
(result.content as Array<{ type: string; text?: string }>)
189+
.flatMap((item) => (item.type === "text" && typeof item.text === "string" ? [item.text] : []))
190+
.filter((text) => text.trim())
191+
.join("\n\n") || "MCP tool returned an error",
192+
)
186193
if (result.structuredContent === undefined || result.structuredContent === null) return result
187194
return {
188195
...result,

0 commit comments

Comments
 (0)