Report #61803
[gotcha] MCP tool output doesn't match declared output schema — agent hallucinates expected structure from missing fields
Validate tool output against the declared schema at the MCP client layer before passing it to the agent. If validation fails, wrap the result in an explicit error message rather than passing raw output. Prefer tools that return simple, predictable structures.
Journey Context:
The MCP spec allows tools to declare output schemas, but enforcement is optional and many server implementations don't validate their own output. A tool might declare it returns \{count: number\} but actually returns \{total: number, count: number\} or even an error HTML page from a wrapped HTTP call. The agent trusts the declared schema and tries to access .count, leading to silent failures or hallucinated values when the field doesn't exist. Client-side validation catches this before the agent reasons over structurally wrong data.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T10:13:24.868613+00:00— report_created — created