fix(mcp): resolve browser version mismatch path reporting and environ…#41943
Open
Vrindakr3300 wants to merge 1 commit into
Open
fix(mcp): resolve browser version mismatch path reporting and environ…#41943Vrindakr3300 wants to merge 1 commit into
Vrindakr3300 wants to merge 1 commit into
Conversation
…ment sandbox stripping
Author
|
@microsoft-github-policy-service agree |
dcrousso
requested changes
Jul 23, 2026
| } = options; | ||
|
|
||
| const env = options.env ? envArrayToObject(options.env) : process.env; | ||
| const env = options.env ? { ...process.env, ...envArrayToObject(options.env) } : process.env; |
Contributor
There was a problem hiding this comment.
this conflicts with existing documented behavior
the whole idea of options.env is to be able to replace the default process.env
also, i dont think options.env is set by MCP so it should already be using process.env
| throw new Error(`${label} is not installed. Run \`playwright-cli install-browser ${target}\` to install`); | ||
| throw new Error(`${label} is not installed. Run \`npx @playwright/mcp install-browser ${target}\` to install`); | ||
| throw new Error(`${label} is not installed. Run \`playwright-cli install-browser ${target}\` to install${suffix}`); | ||
| throw new Error(`${label} is not installed. Run \`npx @playwright/mcp install-browser ${target}\` to install${suffix}`); |
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.
Summary
This PR addresses two compounding issues affecting the Playwright MCP server when integrating with sandboxed hosts (such as LM Studio):
playwright-core's original error message (which includes the specific versioned directory path, e.g.firefox-1534\firefox.exe) and rethrew a generic"Browser is not installed"error, dropping the path. This made version mismatches very difficult to diagnose. We now append the original error message to the rethrown error.process.envwas completely replaced ifoptions.envwas defined. Under Electron sandbox environments like LM Studio, this resulted in crucial environment variables (likePLAYWRIGHT_BROWSERS_PATHand systemPATHparameters) being stripped. We now mergeprocess.envwith the customoptions.envwhen spawning the browser process.Changes
packages/playwright-core/src/tools/mcp/browserFactory.ts: ModifiedthrowIfExecutableMissingto append the originalerror.messageto the thrown error message.packages/playwright-core/src/server/browserType.ts: Mergesprocess.envwith the customoptions.envwhen launching browser processes.tests/mcp/launch.spec.ts: Addedmissing browser path in error messagetest case to assert that both the installation instructions and the exact missing path are reported, skipping system channels likechromeandmsedge.Closes #41871