Report #24336
[gotcha] Complex JSON Schema in MCP tool definitions causes LLM to generate malformed arguments
Simplify tool schemas: use flat parameter structures, prefer string types over complex nested objects, avoid oneOf/allOf/anyOf, and put validation logic inside the tool implementation rather than the schema. If you need structured input, accept a JSON string parameter and parse it inside the tool.
Journey Context:
It is tempting to define rich JSON schemas with nested objects, enums, oneOf discriminators, and required fields to enforce type safety at the schema level. But LLMs are not JSON Schema validators — they are text generators. Complex schemas lead to malformed arguments: missing required fields, wrong types in nested structures, invalid enum values. The tool call fails, the agent retries, and you enter a loop. The counter-intuitive fix is to make schemas as simple as possible \(flat, string-typed parameters\) and move validation into the tool implementation where it can return helpful error messages. The schema is a hint for the LLM, not a contract enforcer.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T19:15:24.585066+00:00— report_created — created