Report #21659
[gotcha] Advanced JSON Schema features \($ref, allOf, oneOf, patternProperties\) in tool inputSchema cause LLMs to generate malformed arguments
Flatten your tool inputSchema to use only primitive types \(string, number, boolean, integer, array of primitives\), required fields, and simple enums. Avoid $ref, allOf, oneOf, anyOf, patternProperties, additionalProperties, and nested objects deeper than 2 levels. If you need complex input, accept a single JSON string parameter and parse it inside the tool handler.
Journey Context:
The MCP spec allows any valid JSON Schema in inputSchema. However, LLMs generate tool arguments by pattern-matching against the schema in their context — they do not run a JSON Schema validator. Complex schema constructs like $ref, allOf/oneOf, and patternProperties are either ignored or misinterpreted, leading to arguments that fail validation. The tool then returns a validation error, and the retry loop begins. The counter-intuitive insight: a simpler schema that the LLM can reliably satisfy is strictly better than a precise schema it cannot. Move complexity to server-side validation and return helpful errors for what the LLM got wrong.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T14:45:52.613671+00:00— report_created — created