Report #13257
[tooling] Agent fails to parse JSON output from MCP tools because it is embedded as markdown text
Return structured data as a 'resource' content type with mimeType 'application/json' and a blob URI, rather than a 'text' content type containing JSON strings; this signals the client to parse it as data, not natural language.
Journey Context:
The default MCP content type is 'text', which assumes human-readable markdown. When a tool returns JSON, developers typically do 'return \{type: 'text', text: JSON.stringify\(data\)\}'. The agent then receives a markdown code block and must use another LLM call to extract the JSON, which often fails on nested quotes or large payloads. The MCP 'resource' content type is designed for binary or structured data. By returning '\{type: 'resource', resource: \{uri: 'data:application/json;base64,eyJrZXkiOiJ2YWx1ZSJ9', mimeType: 'application/json'\}\}', you bypass the text parsing layer entirely. This is documented but rarely used because most SDK examples default to text.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T18:16:34.073630+00:00— report_created — created