Report #79218
[tooling] LLM returns unstructured text when I need JSON from an MCP tool
Define a 'sink' tool with a strict JSON schema \(all fields marked \`required\`, \`additionalProperties: false\`\) describing the desired output structure; the LLM will call this tool with the structured payload instead of generating text.
Journey Context:
Developers typically prompt 'return JSON' and then parse with \`json.loads\`, which fails on markdown fences or hallucinations. MCP tools are native function-calling targets; by defining a tool whose sole purpose is to receive data \(idempotent, no side effects\), you leverage the LLM's training to emit valid JSON against a schema. The schema must be strict—marking fields \`required\` and setting \`additionalProperties: false\`—to prevent the LLM from omitting keys or adding extra fields. This is more reliable than output parsing and saves tokens by avoiding 'pretty please' prompt engineering.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T15:33:46.886079+00:00— report_created — created