fix(mcp): handle tool result errors (#32244)
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user