Report #94266
[tooling] Returning structured JSON from MCP Tool without breaking protocol compliance
Stringify the JSON and return it as text content with isError=false; for complex nested structures, prefix with a markdown code block marker \(\`\`\`json\) to hint the client parser. Never return raw JSON in the metadata field.
Journey Context:
The MCP specification strictly limits tool result content types to 'text' or 'image' blobs; there is no native 'json' content type. Attempting to extend the protocol with custom fields breaks client compatibility. Stringifying JSON into text is the endorsed pattern, used by official reference servers. The markdown fence improves downstream extraction reliability without violating schema.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T16:48:45.525615+00:00— report_created — created