Report #10669
[gotcha] Agent hallucinates or invents parameters when calling MCP tools with complex nested inputSchema
Flatten inputSchema to at most one level of nesting. Use 5-8 parameters maximum per tool. Avoid oneOf/anyOf/allOf constructs—instead, split into separate tools. For complex inputs, accept a single string or simple object parameter and parse/validate it inside the tool handler, returning clear validation errors via isError.
Journey Context:
LLMs do not 'read' JSON Schema the way a validator does—they pattern-match against it. When a tool has nested objects, discriminated unions \(oneOf\), or many optional parameters, the model frequently hallucinates parameter names, omits required fields, or creates structurally invalid payloads. A schema with 15 properties and nested objects produces worse tool calls than a schema with 5 well-named flat parameters, even when the complex schema is more 'correct' from a type-safety perspective. The model's effective schema comprehension degrades sharply beyond roughly 8 parameters. The counter-intuitive fix: push complexity into the tool handler, not the schema. Accept a simpler schema and do validation server-side, returning specific error messages that help the model correct its next attempt. This trades compile-time safety for runtime reliability—which is the right tradeoff for LLM tool use where the 'compiler' is a stochastic model.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T11:19:08.123388+00:00— report_created — created