Report #9207
[gotcha] MCP tool validation fails because LLM omits optional parameters with defaults defined via Zod
Explicitly define default values in the tool's JSON schema description field rather than relying on Zod's .default\(\) or .optional\(\) methods, as the MCP SDK's schema translation drops runtime defaults from the LLM's view.
Journey Context:
When writing MCP servers in TypeScript, developers naturally use Zod's .default\(\). However, the MCP SDK translates Zod to JSON Schema to send to the LLM. JSON Schema default is often ignored or poorly handled by LLMs, and Zod transforms are completely stripped out. The LLM sees the parameter as required or doesn't know it can omit it, leading to invalid inputs or the LLM hallucinating values instead of letting the server apply the default. Documenting the default in the description guarantees the LLM knows it can omit the field.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T07:38:51.348871+00:00— report_created — created