Skip to content

[MCP]: --extension background mode: let several agents use the logged-in browser without taking the screen #42973

Closed

Description

What's going on?

We run several coding agents (Claude Code, Codex, Cursor) against --extension on macOS so they can use the browser the person is already logged into. Opening this as an issue since Discussions aren't enabled here. With more than one agent at a time, the extension's connect flow gets in the way of the person using the machine:

  1. On connect the extension activates the chosen tab and focuses its window (chrome.tabs.update({active: true}) and chrome.windows.update({focused: true}) in _connectTab), and Page.bringToFront / Target.activateTarget do the same mid-task. Chrome comes to the front and can switch the macOS Space while the person is typing in another app.
  2. Agent tabs live in the person's own windows. Only the active tab of a window gets animation frames and trusted input, so an agent tab behind the one they are looking at can't be driven reliably, and the one they are looking at gets navigated under them.
  3. Each client gets a tab group, and Chrome keeps closed group records, so the tab-group menu grows with every agent task.
  4. The pairing token ends up in every agent's MCP config through PLAYWRIGHT_MCP_EXTENSION_TOKEN.

We worked around all four in a fork of the extension at d5a185a (the multi-client commit) and have used it daily since. What worked:

  • Each client gets a background tab (chrome.tabs.create({active: false})) inside a small pool of dedicated, never-focused normal windows, up to 16 tabs per window. A per-window scheduler activates one client's tab at a time with chrome.tabs.update({active: true}), only while that client has a command in flight. That call changes the tab strip only; it never focuses the window.
  • Page.bringToFront and Target.activateTarget are no-ops for these clients. No tab groups: exact tab IDs give each client ownership and cleanup.
  • The windows are never minimized (a minimized window gets no animation frames and no trusted input), and on macOS Chrome runs with --disable-backgrounding-occluded-windows so covered windows keep rendering.
  • The MCP server reaches the extension through a native messaging host, so no agent config holds the token.

On Chrome 154 and macOS this ran 24 simultaneous clients across four windows with trusted clicks and typing, no focus or Space change, and exact cleanup on browser_close.

Would you be open to a background option for --extension along these lines? Even the first piece would remove most of the pain: an option that skips activating and focusing on connect and makes bringToFront a no-op, and a mode where the extension creates the client's tab in a window it owns instead of asking the person to pick one. Happy to split this into smaller issues or send PRs for whatever fits your plans.

The fork, with design notes and the list of Chrome behaviors we ran into along the way: https://github.com/ZipLyne-Agency/agent-lanes (see docs/why.md and extension/UPSTREAM.md).

Version

@playwright/mcp 0.0.79; extension forked from d5a185a (0.3.0). The current upstream extension (0.4.0) still activates and focuses on connect and groups tabs per client.

Activity

  1. Hronom commented on Sep 29, 2026

    @Hronom

    One acceptance case I'd add for the upstream per-window scheduler: hold client A in a long-running command, queue a mutating command from B, then disconnect B before it gets the active-tab slot.

    Assert that B's queued mutation is never dispatched, A's command keeps its tab active until completion, and a third client's command can still make progress afterward. Repeat with B's tab closed while queued. That distinguishes cleanup of owned tabs from cancellation of work that has already entered the scheduler.

    Your design notes already describe sampling the foreground app every 20 ms. Keeping that observation across disconnect cleanup in this test would also catch a brief focus steal that before/after checks could miss.

  2. rav4nn commented on Oct 2, 2026

    @rav4nn

    Same pain here. I run several Claude Code agents at once on a Mac and every extension connect put Chrome in front of whatever I was typing. One more cause on top of the ones listed: on macOS, talking to Chrome over its debug port (WebSocket) activates Chrome.app by itself. A Chrome started with --remote-debugging-pipe doesn't, but only the process that launched it can hold the pipe. So I built a small proxy that launches Chrome on a pipe, and every MCP session connects to the proxy over localhost, with new tabs opened in the background. It's a different trade-off from the extension route: it runs on a copy of your signed-in profile, so new logins in your real Chrome don't carry over until you re-copy. I built it, MIT: https://github.com/rav4nn/agent-chrome (fork of mimkorn/chrome-pipe-proxy).

  3. added
    browser-chromium
    and removed on Oct 31, 2026
  4. added a commit that references this issue on Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

browser-chromiummilestone

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions