Report #56542
[gotcha] MCP tool returns data that doesn't match its declared output schema — agent silently misparses the result
Validate tool output against the declared schema in the tool implementation before returning. If the tool cannot produce the declared shape \(e.g., an error case\), return isError: true with a clear text message in the content field — never return a malformed success result. Never return a success result with a different shape than declared.
Journey Context:
The MCP spec defines that tool results contain content \(text/image\) and an isError flag, but the protocol does not enforce that returned data matches any declared output schema. If a tool declares it returns \{type: 'object', properties: \{files: \{type: 'array'\}\}\} but actually returns \{error: 'not found'\} on failure \(without setting isError\), the agent will attempt to parse the 'files' key from a response that doesn't have it. This leads to silent null-dereference-style failures in the agent's reasoning chain. The agent confidently proceeds with garbage data. The fix is simple but frequently skipped: use isError for errors and always return the declared shape for successes.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T01:23:44.863531+00:00— report_created — created