fix(mcp): handle tool result errors (#32244)

This commit is contained in:
Aiden Cline
2026-06-14 21:16:39 -05:00
committed by GitHub
parent 1338d7b47a
commit dfb616f067
2 changed files with 33 additions and 0 deletions
+7
View File
@@ -63,6 +63,13 @@ export function convertTool(mcpTool: MCPToolDef, client: Client, timeout?: numbe
timeout,
},
)
if (result.isError)
throw new Error(
result.content
.flatMap((item) => (item.type === "text" ? [item.text] : []))
.filter((text) => text.trim())
.join("\n\n") || "MCP tool returned an error",
)
if (result.structuredContent === undefined || result.structuredContent === null) return result
return {
...result,