Playwright browser.bind() lets CLI and other clients connect to a launched browser
Introduced 2026-04-01 · score 0.98
HOW TO USE IT
When inspecting a launched browser session, bind it with a name, then attach a client using that name or the returned endpoint. Use `host` and `port` to bind over WebSocket; call `browser.unbind()` to stop accepting connections.
const { endpoint } = await browser.bind('my-session', { workspaceDir: '<project-dir>' });
// In another terminal:
playwright-cli attach my-session
playwright-cli -s=my-session snapshotconst { endpoint } = await browser.bind('my-session', { host: 'localhost', port: 0 });
const client = await chromium.connect(endpoint);@playwright/mcp --endpoint=my-sessionWHY THIS HELPS
When debugging or inspecting a repository's browser session from a coding agent, bind the launched browser and connect a client to it.
REQUIREMENTS AND LIMITATIONS
- Version: v1.59.0
- title (required): Browser server name used for identification.
- workspaceDir: Working directory associated with the browser server.
- host: When specified, creates a WebSocket server instead of a named pipe.
- port: WebSocket port; `0` lets the OS choose an available port.
- endpoint (required): WebSocket endpoint string passed to `chromium.connect(endpoint)`.
- browser.unbind(): Unbinds the browser server previously bound with `browser.bind()`.
- Prerequisite: `browser.bind()` and `browser.unbind()` were added in Playwright v1.59.
- Prerequisite: The connecting Playwright instance’s major and minor versions must match the version that launched the browser.
- Multiple clients at a time are supported.
- Binding over WebSocket uses `host` and `port` options instead of a named pipe.
FIRST-PARTY EVIDENCE
- https://github.com/microsoft/playwright/releases/tag/v1.59.0
- https://playwright.dev/docs/api/class-browser
- https://playwright.dev/docs/api/class-browsertype
Check the installed version and the source before using it. Entry JSON