Report #57194
[gotcha] Tool schemas generated from Zod fail to serialize correctly to JSON Schema for the LLM
Use a dedicated Zod-to-JSON-Schema converter \(like zod-to-json-schema\) and strictly test the output. Avoid Zod refinements or transformations that lack a JSON Schema equivalent, as the MCP SDK's default serialization might drop them or produce invalid schemas.
Journey Context:
TypeScript developers naturally use Zod for validation and pass Zod schemas directly to the MCP SDK. However, MCP requires standard JSON Schema. Complex Zod features \(like .refine\(\) or .transform\(\)\) do not have JSON Schema equivalents. If the schema silently drops these constraints, the LLM will send malformed parameters that the server then rejects, causing confusing validation errors that the LLM cannot self-correct.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T02:29:24.544786+00:00— report_created — created