Commit 139cfd1
feat(screenshot): add JPEG quality parameter support (#184)
## 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
```javascript
// New capability - control JPEG quality
await take_screenshot({
format: 'jpeg',
quality: 50, // New parameter!
fullPage: false
})
```
## Checklist
- [x] Code follows conventional commits
- [x] Documentation updated with `npm run docs`
- [x] Tested locally
- [x] Backward compatible
- [ ] CLA signed (will complete if needed)
Fixes #[issue-number] (if applicable)
Co-authored-by: aberemia24 <[email protected]>1 parent d9f77f8 commit 139cfd1
2 files changed
+11
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
308 | 308 | | |
309 | 309 | | |
310 | 310 | | |
| 311 | + | |
311 | 312 | | |
312 | 313 | | |
313 | 314 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
25 | 33 | | |
26 | 34 | | |
27 | 35 | | |
| |||
50 | 58 | | |
51 | 59 | | |
52 | 60 | | |
| 61 | + | |
| 62 | + | |
53 | 63 | | |
54 | 64 | | |
55 | 65 | | |
| |||
0 commit comments