Skip to content

MCP screenshot returns images exceeding API max dimension limit (2000px) #884

@f-trycua

Description

@f-trycua

Description

When using the CUA MCP server's computer_screenshot tool with Claude's API, screenshots are being returned with dimensions that exceed the API's maximum allowed size for many-image requests (2000 pixels).

Error Message

API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.23.content.19.image.source.base64.data: At least one of the image dimensions exceed max allowed size for many-image requests: 2000 pixels"},"request_id":"req_011CXLuG7Z49CpQtVZU2jfKe"}

Context

  • The error occurs when calling computer_screenshot from the MCP server
  • The API has a limit of 2000 pixels for image dimensions in many-image requests
  • The screenshot is being returned at its native resolution without resizing

Expected Behavior

Screenshots should be automatically resized/scaled to ensure they don't exceed the 2000 pixel limit on any dimension before being returned to the API.

Suggested Solution

The MCP server's screenshot functionality should:

  1. Check the dimensions of the captured screenshot
  2. If either dimension exceeds 2000 pixels, scale the image down proportionally
  3. Return the resized image that fits within the API limits

This is similar to the recent fix for 1MB file size compression (commit d9204b8), but for image dimensions instead of file size.

Environment

  • CUA MCP Server
  • Claude API

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions