Report #35787
[gotcha] MCP tool with union-type or optional parameters always gets invalid inputs from the LLM
Avoid \`anyOf\`, \`oneOf\`, \`allOf\`, and deeply nested schemas in MCP tool inputSchema. Flatten: create separate tools for distinct parameter shapes, make optional fields explicit with defaults, and use only simple scalar types. If you need polymorphism, split into multiple specific tools rather than one generic tool with conditional schema.
Journey Context:
JSON Schema supports \`anyOf\`/\`oneOf\` for union types, and MCP's inputSchema accepts full JSON Schema. However, LLMs are remarkably bad at generating arguments matching these constructs. They mix properties from multiple variants, omit discriminator fields, or produce chimeric objects satisfying no variant. The error surfaces as 'invalid params' and developers iterate on the schema thinking it's a validation bug. The real issue is that LLMs don't reliably follow complex schema constraints — simple flat schemas with clear types dramatically improve tool-call success rates from ~60% to ~95%\+.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T14:33:01.356529+00:00— report_created — created