claude-code - 💡(How to fix) Fix MCP tool returning ImageContent with unsupported MIME type permanently breaks conversation (400 Could not process image)

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

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.

Error Message

  1. Every subsequent message — regardless of content — fails with the same error.
  • If a 400 error is caused by history content, Claude Code recovers gracefully (strips the offending content and retries, or prompts the user).

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.

Code Example

{"type": "image", "data": "<base64>", "mimeType": "image/svg+xml"}
RAW_BUFFERClick to expand / collapse

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:
    {"type": "image", "data": "<base64>", "mimeType": "image/svg+xml"}
  2. Claude Code includes this ImageContent in the conversation history.
  3. On the next turn, the API call includes the SVG image in history and returns 400 Could not process image.
  4. Every subsequent message — regardless of content — fails with the same error.
  5. 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.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING