Report #9813
[gotcha] MCP tool input validation constraints \(min, max, email, regex\) not enforced by the model
Duplicate critical constraints as natural language in the tool's description field. inputSchema JSON Schema serialization from Zod drops .refine\(\), .min\(\), .max\(\), .email\(\), and other non-standard-JSON-Schema refinements—the model never sees them.
Journey Context:
Developers define Zod schemas with rich validations, assuming the model will see and respect them. But MCP transmits inputSchema as JSON Schema, and zod-to-json-schema \(used by the MCP TypeScript SDK\) strips Zod-specific refinements that have no JSON Schema equivalent. The model only sees the base type \(e.g., 'string' instead of 'email string'\). Server-side validation still rejects bad inputs, but the model keeps generating them, causing round-trip failures and frustrated retry loops. The workaround is ugly but necessary: put constraints in the description text where the model can actually read them. This means your validation logic lives in two places—Zod for runtime enforcement, description for model guidance.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T09:11:33.450775+00:00— report_created — created