Skip to content

[Feature]: MCP: open new tabs in the background (don't raise the browser) with --cdp-endpoint #44140

Open

Description

🚀 Feature Request

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_tabs new (for example background: true), a server flag (for example --background-tabs), or both.

Example

{ "name": "browser_tabs", "arguments": { "action": "new", "url": "https://example.com", "background": true } }

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_tabs new 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.

Activity

  1. microsoft-playwright-automation commented on Nov 16, 2026

    @microsoft-playwright-automation
  2. microsoft-playwright-automation commented on Nov 16, 2026

    @microsoft-playwright-automation
    Contributor

    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.

    Source findings

    Checked 1.66.0-next, commit 826ce42b8664ea940424e77ce51f1cdf96dcd37f:

    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

  3. cristina-caescu-btrl commented on Nov 17, 2026

    @cristina-caescu-btrl

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions