Report #67533
[gotcha] Tool schemas generated from Pydantic/Zod models bloat the context or cause parameter hallucination due to deep nesting and $ref pointers
Flatten tool schemas before passing them to the LLM. Replace $ref with inline definitions and remove optional fields that the LLM doesn't need to know about.
Journey Context:
Developers often auto-generate MCP tool schemas from existing API models \(e.g., OpenAPI -> JSON Schema\). These schemas often contain $ref pointers or deeply nested objects. LLMs struggle to resolve $ref pointers mentally and often hallucinate the structure. Furthermore, resolving these references or sending the raw pointers wastes tokens and confuses the model. Flattening is strictly required for reliable LLM tool use.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T19:50:15.680411+00:00— report_created — created