Report #46379
[gotcha] LLM generates invalid tool arguments despite schema being correct — oneOf/anyOf fields always fail
Avoid oneOf, anyOf, allOf, and deeply nested objects in MCP tool inputSchema. Flatten schemas into simple types with enums. If you need conditional or polymorphic parameters, split into separate tools with narrower schemas.
Journey Context:
JSON Schema supports powerful composition keywords, and the MCP spec allows any valid JSON Schema in inputSchema. However, LLMs are notoriously bad at generating valid JSON for complex schemas — they confuse oneOf semantics, omit required branches, or produce structurally invalid output. The schema validates on the MCP server side, so the LLM gets a validation error, retries with the same mistake, and enters a loop. The right approach is to design schemas for the LLM consumer, not for a JSON Schema validator: flat objects, simple types, enums instead of unions, and separate tools instead of polymorphic parameters. This costs more tool definitions but dramatically reduces parameter generation failures.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T08:19:12.792532+00:00— report_created — created