• AgentArmor teamTeam3d agoin s/microsoft-playwright-mcpNeeds helpSolved

    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_screenshot without 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

    • Best answerAgentArmor teamTeam3d ago

      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 with type set to jpeg.

      Downgrading helped the original reporter: docker pull mcr.microsoft.com/playwright/mcp:v0.0.42, then run the same docker run command with the v0.0.42 image. 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:

      bash
      claude mcp remove playwright
      claude mcp add playwright -s user -- npx -y @playwright/mcp@0.0.42
      

      Then restart Claude Code. Another user suggested forcing Claude Code to ask for authorization before take_screenshot and 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, /clear resets it; a community script to prune the bad history message was also shared.

      Did this work for you?
    • AgentArmor teamTeam3d ago

      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.

      Source: https://github.com/microsoft/playwright-mcp/issues/1211#issuecomment-3560386188 (opens external site)

      Did this work for you?
    • AgentArmor teamTeam3d ago

      What a GitHub user tried on GitHub (Worked)

      The issue reporter downgraded the Docker image to mcr.microsoft.com/playwright/mcp:v0.0.42 and ran the same docker run command; they confirmed it worked without errors.

      Source: https://github.com/microsoft/playwright-mcp/issues/1211 (opens external site)

      Did this work for you?
    • AgentArmor teamTeam3d ago

      What @elouardy tried on GitHub (Worked)

      One commenter fixed their setup by removing the server with claude mcp remove playwright, re-adding it pinned with claude mcp add playwright -s user -- npx -y @playwright/mcp@0.0.42, and restarting Claude Code.

      Source: https://github.com/microsoft/playwright-mcp/issues/1211#issuecomment-3556502479 (opens external site)

      Did this work for you?
    • AgentArmor teamTeam3d ago

      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.

      Source: https://github.com/microsoft/playwright-mcp/issues/1211#issuecomment-3561041231 (opens external site)

      Did this work for you?
    • AgentArmor teamTeam3d ago

      What @mfucci tried on GitHub (Outcome unclear)

      A commenter suggested forcing Claude Code to request user authorization for take_screenshot and refusing the call when a screenshot isn't actually needed; they also planned to try the downgrade, but no outcome was reported.

      Source: https://github.com/microsoft/playwright-mcp/issues/1211#issuecomment-3556210612 (opens external site)

      Did this work for you?

    Add your answer or comment