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
{{ message }}
Repository navigation
[Feature]: MCP: open new tabs in the background (don't raise the browser) with --cdp-endpoint #44140
Let MCP tools open new tabs in the background when Playwright MCP is attached to an existing browser with --cdp-endpoint: an option on browser_tabsnew (for example background: true), a server flag (for example --background-tabs), or both.
or npx @playwright/mcp --cdp-endpoint http://127.0.0.1:9223 --background-tabs.
Motivation
I run Playwright MCP against a long-lived Chrome on my own Mac (--cdp-endpoint), so agents can use my sign-ins. That Chrome shares the screen I work on. Every browser_tabsnew raises Chrome and, on macOS, can move me to the Space where Chrome's window is, several times per agent task. That makes the setup unusable while I'm working, so for now I've switched to chrome-devtools-mcp, whose new_page accepts background: true.
Chrome already supports this: Target.createTarget has a background parameter. On current main the tab is created in CRBrowserContext.doCreateNewPage() (packages/playwright-core/src/server/chromium/crBrowser.ts) as Target.createTarget({ url: 'about:blank', browserContextId }), with no way to pass background, and browser_tabs (packages/playwright-core/src/tools/backend/tabs.ts) only calls context.newTab(). Pages in a background tab may need focus emulation so sites behave as if focused; chrome-devtools-mcp does this with emulateFocus.
Versions: @playwright/mcp 0.0.85, Chrome 159 (Beta) on macOS.
I'd be happy to work on this and send a PR if the approach is acceptable. Please let me know which shape you prefer: a per-call option, a server flag, or both.
Hi, I'm the Playwright bot and I checked the tab-creation and focus code.
Background tab creation is not supported with --cdp-endpoint on current main. There is already a --background flag, but it applies only to --extension; it does not affect direct CDP connections.
This needs a library API decision, not just another browser_tabs argument: BrowserContext.newPage() has no background-creation option. Focus handling also matters: MCP deliberately connects with noDefaults: true, which disables focus emulation, and browser_tabs selection calls bringToFront(). Changing tab creation alone would not give the same background behavior as the existing extension flag.
I also checked chrome-devtools-mcp's implementation: it passes background to page creation, enables focus emulation on that page, and makes it the MCP-selected page.
These are source findings, not a reproduction of macOS window activation or Space switching. No runtime tests were run.
My recommendation is to reuse --background for CDP rather than add a second server flag. No patch is proposed in this run because the missing piece is a supported library contract for background page creation and controlled-page focus, while preserving the user's other browser settings.
Triaged on macOS by the Playwright bot - agent run
Activity
microsoft-playwright-automation commentedon Nov 16, 2026
microsoft-playwright-automation commentedon Nov 16, 2026
Hi, I'm the Playwright bot and I checked the tab-creation and focus code.
Background tab creation is not supported with
--cdp-endpointon current main. There is already a--backgroundflag, but it applies only to--extension; it does not affect direct CDP connections.This needs a library API decision, not just another
browser_tabsargument:BrowserContext.newPage()has no background-creation option. Focus handling also matters: MCP deliberately connects withnoDefaults: true, which disables focus emulation, andbrowser_tabsselection callsbringToFront(). Changing tab creation alone would not give the same background behavior as the existing extension flag.Source findings
Checked
1.66.0-next, commit826ce42b8664ea940424e77ce51f1cdf96dcd37f:browser_tabscallscontext.newTab(), which usesBrowserContext.newPage().background. The CDP definition does support that parameter.noDefaults. The related focus-emulation report is [MCP]: --extension --background: noDefaults skips focus emulation, hidden tabs get no rAF and clicks time out #44096; it is separate from adding background creation over CDP.backgroundto page creation, enables focus emulation on that page, and makes it the MCP-selected page.These are source findings, not a reproduction of macOS window activation or Space switching. No runtime tests were run.
My recommendation is to reuse
--backgroundfor CDP rather than add a second server flag. No patch is proposed in this run because the missing piece is a supported library contract for background page creation and controlled-page focus, while preserving the user's other browser settings.Triaged on macOS by the Playwright bot - agent run
cristina-caescu-btrl commentedon Nov 17, 2026
New impact here: This issue is making our tests related to open new tab to fail. We assert elements from new tab, but right now we assert blank page.