Auto-install Playwright Chromium for MCP tools#2942
Open
glendaviesnz wants to merge 6 commits intotrunkfrom
Open
Auto-install Playwright Chromium for MCP tools#2942glendaviesnz wants to merge 6 commits intotrunkfrom
glendaviesnz wants to merge 6 commits intotrunkfrom
Conversation
Author
|
I am still doing some testing on this, so leaving as draft. Came from trying to get a Codex plugin working with Studio MCP |
361bcba to
9bdb608
Compare
Collaborator
📊 Performance Test ResultsComparing 4f65c83 vs trunk app-size
site-editor
site-startup
Results are median values from multiple test runs. Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes: https://linear.app/a8c/issue/STU-1531/make-playwright-browser-dependency-install-more-robust
Summary
I struck a problem with an external MCP client (Codex) could not get the take_screenshot tool to work as it got stuck in a missing chromium loop - I found it very hard to reproduce though, but this PR makes changes to:
Problem
The
take_screenshotandvalidate_blocksMCP tools run inside the Studio CLI MCP server and depend on the shared Playwright browser launcher.When Studio MCP is available but Playwright's managed Chromium browser is missing, those tools can fail even though the site itself is healthy. This is especially relevant for MCP consumers because the screenshot and validation tools need a working browser runtime inside Studio, not just in the calling agent.
What changed
This update adds a repair-first flow for Studio MCP browser startup:
STUDIO_MCP_BROWSER_EXECUTABLE_PATHorSTUDIO_MCP_BROWSER_CHANNEL, Studio respects that configurationplaywright install chromiumfrom the CLI runtime before launching the shared browserThis keeps the default MCP path aligned with a Studio-managed Playwright browser while preserving explicit overrides for locked-down or unusual environments.
Why this approach
This makes the MCP screenshot and validation tools more reliable because it:
Test instructions
Automated
npx vitest run apps/cli/ai/tests/browser-utils.test.ts --config apps/cli/vitest.config.tsnpx tsc -p apps/cli/tsconfig.json --noEmitManual
take_screenshotorvalidate_blockswithout any browser override env vars set.STUDIO_MCP_BROWSER_CHANNEL=chromeorSTUDIO_MCP_BROWSER_EXECUTABLE_PATH=...set and confirm Studio skips the auto-install path and uses the configured override.If you don't have an MCP client handy, you can still smoke test the install path from the repo root:
npm run cli:build.node --input-type=module./tmp/studio-empty-playwright, and the browser launches successfully from that managed path.