[Bug] Anthropic API Error: PNG screenshots sent with incorrect image/jpeg MIME type

Status Fixed / completed
Maintainer reply None cached
Activity 11 comments · opened Nov 19, 2025 · closed Nov 19, 2025

Bug Description
When using the MCP Playwright server within the Claude Code environment (VSCode extension), a persistent invalid_request_error occurs when attempting to transmit screenshots to the Anthropic API. The issue manifests as an incorrect MIME type specification: PNG screenshots are transmitted with an image/jpeg media type declaration, which blocks all subsequent requests within the current conversation

Environment Info

  • Platform: win32
  • Terminal: vscode
  • Version: 2.0.31
  • Feedback ID: 51270c65-5715-4f04-b9dc-83c4b73dfbb4

Errors

[]

Steps to Reproduce
Step 1: Screenshot Initialization
Tool invocation:
{
"tool": "mcp_playwright_browser_take_screenshot",
"parameters": {
"fullPage": true,
"filename": "all-post-operative-control-page.png"
}
}


### Step 2: Error Manifestation
When attempting to continue the conversation, the following error occurs:

messages.7.content.17.image.source.base64.data:
Image does not match the provided media type image/jpeg


### Step 3: Issue Persistence
The error reproduces with every subsequent request within the current conversation, even without repeated calls to MCP Playwright.

---

## 4. Diagnostic Data

### 4.1. Log Fragments (Output → Claude)

2025-11-19T08:30:26.821Z [ERROR] Error streaming, falling back to non-streaming mode: 400
{
"type":"error",
"error":{
"type":"invalid_request_error",
"message":"messages.7.content.17.image.source.base64.data: Image does not match the provided media type image/jpeg"
},
"request_id":"req_011CVGwCPUBQVhbin6DfhmxU"
}

2025-11-19T08:30:27.493Z [ERROR] Error in non-streaming fallback: 400
{
"type":"error",
"error":{
"type":"invalid_request_error",
"message":"messages.7.content.17.image.source.base64.data: Image does not match the provided media type image/jpeg"
},
"request_id":"req_011CVGwCTFPUKyg9MdCjc8p1"
}

2025-11-19T08:30:27.493Z [ERROR]
"Error: Error: 400 {\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"messages.7.content.17.image.source.base64.data: Image does not match the provided media type image/jpeg\"},\"request_id\":\"req_011CVGwCTFPUKyg9MdCjc8p1\"}\n
at generate (B:/~BUN/root/claude.exe:389:20036)\n
at makeRequest (B:/~BUN/root/claude.exe:731:5434)\n
at processTicksAndRejections (native:7:39)"


### 4.2. Additional Information

2025-11-19T08:30:26.821Z [DEBUG] CLAUDE_CODE_MAX_OUTPUT_TOKENS Capped from 200000 to 64000

View original on GitHub ↗

11 Comments

github-actions[bot] · 9 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/3175
  2. https://github.com/anthropics/claude-code/issues/9938
  3. https://github.com/anthropics/claude-code/issues/988

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

YustasDev · 9 months ago

I have the same problem.

<img width="1917" height="366" alt="Image" src="https://github.com/user-attachments/assets/2ff77fae-f1a9-4ec9-bb01-0d7739f284f4" />

YustasDev · 9 months ago

How do I continue working with Claude Code further in this case?

<img width="1915" height="459" alt="Image" src="https://github.com/user-attachments/assets/a81c5fce-b7fc-4214-b40b-046c3865c41b" />

Marcin-Duszynski · 9 months ago

+1

Sceat · 9 months ago

Workaround: PreToolUse Hook to Block PNG Screenshots

The root cause is a Playwright MCP bug where PNG screenshots are incorrectly declared with image/jpeg media type, causing API rejections.

Solution: Use a PreToolUse hook to block non-JPEG screenshot requests and force Claude to use JPEG format.

Setup

  1. Create .claude/hooks/playwright-screenshot-guard.py:
#!/usr/bin/env python3
import sys, json

