MCP tool returning ImageContent with unsupported MIME type permanently breaks conversation (400 Could not process image)

Resolved 💬 4 comments Opened May 12, 2026 by pzfreo Closed May 15, 2026

Summary

When an MCP tool returns an ImageContent with an unsupported MIME type (e.g. image/svg+xml), Claude Code adds it to conversation history as-is. Every subsequent API call replays that history and fails with 400 Could not process image, making the session completely unrecoverable — even a simple \"hi\" fails.

Steps to reproduce

  1. Have an MCP server return a tool result containing:

``json
{"type": "image", "data": "<base64>", "mimeType": "image/svg+xml"}
``

  1. Claude Code includes this ImageContent in the conversation history.
  2. On the next turn, the API call includes the SVG image in history and returns 400 Could not process image.
  3. Every subsequent message — regardless of content — fails with the same error.
  4. The only recovery is starting a brand new conversation.

Root cause

Two independent failures:

1. No MIME type validation on MCP tool results. The Claude API only accepts image/png, image/jpeg, image/gif, and image/webp as inline image content. Claude Code should validate (or allowlist) MIME types from MCP ImageContent results before adding them to conversation history. An unsupported type should be dropped, converted to a text fallback, or flagged — not silently forwarded to the API.

2. No recovery path when an API 400 is caused by history content. When the API rejects a call due to a specific piece of content in history, Claude Code should be able to identify the offending message, skip or strip it, and retry. At minimum it should surface _which_ message is causing the problem and offer the user a way to remove it, rather than hard-locking the session indefinitely.

Impact

Any MCP server that returns ImageContent with a non-standard MIME type (SVG, PDF, etc.) will permanently break the session for the user. This is easy to hit accidentally — e.g. a rendering tool that returns both PNG and SVG results.

Expected behaviour

  • Claude Code rejects or drops ImageContent with unsupported MIME types at the point the MCP result is received, before it enters conversation history.
  • If a 400 error is caused by history content, Claude Code recovers gracefully (strips the offending content and retries, or prompts the user).

Context

Discovered via the build123d-mcp server, which was returning SVG as ImageContent(mimeType="image/svg+xml"). Fixed on the server side in v0.3.19, but the client should be resilient to this regardless of what MCP servers send.

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