Skip to content

Playwright Extension: only one MCP client connection is supported at a time #41838

Description

@dosxnjos

Context

The Playwright Extension (packages/extension) is designed to let an MCP client (e.g. an AI
coding agent) drive an existing Chrome browser through the extension's relay. In practice, only
one such connection is supported at a time.

Problem

Opening a second --extension connection while a first one is still active disconnects the first
connection and takes over the browser, instead of the two coexisting. This makes it impossible to
run more than one MCP client against the same browser profile at once — for example, two separate
agent instances (Claude Code, or any other MCP client) each trying to drive their own tabs in the
same browser.

Concretely, today: connection B arriving silently kicks out connection A mid-task, with no
indication to A's client that anything happened beyond its browser tools suddenly failing.

To reproduce

  1. Start an MCP client with --extension --browser chrome (client A), connect it to a tab.
  2. While A is still connected, start a second MCP client the same way (client B), connect it to a
    different tab.
  3. Client A's next tool call fails — its connection was torn down when B connected, even though A
    never disconnected and B targeted an unrelated tab.

Proposed fix

I have a working fix (extension-side, packages/extension/src/background.ts and
connectedTabGroup.ts, plus the status page) that:

  • Tracks connections in a map keyed by the connecting tab id, instead of a single active
    connection.
  • Gives each connection its own Chrome tab group (Playwright · <clientName>, with a (2), (3)
    ... suffix when connections share a client name), so a user can visually tell which tabs belong
    to which connection.
  • Updates the status page to show one block per active connection, each independently
    disconnectable.

No protocol version bump needed, no change to packages/playwright-core's server-side MCP tools.
Covered by a new test file (tests/extension/multi-connection.spec.ts), which passes locally.

I have this ready as a small, self-contained diff (extension-side only) and would like to open a
PR with it, per the contribution guidelines asking to check in here first. Happy to adjust the
approach based on feedback — let me know if this is a direction the team wants, or if a different
approach to multi-connection support is preferred.

Metadata

Metadata

Assignees

Labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions