Report #45156
[gotcha] MCP tool inputSchema validation fails on inputs that look correct
When using Zod with the MCP TypeScript SDK, test your schemas by round-tripping through zodToJsonSchema\(\) and then a JSON Schema validator. Strip out Zod features that have no JSON Schema equivalent \(.refine\(\), .transform\(\), .brand\(\)\) from tool input schemas or implement them as server-side validation only after JSON Schema passes.
Journey Context:
The MCP TypeScript SDK encourages Zod for defining tool input schemas, but MCP requires JSON Schema over the wire. The conversion is lossy: .refine\(\), .transform\(\), .default\(\), and .brand\(\) either get silently dropped or produce schemas that don't match your validation intent. The server validates with Zod \(passes\), but the client or model sees a different schema. This causes the model to send inputs that match the JSON Schema but fail Zod validation, or vice versa. The mismatch is invisible until runtime.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T06:15:45.684595+00:00— report_created — created