Skip to content

MCP: Image media type mismatch in tool_result causes Claude API rejection #2

@y736674690-lab

Description

@y736674690-lab

Description

When using the Anima MCP server (https://public-api.animaapp.com/v1/mcp), the codegen-figma_to_code tool returns snapshot images with an incorrect media type, causing the Claude API to reject the entire request.

Error Message

messages.164.content.0.tool_result.content.1.image.source.base64: The image was specified using the image/png media type, but the image appears to be a image/jpeg image

Root Cause

The MCP server appears to hardcode the media type as image/png for all snapshot images returned in tool_result. However, the actual image data (likely fetched from the Figma Image API) can be JPEG. The Claude API validates the base64 image content against the declared media type and rejects the request when they don't match.

Steps to Reproduce

  1. Configure the Anima MCP server in any MCP-compatible client (Claude Code, Cursor, OpenCode, etc.)
  2. Call the figma_to_code tool with a Figma design URL that contains nodes without transparency (Figma tends to return JPEG for these)
  3. The MCP server returns a tool_result containing the snapshot image with media_type: "image/png" while the actual image bytes are JPEG
  4. The AI provider API rejects the request due to the media type mismatch

Expected Behavior

The MCP server should detect the actual image format (by inspecting magic bytes or the Content-Type header from Figma) and set the correct media type (image/jpeg or image/png) accordingly. Alternatively, the server could convert all images to PNG before returning them.

Impact

This is a blocking issue — when it occurs, the entire Figma-to-code flow fails because the AI never receives the tool result. There is no client-side workaround since the MCP client transparently forwards the tool_result to the AI provider.

Environment

  • MCP endpoint: https://public-api.animaapp.com/v1/mcp
  • MCP transport: HTTP (Streamable)
  • Client: OpenCode (also reproducible with other MCP clients)
  • AI provider: Anthropic Claude API

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions