Skip to content

feat: add webp screenshot format from upstream Playwright MCP#124

Open
JustasMonkev wants to merge 1 commit into
mainfrom
claude/kind-mendel-60pvm1
Open

feat: add webp screenshot format from upstream Playwright MCP#124
JustasMonkev wants to merge 1 commit into
mainfrom
claude/kind-mendel-60pvm1

Conversation

@JustasMonkev

@JustasMonkev JustasMonkev commented Jul 10, 2026

Copy link
Copy Markdown
Owner

Summary

Resolves #123 by mirroring upstream microsoft/playwright#41152 / commit f3114b3 (merged 2026-07-10): browser_take_screenshot now accepts type: 'webp' alongside png/jpeg.

Changes in src/tools/screenshot.ts:

  • Add 'webp' to the type enum and update the default-filename description to {png|jpeg|webp}.
  • Match upstream quality handling: quality: 90 only for jpeg; png/webp use browser defaults (upstream: quality: fileType === 'jpeg' ? 90 : undefined).
  • Compute the response image contentType as image/${fileType} so webp returns image/webp.

Plus README parameter docs and three new schema/handler tests.

Version bump — maintainer note

WebP is a new Playwright core capability, so the pin moves from 1.61.0 to 1.62.0-alpha-2026-07-10 (the first build containing #41152; latest stable 1.61.1 still types screenshots as "png"|"jpeg" and throws on webp at runtime). If you'd rather not ship a nightly pin, hold this PR until 1.62.0 stable and I/you can swap the pin — the rest of the diff is unchanged. Note npm ls shows a cosmetic invalid flag on @axe-core/playwright's playwright-core >= 1.0.0 peer range because semver prereleases don't satisfy plain ranges; install and tests are unaffected, and it disappears at 1.62.0 stable.

Why it matters

The tool surface had diverged from upstream Playwright MCP: clients could not request WebP screenshots even though upstream browser_take_screenshot now supports them.

Validation

🤖 Generated with Claude Code

https://claude.ai/code/session_01VNuK5H15LdnhueURhz1rEq


Generated by Claude Code

Summary by CodeRabbit

  • New Features

    • Added WebP support to the screenshot tool.
    • Screenshot results now report the correct image format for PNG, JPEG, and WebP files.
    • JPEG quality settings are applied only to JPEG screenshots.
  • Documentation

    • Updated screenshot tool documentation to include WebP as a supported format.

Mirror microsoft/playwright#41152 (commit f3114b3): browser_take_screenshot
now accepts type 'webp' alongside png/jpeg. Requires playwright 1.62, so
the pin moves to 1.62.0-alpha-2026-07-10 until a stable release lands.

Closes #123

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VNuK5H15LdnhueURhz1rEq
@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

WebP screenshot support

Layer / File(s) Summary
Screenshot contract and execution
src/tools/screenshot.ts, package.json, README.md
The screenshot tool accepts webp, forwards the format to Playwright, applies quality only to JPEG, returns the matching image content type, updates documentation, and bumps Playwright versions.
Screenshot format validation
tests/tools-screenshot.test.ts
Tests cover WebP forwarding, format-specific quality handling, and rejection of invalid screenshot types.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related issues

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding WebP screenshot support from upstream Playwright MCP.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/kind-mendel-60pvm1

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@package.json`:
- Around line 52-53: Align the `@playwright/test` dependency with playwright and
playwright-core by updating its version to 1.62.0-alpha-2026-07-10 in
package.json, ensuring all Playwright packages resolve to the same version.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6b6e2e38-2ebd-4fb5-850d-0c4adadd5ea2

📥 Commits

Reviewing files that changed from the base of the PR and between 51c90a7 and 5815519.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (4)
  • README.md
  • package.json
  • src/tools/screenshot.ts
  • tests/tools-screenshot.test.ts

Comment thread package.json
Comment on lines +52 to +53
"playwright": "1.62.0-alpha-2026-07-10",
"playwright-core": "1.62.0-alpha-2026-07-10",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

@playwright/test version mismatch with playwright/playwright-core.

playwright and playwright-core are bumped to 1.62.0-alpha-2026-07-10, but @playwright/test (Line 61) remains at 1.61.0. This creates a duplicate playwright-core installation in node_modules (1.61.0 via @playwright/test transitive, 1.62.0-alpha direct), which can lead to API mismatches and subtle runtime issues if both are imported in the same process.

🔧 Proposed fix
-		"`@playwright/test`": "1.61.0",
+		"`@playwright/test`": "1.62.0-alpha-2026-07-10",

Also applies to: 61-61

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@package.json` around lines 52 - 53, Align the `@playwright/test` dependency
with playwright and playwright-core by updating its version to
1.62.0-alpha-2026-07-10 in package.json, ensuring all Playwright packages
resolve to the same version.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 581551918c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread package-lock.json
Comment on lines +536 to +537
"node_modules/@playwright/test/node_modules/playwright": {
"version": "1.61.0",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Align the Playwright CLI version used by installs

This new nested 1.61.0 copy exists because @playwright/test remains at 1.61.0 while the runtime playwright/playwright-core packages were bumped to 1.62 alpha. I checked the CI workflow, and its browser install step still runs npx playwright install --with-deps chromium; after npm ci npm links the top-level playwright bin from @playwright/test, so that step uses this 1.61 CLI/browser revision while the application imports the 1.62 runtime. In environments that skip postinstall downloads or rely on the explicit install step, launches can hit Playwright's executable-version mismatch; bump @playwright/test to the same version or invoke the root playwright-core CLI.

Useful? React with 👍 / 👎.

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.

Sync browser_take_screenshot with upstream Playwright MCP: add webp output format (blocked on Playwright bump)

2 participants