Skip to content

fix(mcp): ignore browser config when attaching to extension#40475

Merged
yury-s merged 5 commits intomicrosoft:mainfrom
yury-s:mcp-extension-ignore-config
Apr 29, 2026
Merged

fix(mcp): ignore browser config when attaching to extension#40475
yury-s merged 5 commits intomicrosoft:mainfrom
yury-s:mcp-extension-ignore-config

Conversation

@yury-s
Copy link
Copy Markdown
Member

@yury-s yury-s commented Apr 28, 2026

Summary

  • In extension mode, the browser section of the loaded config file is now ignored (both userDataDir and executablePath) — only the browser/channel from the CLI flag or PLAYWRIGHT_MCP_BROWSER env applies, matching the documented intent of the extension config option.
  • User data dir is always defaultUserDataDirForChannel(channel); tests can override via the new PWTEST_EXTENSION_USER_DATA_DIR env var.
  • createExtensionBrowser no longer takes FullConfig — it just receives the resolved channel. New resolveChannelForExtension helper extracted in config.ts, with resolveBrowserParam factored out of configFromCLIOptions for reuse.
  • Removed the custom executablePath extension test since that path is no longer wired through.

Comment thread packages/playwright-core/src/tools/mcp/browserFactory.ts Outdated
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

yury-s added 5 commits April 29, 2026 10:24
Extension mode only takes channel/browser name from CLI/env; user data
dir is always the browser default. Tests can override the user data dir
via the PWTEST_EXTENSION_USER_DATA_DIR env var.
The extension code path no longer reads userDataDir/executablePath/
launchOptions from config; only channel is read, and channel is
effectively the browser name, which is fine to source from the config
file too.
LocalBrowserConfig / CDPBrowserConfig / RemoteBrowserConfig /
ExtensionBrowserConfig (each tagged with `mode`). Extension drops
launchOptions/contextOptions/userDataDir, has `isolated: false` literal
and `browserName: 'chromium'` literal so call sites can use plain
`config.browser.isolated` / `config.browser.browserName` and TS narrows
extension correctly. createBrowserWithInfo splits into
createAttachedBrowser (no FullConfig needed) and
createLocalBrowserWithInfo. Adds `acquireBrowserContext` helper to
dedupe newContext-vs-contexts[0] across three call sites.
@yury-s yury-s force-pushed the mcp-extension-ignore-config branch from d80df29 to 76ae9ac Compare April 29, 2026 17:47
@yury-s yury-s merged commit 5ec1b3f into microsoft:main Apr 29, 2026
4 of 17 checks passed
@yury-s yury-s deleted the mcp-extension-ignore-config branch April 29, 2026 18:00
@github-actions
Copy link
Copy Markdown
Contributor

Test results for "MCP"

