You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
verify Playwright Chromium is available before Studio MCP launches the shared browser
auto-install Playwright Chromium when the managed browser is missing
keep explicit executable and channel overrides for environments that need a custom browser path
add focused tests for install and override behavior
Problem
The take_screenshot and validate_blocks MCP 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:
if the user has explicitly configured STUDIO_MCP_BROWSER_EXECUTABLE_PATH or STUDIO_MCP_BROWSER_CHANNEL, Studio respects that configuration
otherwise, Studio checks whether Playwright's managed Chromium executable exists
if it is missing, Studio runs playwright install chromium from the CLI runtime before launching the shared browser
after the install attempt, Studio continues with the existing browser launch candidates and returns clearer guidance if launch still fails
This 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:
addresses the missing-browser case directly
keeps behavior more reproducible across machines
preserves an explicit override path when users need to point Studio at a different browser
gives clearer diagnostics when repair is not possible
Test instructions
Automated
npx vitest run apps/cli/ai/tests/browser-utils.test.ts --config apps/cli/vitest.config.ts
npx tsc -p apps/cli/tsconfig.json --noEmit
Manual
Start from a Studio environment where the Playwright Chromium cache is missing.
Run the Studio MCP server and invoke take_screenshot or validate_blocks without any browser override env vars set.
Confirm Studio attempts to install Playwright Chromium and then proceeds with the MCP tool.
Repeat with STUDIO_MCP_BROWSER_CHANNEL=chrome or STUDIO_MCP_BROWSER_EXECUTABLE_PATH=... set and confirm Studio skips the auto-install path and uses the configured override.
Simulate a failed install or offline environment and confirm the MCP error explains that auto-install failed and points the user at the override options.
If you don't have an MCP client handy, you can still smoke test the install path from the repo root:
Run npm run cli:build.
Run node --input-type=module.
Paste the script below into the REPL.
Confirm the first check shows the Playwright-managed executable is missing, the install step downloads Chromium into /tmp/studio-empty-playwright, and the browser launches successfully from that managed path.
I like the goal here, but this PR feels broader than a pure reliability fix. The valuable part is making studio mcp recover when Playwright Chromium is missing and improving the failure guidance. The extra browser path probing, multiple env var aliases, and channel-based overrides add quite a bit of cross-platform complexity, and at least some of that complexity is already affecting control flow in non-obvious ways. Unless there’s concrete evidence that users need all of those override paths, I’d prefer to narrow this to the minimal reliability fix: ensure Playwright Chromium is available, then launch it, with one explicit Studio-owned escape hatch if needed.
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
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.