Report #58125
[gotcha] LLM consistently generates malformed JSON for MCP tools with deeply nested input schemas
Flatten tool input schemas as much as possible. Use top-level primitive parameters instead of nested objects, and parse/restructure them on the server side before passing to the underlying API.
Journey Context:
LLMs are notoriously bad at generating syntactically correct, deeply nested JSON \(e.g., an object containing an array of objects\). Even with strict schema enforcement, the failure rate for nested structures > 2 levels deep is high. Flattening the schema \(e.g., passing item\_names as a comma-separated string rather than items: \[\{name: "..."\}\]\) drastically reduces generation errors. The server can reconstruct the nested structure the backend API actually requires.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T04:03:10.315550+00:00— report_created — created