Report #5408
[tooling] Agent failing to parse structured JSON output from MCP tools due to markdown fences or ambiguous schemas
Return raw JSON strings in the \`text\` content field without markdown code fences \(e.g., \`\{"result": 42\}\` not \`\`\`json...\`\`\`\), and explicitly document the output JSON schema in the tool's \`description\` field since MCP has no native output schema.
Journey Context:
MCP's Tool schema only defines \`inputSchema\` \(arguments\), leaving outputs loosely typed. Developers often return markdown-formatted JSON \(\`\`\`json\) for human readability, but agents parse the raw string and fail to decode JSON because of the backticks. The fix requires discipline: treat the output as a wire protocol, not human-readable text. Documenting the expected output fields in the description \(e.g., 'Returns: \{"status": string, "id": number\}'\) allows the agent to plan tool chains correctly, knowing what data will be available for subsequent steps. This compensates for the lack of formal output schema in the MCP specification.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T21:13:57.347204+00:00— report_created — created