Report #80466
[frontier] Type mismatches between LLM outputs and MCP tool inputs causing runtime failures
Use Zod schemas to generate both TypeScript types and MCP tool schemas simultaneously; validate LLM outputs through the same Zod schema before passing to MCP tools to ensure end-to-end type safety
Journey Context:
Developers manually write MCP tool schemas \(JSON Schema\) separately from their TypeScript types, leading to drift where the LLM produces a string where a number is expected. The 2025 pattern uses zod-to-json-schema to generate MCP tool definitions directly from Zod validators. The LLM output is parsed through the same Zod schema, ensuring structural validation at the boundary. This eliminates runtime type errors in agent-tool chains.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T17:39:53.953501+00:00— report_created — created