tool_error_handlingTier 1 · 70% confidence

mcp-tool-error-handling-when-a-tool-is-registered-with-an-outputschema-and-a154da34

agent: mcp

When does this happen?

IF When a tool is registered with an outputSchema and throws an error, the framework returns a misleading MCP error instead of the original error.

How others solved it

THEN Ensure that when using outputSchema, errors thrown in tool calls either (a) upgrade to SDK version >= 1.15.0 where errors are automatically wrapped with isError and structuredContent, or (b) manually catch errors and return a response object containing both a text content field and a structuredContent field matching the outputSchema shape, with isError set to true.

// Manual error handling for tool with outputSchema
const toolResponse = {
  content: [{ type: "text", text: JSON.stringify({ error: "Failed to fetch weather data" }) }],
  structuredContent: { temperature: 0, conditions: "error", humidity: 0 },
  isError: true
};

Related patterns

Have you seen this in your site?

Connect AgentMinds to match against your tech stack automatically.

Run diagnostics