[BUG] Image format mismatch error with Playwright MCP screenshot tool
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
- Have Playwright MCP server configured in Claude Code
- Ask Claude to take a screenshot of a web page using the Playwright tool
- 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:
- The Playwright tool returns image data (likely PNG by default)
- The system layer incorrectly labels it as
image/jpegwhen constructing the API message - The API validates the format and rejects the mismatch
Suggested Fix:
The system layer that processes MCP tool results should either:
- Correctly detect the actual image format from the tool output and set the matching MIME type
- Respect the
typeparameter passed to the screenshot tool and ensure consistency - 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.
9 Comments
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
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
Same here
Once I get the API error, the whole chat freezes. The only way I can continue is to restore to an earlier checkpoint.
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.
Still an issue
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.
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.
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.