Skip to content

Conversation

@Coquinate
Copy link
Contributor

Summary

This PR adds support for the quality parameter when taking JPEG screenshots, allowing users to control compression levels and significantly reduce file sizes.

Problem

Currently, the Chrome DevTools MCP doesn't expose the quality parameter that Puppeteer natively supports. This leads to:

  • Large screenshot file sizes (especially problematic for AI assistants with image size limits)
  • No control over JPEG compression
  • Inability to optimize screenshots for different use cases

Solution

Added the quality parameter (0-100) to the screenshot tool schema and passed it through to Puppeteer's screenshot method.

Changes

  • ✅ Added quality parameter to screenshot schema with proper validation (0-100 range)
  • ✅ Pass quality parameter to Puppeteer's screenshot() method
  • ✅ Added optimizeForSpeed flag for improved encoding performance
  • ✅ Updated documentation via npm run docs

Testing

Tested locally with various quality settings:

  • PNG (baseline): 128 KB
  • JPEG quality 100: 245 KB
  • JPEG quality 50: 84 KB (35% reduction)
  • JPEG quality 30: 66 KB (49% reduction)

Impact

This change is backward compatible - the quality parameter is optional and doesn't affect existing usage. It particularly helps with:

  • AI assistants that have image size limits (e.g., 8000px max dimension errors)
  • Reducing bandwidth when capturing many screenshots
  • Optimizing storage for screenshot-heavy workflows

Example Usage

// New capability - control JPEG quality
await take_screenshot({
  format: 'jpeg',
  quality: 50,  // New parameter!
  fullPage: false
})

Checklist

  • Code follows conventional commits
  • Documentation updated with npm run docs
  • Tested locally
  • Backward compatible
  • CLA signed (will complete if needed)

Fixes #[issue-number] (if applicable)

@google-cla
Copy link

google-cla bot commented Sep 27, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@OrKoN OrKoN self-requested a review September 29, 2025 12:59
@OrKoN OrKoN force-pushed the feat/add-jpeg-quality-parameter branch from baf0b58 to 5dc7b5a Compare September 29, 2025 13:10
@OrKoN OrKoN enabled auto-merge (squash) September 29, 2025 13:10
@OrKoN OrKoN force-pushed the feat/add-jpeg-quality-parameter branch from 5dc7b5a to ba1e3ba Compare September 29, 2025 13:51
- Add optional quality parameter (0-100) to screenshot schema
- Pass quality parameter to Puppeteer screenshot method
- Add optimizeForSpeed flag for improved performance
- Update documentation with new parameter details

This allows users to control JPEG compression quality, significantly
reducing file sizes for screenshots. For example, quality=50 can reduce
file size by ~35% compared to PNG format.

Fixes potential issues with large screenshot sizes exceeding API limits
when using Chrome DevTools MCP with AI assistants.
@OrKoN OrKoN force-pushed the feat/add-jpeg-quality-parameter branch from ba1e3ba to f7ef840 Compare September 29, 2025 13:54
@OrKoN OrKoN merged commit 139cfd1 into ChromeDevTools:main Sep 29, 2025
16 checks passed
OrKoN pushed a commit that referenced this pull request Sep 29, 2025
🤖 I have created a release *beep* *boop*
---


##
[0.5.0](chrome-devtools-mcp-v0.4.0...chrome-devtools-mcp-v0.5.0)
(2025-09-29)


### Features

* **screenshot:** add JPEG quality parameter support
([#184](#184))
([139cfd1](139cfd1))


### Bug Fixes

* do not error if the dialog was already handled
([#208](#208))
([d9f77f8](d9f77f8))
* reference to handle_dialog tool
([#209](#209))
([205eef5](205eef5))
* support node20
([#52](#52))
([13613b4](13613b4))
* update tool reference in an error
([#205](#205))
([7765bb3](7765bb3))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants