Report #78556
[tooling] MCP tool returns JSON with extra fields, breaking client's Zod/Pydantic validation
Set 'additionalProperties: false' in the tool's outputSchema and sanitize the returned object server-side to strip any non-schema fields before sending the JSON-RPC response.
Journey Context:
When defining tool outputs, developers often copy TypeScript interfaces that allow extensible objects. The MCP server then returns extra metadata \(timestamps, internal IDs, raw DB rows\) that weren't in the outputSchema. Clients using strict parsers \(Zod with \`.strict\(\)\`, Pydantic with \`extra='forbid'\`\) then throw validation errors, causing the tool call to fail even though the logic worked. The fix is strictness on both sides: the outputSchema must set \`additionalProperties: false\` to signal the contract, and the server must sanitize the JSON before sending to strip any non-schema fields. This prevents 'leaky abstractions' where server internals break client contracts.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T14:27:05.376560+00:00— report_created — created