83 failed
❌ [chrome] › mcp/config-resolve.spec.ts:69 › browserName and channel › config file browserName chromium does not auto-set channel @mcp-macos-latest-chrome
❌ [chrome] › mcp/config-resolve.spec.ts:77 › browserName and channel › config file browserName firefox does not set channel @mcp-macos-latest-chrome
❌ [chrome] › mcp/config-resolve.spec.ts:85 › browserName and channel › config file browserName + channel are both preserved @mcp-macos-latest-chrome
❌ [chrome] › mcp/config-resolve.spec.ts:220 › merge order › env overrides config file @mcp-macos-latest-chrome
❌ [chrome] › mcp/config.spec.ts:88 › browserName @mcp-macos-latest-chrome
❌ [chrome] › mcp/config-resolve.spec.ts:69 › browserName and channel › config file browserName chromium does not auto-set channel @mcp-ubuntu-latest-chrome
❌ [chrome] › mcp/config-resolve.spec.ts:77 › browserName and channel › config file browserName firefox does not set channel @mcp-ubuntu-latest-chrome
❌ [chrome] › mcp/config-resolve.spec.ts:85 › browserName and channel › config file browserName + channel are both preserved @mcp-ubuntu-latest-chrome
❌ [chrome] › mcp/config-resolve.spec.ts:220 › merge order › env overrides config file @mcp-ubuntu-latest-chrome
❌ [chrome] › mcp/config.spec.ts:88 › browserName @mcp-ubuntu-latest-chrome
❌ [chrome] › mcp/config-resolve.spec.ts:69 › browserName and channel › config file browserName chromium does not auto-set channel @mcp-windows-latest-chrome
❌ [chrome] › mcp/config-resolve.spec.ts:77 › browserName and channel › config file browserName firefox does not set channel @mcp-windows-latest-chrome
❌ [chrome] › mcp/config-resolve.spec.ts:85 › browserName and channel › config file browserName + channel are both preserved @mcp-windows-latest-chrome
❌ [chrome] › mcp/config-resolve.spec.ts:220 › merge order › env overrides config file @mcp-windows-latest-chrome
❌ [chrome] › mcp/config.spec.ts:88 › browserName @mcp-windows-latest-chrome
❌ [chromium] › mcp/cli-isolated.spec.ts:21 › should not save user data by default (in-memory mode) @mcp-macos-latest-chromium
❌ [chromium] › mcp/cli-isolated.spec.ts:45 › should save user data with --persistent flag @mcp-macos-latest-chromium
❌ [chromium] › mcp/cli-json.spec.ts:84 › list after open returns one browser entry @mcp-macos-latest-chromium
❌ [chromium] › mcp/cli-session.spec.ts:86 › delete-data @mcp-macos-latest-chromium
❌ [chromium] › mcp/cli-session.spec.ts:98 › delete-data named session @mcp-macos-latest-chromium
❌ [chromium] › mcp/config.spec.ts:88 › browserName @mcp-macos-latest-chromium
❌ [chromium] › mcp/cli-isolated.spec.ts:21 › should not save user data by default (in-memory mode) @mcp-windows-latest-chromium
❌ [chromium] › mcp/cli-isolated.spec.ts:45 › should save user data with --persistent flag @mcp-windows-latest-chromium
❌ [chromium] › mcp/cli-json.spec.ts:84 › list after open returns one browser entry @mcp-windows-latest-chromium
❌ [chromium] › mcp/cli-session.spec.ts:86 › delete-data @mcp-windows-latest-chromium
❌ [chromium] › mcp/cli-session.spec.ts:98 › delete-data named session @mcp-windows-latest-chromium
❌ [chromium] › mcp/config.spec.ts:88 › browserName @mcp-windows-latest-chromium
❌ [chromium] › mcp/dashboard.spec.ts:185 › should start dashboard and annotate when no dashboard is running @mcp-windows-latest-chromium
❌ [chromium] › mcp/dashboard.spec.ts:207 › should enter annotate mode on fresh dashboard.tsx mount with -s --annotate @mcp-windows-latest-chromium
❌ [chromium] › mcp/dashboard.spec.ts:231 › should switch screencast to -s session on show --annotate @mcp-windows-latest-chromium
❌ [chromium] › mcp/cli-isolated.spec.ts:21 › should not save user data by default (in-memory mode) @mcp-ubuntu-latest-chromium
❌ [chromium] › mcp/cli-isolated.spec.ts:45 › should save user data with --persistent flag @mcp-ubuntu-latest-chromium
❌ [chromium] › mcp/cli-json.spec.ts:84 › list after open returns one browser entry @mcp-ubuntu-latest-chromium
❌ [chromium] › mcp/cli-session.spec.ts:86 › delete-data @mcp-ubuntu-latest-chromium
❌ [chromium] › mcp/cli-session.spec.ts:98 › delete-data named session @mcp-ubuntu-latest-chromium
❌ [chromium] › mcp/config.spec.ts:88 › browserName @mcp-ubuntu-latest-chromium
❌ [firefox] › mcp/cli-isolated.spec.ts:21 › should not save user data by default (in-memory mode) @mcp-ubuntu-latest-firefox
❌ [firefox] › mcp/cli-isolated.spec.ts:45 › should save user data with --persistent flag @mcp-ubuntu-latest-firefox
❌ [firefox] › mcp/cli-json.spec.ts:84 › list after open returns one browser entry @mcp-ubuntu-latest-firefox
❌ [firefox] › mcp/cli-session.spec.ts:86 › delete-data @mcp-ubuntu-latest-firefox
❌ [firefox] › mcp/cli-session.spec.ts:98 › delete-data named session @mcp-ubuntu-latest-firefox
❌ [firefox] › mcp/config.spec.ts:88 › browserName @mcp-ubuntu-latest-firefox
❌ [firefox] › mcp/cli-isolated.spec.ts:21 › should not save user data by default (in-memory mode) @mcp-windows-latest-firefox
❌ [firefox] › mcp/cli-isolated.spec.ts:45 › should save user data with --persistent flag @mcp-windows-latest-firefox
❌ [firefox] › mcp/cli-json.spec.ts:84 › list after open returns one browser entry @mcp-windows-latest-firefox
❌ [firefox] › mcp/cli-session.spec.ts:86 › delete-data @mcp-windows-latest-firefox
❌ [firefox] › mcp/cli-session.spec.ts:98 › delete-data named session @mcp-windows-latest-firefox
❌ [firefox] › mcp/config.spec.ts:88 › browserName @mcp-windows-latest-firefox
❌ [firefox] › mcp/cli-isolated.spec.ts:21 › should not save user data by default (in-memory mode) @mcp-macos-latest-firefox
❌ [firefox] › mcp/cli-isolated.spec.ts:45 › should save user data with --persistent flag @mcp-macos-latest-firefox
❌ [firefox] › mcp/cli-json.spec.ts:84 › list after open returns one browser entry @mcp-macos-latest-firefox
❌ [firefox] › mcp/cli-session.spec.ts:86 › delete-data @mcp-macos-latest-firefox
❌ [firefox] › mcp/cli-session.spec.ts:98 › delete-data named session @mcp-macos-latest-firefox
❌ [firefox] › mcp/config.spec.ts:88 › browserName @mcp-macos-latest-firefox
❌ [msedge] › mcp/cli-isolated.spec.ts:21 › should not save user data by default (in-memory mode) @mcp-windows-latest-msedge
❌ [msedge] › mcp/cli-isolated.spec.ts:45 › should save user data with --persistent flag @mcp-windows-latest-msedge
❌ [msedge] › mcp/cli-json.spec.ts:84 › list after open returns one browser entry @mcp-windows-latest-msedge
❌ [msedge] › mcp/cli-session.spec.ts:86 › delete-data @mcp-windows-latest-msedge
❌ [msedge] › mcp/cli-session.spec.ts:98 › delete-data named session @mcp-windows-latest-msedge
❌ [msedge] › mcp/config.spec.ts:88 › browserName @mcp-windows-latest-msedge
❌ [msedge] › mcp/network.spec.ts:90 › browser_network_requests numbers requests with stable indexes @mcp-windows-latest-msedge
❌ [webkit] › mcp/cli-core.spec.ts:114 › check @mcp-macos-latest-webkit
❌ [webkit] › mcp/cli-core.spec.ts:123 › uncheck @mcp-macos-latest-webkit
❌ [webkit] › mcp/cli-isolated.spec.ts:21 › should not save user data by default (in-memory mode) @mcp-macos-latest-webkit
❌ [webkit] › mcp/cli-isolated.spec.ts:45 › should save user data with --persistent flag @mcp-macos-latest-webkit
❌ [webkit] › mcp/cli-json.spec.ts:84 › list after open returns one browser entry @mcp-macos-latest-webkit
❌ [webkit] › mcp/cli-session.spec.ts:86 › delete-data @mcp-macos-latest-webkit
❌ [webkit] › mcp/cli-session.spec.ts:98 › delete-data named session @mcp-macos-latest-webkit
❌ [webkit] › mcp/config.spec.ts:88 › browserName @mcp-macos-latest-webkit
❌ [webkit] › mcp/cli-core.spec.ts:114 › check @mcp-windows-latest-webkit
❌ [webkit] › mcp/cli-core.spec.ts:123 › uncheck @mcp-windows-latest-webkit
❌ [webkit] › mcp/cli-isolated.spec.ts:21 › should not save user data by default (in-memory mode) @mcp-windows-latest-webkit
❌ [webkit] › mcp/cli-isolated.spec.ts:45 › should save user data with --persistent flag @mcp-windows-latest-webkit
❌ [webkit] › mcp/cli-json.spec.ts:84 › list after open returns one browser entry @mcp-windows-latest-webkit
❌ [webkit] › mcp/cli-session.spec.ts:86 › delete-data @mcp-windows-latest-webkit
❌ [webkit] › mcp/cli-session.spec.ts:98 › delete-data named session @mcp-windows-latest-webkit
❌ [webkit] › mcp/config.spec.ts:88 › browserName @mcp-windows-latest-webkit
❌ [webkit] › mcp/cli-isolated.spec.ts:21 › should not save user data by default (in-memory mode) @mcp-ubuntu-latest-webkit
❌ [webkit] › mcp/cli-isolated.spec.ts:45 › should save user data with --persistent flag @mcp-ubuntu-latest-webkit
❌ [webkit] › mcp/cli-json.spec.ts:84 › list after open returns one browser entry @mcp-ubuntu-latest-webkit
❌ [webkit] › mcp/cli-session.spec.ts:86 › delete-data @mcp-ubuntu-latest-webkit
❌ [webkit] › mcp/cli-session.spec.ts:98 › delete-data named session @mcp-ubuntu-latest-webkit
❌ [webkit] › mcp/config.spec.ts:88 › browserName @mcp-ubuntu-latest-webkit

6738 passed, 927 skipped


Merge workflow run.

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.

2 participants