def main():
    input_data = json.load(sys.stdin)
    tool_name = input_data.get("tool_name", "")
    tool_input = input_data.get("tool_input", {})

    # Block non-JPEG screenshots
    if "browser_take_screenshot" in tool_name:
        screenshot_type = tool_input.get("type", "png")
        
        if screenshot_type != "jpeg":
            print("🚫 BLOCKED: Playwright screenshot must use JPEG format", file=sys.stderr)
            print("", file=sys.stderr)
            print("Playwright MCP bug: PNG screenshots fail with media type mismatch", file=sys.stderr)
            print("Solution: Set type='jpeg' in browser_take_screenshot", file=sys.stderr)
            print(f"Current: type='{screenshot_type}' ❌", file=sys.stderr)
            print("Required: type='jpeg' ✅", file=sys.stderr)
            sys.exit(2)  # Block tool execution
    
    sys.exit(0)  # Allow

if __name__ == "__main__":
    main()
  1. Make executable: chmod +x .claude/hooks/playwright-screenshot-guard.py
  1. Add to .claude/settings.json:
{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "mcp__playwright__browser_take_screenshot",
        "hooks": [
          {
            "type": "command",
            "command": ".claude/hooks/playwright-screenshot-guard.py",
            "timeout": 5000
          }
        ]
      }
    ]
  }
}

Result: Claude will be blocked from taking PNG screenshots and forced to use type='jpeg', which works correctly with the Anthropic API.

Tested and verified - no more media type mismatch errors.

angurishu · 9 months ago
## Workaround: PreToolUse Hook to Block PNG Screenshots The root cause is a Playwright MCP bug where PNG screenshots are incorrectly declared with image/jpeg media type, causing API rejections. Solution: Use a PreToolUse hook to block non-JPEG screenshot requests and force Claude to use JPEG format. ### Setup 1. Create .claude/hooks/playwright-screenshot-guard.py: #!/usr/bin/env python3 import sys, json def main(): input_data = json.load(sys.stdin) tool_name = input_data.get("tool_name", "") tool_input = input_data.get("tool_input", {}) # Block non-JPEG screenshots if "browser_take_screenshot" in tool_name: screenshot_type = tool_input.get("type", "png") if screenshot_type != "jpeg": print("🚫 BLOCKED: Playwright screenshot must use JPEG format", file=sys.stderr) print("", file=sys.stderr) print("Playwright MCP bug: PNG screenshots fail with media type mismatch", file=sys.stderr) print("Solution: Set type='jpeg' in browser_take_screenshot", file=sys.stderr) print(f"Current: type='{screenshot_type}' ❌", file=sys.stderr) print("Required: type='jpeg' ✅", file=sys.stderr) sys.exit(2) # Block tool execution sys.exit(0) # Allow if __name__ == "__main__": main() 2. Make executable: chmod +x .claude/hooks/playwright-screenshot-guard.py 3. Add to .claude/settings.json: { "hooks": { "PreToolUse": [ { "matcher": "mcp__playwright__browser_take_screenshot", "hooks": [ { "type": "command", "command": ".claude/hooks/playwright-screenshot-guard.py", "timeout": 5000 } ] } ] } } Result: Claude will be blocked from taking PNG screenshots and forced to use type='jpeg', which works correctly with the Anthropic API. Tested and verified - no more media type mismatch errors.

just wanted to say thank you for this

szwang · 9 months ago

This should be fixed in version 2.0.46. So sorry for the friction, and thank you for reporting!

xpluscal · 9 months ago

Doesn't seem to be fixed, still occurring in 2.0.47

GraysonCAdams · 9 months ago

Not fixed.

Can confirm, still seeing this on 2.0.47.

Downgrading my VS Code extension to 2.0.36 doesn't work per guidance, I then get:

 API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"`clear_thinking_20251015` strategy requires `thinking` to be 
    enabled"},"request_id":"req_011CV9w7LXQaGqmgogERWisW"}

Just resolved to telling Claude to tell me when to take screenshots and then I paste them into VS Code for it. Annoying but I am hoping this gets patched soon.

SongKimTB · 9 months ago

another user suggested downgrading the cli to 2.0.30 https://github.com/anthropics/claude-code/issues/11975#issuecomment-3555784241

i tried that and im not getting that error anymore.

github-actions[bot] · 9 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.