[BUG] Image format mismatch error with Playwright MCP screenshot tool

Status Closed — not planned
Maintainer reply None cached
Activity 9 comments · opened Nov 21, 2025 · closed Feb 2, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

When using the mcp__playwright__browser_take_screenshot tool through Claude Code, the API consistently returns a 400 error indicating that the image data doesn't match the declared MIME type.

What Should Happen?

Expected Behavior:
The screenshot image should be successfully captured and displayed in the conversation without format mismatch errors.

Error Messages/Logs

API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.5.content.7.image.source.base64.data: Image does not match the provided media type image/jpeg"},"request_id":"req_011CVMaFmiYjEXhaXnfkgRSC"}

Steps to Reproduce

  1. Have Playwright MCP server configured in Claude Code
  2. Ask Claude to take a screenshot of a web page using the Playwright tool
  3. The error occurs when Claude tries to send the screenshot image back in the conversation

Claude Model

Sonnet (default)

Is this a regression?

Yes, this worked in a previous version

Last Working Version

_No response_

Claude Code Version

claude --version 2.0.49 (Claude Code)

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

Expected Behavior:
The screenshot image should be successfully captured and displayed in the conversation without format mismatch errors.

Actual Behavior:
The API rejects the message because the base64-encoded image data doesn't match the declared MIME type (image/jpeg). The actual image data appears to be in PNG format while being labeled as JPEG.

Root Cause:
This appears to be a bug in the system layer between the MCP tool result and the API message construction. The issue is in how Claude Code processes the Playwright screenshot tool's output:

  1. The Playwright tool returns image data (likely PNG by default)
  2. The system layer incorrectly labels it as image/jpeg when constructing the API message
  3. The API validates the format and rejects the mismatch

Suggested Fix:
The system layer that processes MCP tool results should either:

  1. Correctly detect the actual image format from the tool output and set the matching MIME type
  2. Respect the type parameter passed to the screenshot tool and ensure consistency
  3. Default to PNG format throughout the pipeline if that's what Playwright returns

Workaround:
Use mcp__playwright__browser_snapshot instead, which returns text-based accessibility information rather than images.

View original on GitHub ↗

9 Comments

github-actions[bot] · 10 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/11975
  2. https://github.com/anthropics/claude-code/issues/11931
  3. https://github.com/anthropics/claude-code/issues/11936

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

vuyelwadr · 10 months ago

same issue for me too

API Error: 400
{"type":"error","error":{"type":"invalid_request_error","message":"messages.7.content.2.image.source.base64.data:
Image does not match the provided media type image/jpeg"},"request_id":"req_011CVMcaELvacfxKnKvAUr3L"}

cant send more messages or compact afterwards

Boanerges1996 · 10 months ago

Same here

onurorhon · 10 months ago

Once I get the API error, the whole chat freezes. The only way I can continue is to restore to an earlier checkpoint.

github-actions[bot] · 9 months ago

This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.

satya-waylit · 9 months ago

Still an issue

github-actions[bot] · 8 months ago

This issue has been automatically closed due to 60 days of inactivity. If you're still experiencing this issue, please open a new issue with updated information.

marcindulak · 8 months ago

This issue was closed incorrectly despite recent human comments. This behavior of the bot is reported at https://github.com/anthropics/claude-code/issues/16497. Please upvote that issue, so maybe it gets noticed.

github-actions[bot] · 8 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.