Skip to content

--screenshotMaxWidth returns images at twice the bound on a HiDPI display #2531

Description

@thomasbachem

Description of the bug

--screenshotMaxWidth caps the image before the device scale factor is applied, so on a 2x display the returned screenshot is twice the requested width. Asking for 800 gives back 1600, four times the area.

That matters most where the flag came from: #1823 added it to keep screenshots under the 8000 pixel limit behind #879, and a cap picked to stay under that would still exceed it by the same factor.

The overshoot is also what gets billed. Anthropic prices an image at ceil(width/28) * ceil(height/28) visual tokens, so the 800x433 the flag should return costs 464 and the 1600x865 it does return costs 1798 – 3.9x on every capture, and still over 3x on a model whose long edge cap downscales the wider one.

Reproduction

Start Chrome with a given scale factor and connect to it:

"Google Chrome for Testing" --remote-debugging-port=9333 --headless=new \
  --window-size=1400,900 --force-device-scale-factor=2 https://example.com/

npx chrome-devtools-mcp@1.7.0 --browserUrl http://localhost:9333 --screenshotMaxWidth 800

Then call take_screenshot and read the PNG header. The bound holds exactly at a scale factor of 1 and is out by the factor above it:

DPR 1    no bound 1400x757     --screenshotMaxWidth 800 ->   800x433
DPR 2    no bound 2800x1514    --screenshotMaxWidth 800 ->  1600x865

Expectation

An image no wider than the requested maximum, since the flag is there to bound what reaches the model.

MCP configuration

{
  "mcpServers": {
    "chrome-devtools": {
      "command": "npx",
      "args": ["-y", "chrome-devtools-mcp@1.7.0", "--browserUrl", "http://localhost:9333", "--screenshotMaxWidth", "800"]
    }
  }
}

Chrome DevTools MCP version

1.7.0

Chrome version

151.0.7922.71 (Chrome for Testing)

Coding agent version

Claude Code 2.1.92

Model version

Claude Opus 5

Node version

v24.19.0

Operating system

macOS 26.5.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions