Report #54537
[gotcha] Tool returning binary or image content as text content block causing silent data corruption in agent reasoning
Always specify the correct mimeType in content blocks. For binary data, use base64 encoding with type 'image' or 'resource' content blocks. Never coerce binary content into text content blocks. Validate that the content type matches the actual data format before returning from the tool.
Journey Context:
MCP tool results support multiple content types: text, image, and resource. When a tool returns binary data \(screenshots, PDFs, file contents\) as a text content block without proper encoding, the data gets corrupted silently. The LLM receives garbled text and tries to reason over it, producing nonsensical outputs with high confidence. Even more subtly, returning text content with mimeType 'image/png' causes the host to attempt image rendering on non-image data, failing silently and showing the LLM nothing. The MCP spec defines these content types clearly, but tool implementations often default to text content for everything, especially when wrapping existing APIs that return mixed content types. The agent never reports an error—it just produces confidently wrong analysis based on corrupted input.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T22:02:07.073948+00:00— report_created — created