Playwright MCP screenshot in Claude Code: "Image does not match the provided media type image/jpeg"
Using Playwright MCP v0.0.47 (Docker
mcr.microsoft.com/playwright/mcp) with Claude Code v2.0.47 on Ubuntu 22.04 and macOS,browser_take_screenshotwithout an explicit format causes "API Error: 400 ... Image does not match the provided media type image/jpeg". The screenshot file is saved correctly, but the error poisons the session so every later message fails until/clear. What causes this and how can I avoid it without losing the conversation?Originally asked on GitHub: https://github.com/microsoft/playwright-mcp/issues/1211
6 answers
Status: the issue is closed in the repo, but the thread does not mention a fixed version. Users identified the cause: when a screenshot is taken without specifying a format, the file is saved as PNG while the MCP response still declares
image/jpeg, so the Claude API rejects the whole message. The maintainer could not reproduce it, and one user still hit it on v0.0.42.The workaround that worked in the thread is to explicitly request JPEG. A user reproduced the bug with a screenshot request that did not specify a format (PNG default), while asking for "a screenshot in JPG" made the tool call include
type: "jpeg"and the image came through without the 400 error. So prompt for JPEG, or otherwise make Claude call the tool withtypeset tojpeg.Downgrading helped the original reporter:
docker pull mcr.microsoft.com/playwright/mcp:v0.0.42, then run the samedocker runcommand with thev0.0.42image. Another commenter, however, still got the same 400 on v0.0.42 when requesting a PNG screenshot, so the downgrade is not a reliable fix.For an npx-based setup, one commenter said they fixed it by removing and re-adding the pinned server:
bashclaude mcp remove playwright claude mcp add playwright -s user -- npx -y @playwright/mcp@0.0.42Then restart Claude Code. Another user suggested forcing Claude Code to ask for authorization before
take_screenshotand refusing the call when a screenshot isn't needed, but no one in the thread reported whether that worked. If a session is already poisoned,/clearresets it; a community script to prune the bad history message was also shared.Did this work for you?What @larbifattah tried on GitHub (Partly worked)
Reproduced the exact trigger in Claude Code: a screenshot request without a format (saved as .png) produced the 400 "media type image/jpeg" error, while the same page requested as JPEG with
type: "jpeg"displayed correctly.Did this work for you?What a GitHub user tried on GitHub (Worked)
The issue reporter downgraded the Docker image to
mcr.microsoft.com/playwright/mcp:v0.0.42and ran the samedocker runcommand; they confirmed it worked without errors.Source: https://github.com/microsoft/playwright-mcp/issues/1211 (opens external site)
Did this work for you?What @elouardy tried on GitHub (Worked)
One commenter fixed their setup by removing the server with
claude mcp remove playwright, re-adding it pinned withclaude mcp add playwright -s user -- npx -y @playwright/mcp@0.0.42, and restarting Claude Code.Did this work for you?What @0xalex88 tried on GitHub (Didn't work)
Another user stayed on Docker v0.0.42 and asked for a PNG screenshot from google.com; the file was saved, but the same 400 "expects jpeg" error still appeared, so the downgrade did not fix it for them.
Did this work for you?What @mfucci tried on GitHub (Outcome unclear)
A commenter suggested forcing Claude Code to request user authorization for
take_screenshotand refusing the call when a screenshot isn't actually needed; they also planned to try the downgrade, but no outcome was reported.Did this work for you?
Related questions
- Playwright MCP browser_take_screenshot shows no saved file or unreadable image in Cursor or VS Code
- Windows: playwright-mcp via Claude Desktop fails: Chromium distribution 'chrome' is not found
- playwright-mcp fails to start in Cursor after 0.0.19/0.0.20 (Client closed / Connection closed)
- Can I generate codegen-style Playwright test code from a prompt-driven playwright-mcp flow?
- Does Playwright MCP have a quiet mode to reduce page snapshot tokens?