concurrent-playwright-mcp
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@concurrent-playwright-mcp Create a session and navigate to https://example.com"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
concurrent-playwright-mcp
An MCP server that runs concurrent, session-isolated Playwright browser contexts, so many agents can each drive their own browser at the same time without colliding.
The problem this solves
The official Playwright MCP server (@playwright/mcp) drives a single shared browser context by default, so concurrent clients share one cookie jar, storage, and set of tabs. That is fine for one agent doing one thing, but it breaks the moment you want parallel work:
Two sub-agents navigating at once stomp on each other's page, cookies, and storage.
A "log in as user A" flow and a "log in as user B" flow share one cookie jar, so the second login clobbers the first.
There is no clean way to give each task its own sandbox and tear it down independently.
This server fixes that. Every session gets its own BrowserContext (an incognito-like profile: isolated cookies, localStorage, cache, and tabs) keyed by a sessionId you choose. Sessions share one browser process for efficiency but never share state. The headline guarantee is verified by a real-browser test and a benchmark that asserts zero cross-session collisions.
| concurrent-playwright-mcp | |
Parallel sessions | Shared context | Isolated context per |
Cookies / storage | Shared | Isolated per session |
Independent teardown | No |
|
Resource bounds | n/a | Session cap + optional idle eviction |
Why not @playwright/mcp --isolated?
The official server can isolate too — its --isolated flag gives each connection its own context. The difference is the model:
Addressable sessions. Here isolation is keyed by a
sessionIdyou choose and pass to every call, so a single client can open and drive many isolated sessions and route each call deliberately. With--isolated, a "session" is just the transport connection — you can't address N parallel contexts from one client.Persistable, not ephemeral.
--isolateddiscards all state when the browser closes. Here you canbrowser_save_storage_stateand restore it (storageStatePathon create) to resume an authenticated profile across sessions. (An upstream request for named/persistent sessions was closed as out of scope.)One lightweight context per session — not a process or container per session — so many sessions share one Chromium.
Use @playwright/mcp for a single browser; use this when many agents or tasks each need their own isolated, addressable session at the same time — especially over HTTP.
Related MCP server: ultimate-playwright-mcp
Architecture
cli.ts entrypoint: load config → pick transport
├─ config.ts parse + validate env into a typed config
├─ transport/stdio.ts run over stdio (default)
├─ transport/http.ts run Streamable HTTP: a session manager per client, one shared browser
├─ browser-provider.ts the shared, lazily-launched, memoized Browser (a port)
└─ server.ts MCP edge: validates input (Zod), enforces policy, maps errors
├─ policy/url-policy.ts navigation allowlist + file:/data: blocking (pure)
├─ policy/path-policy.ts filesystem path confinement (pure)
├─ errors.ts error taxonomy: SessionError base + machine-readable codes
└─ session-manager.ts isolated sessions over a BrowserProvider (the core)
└─ session.ts one isolated context: ref actions, capture, storage stateThis is hexagonal: untrusted input is validated at the edge (server.ts) and passed inward as
typed data, so the domain (SessionManager/BrowserSession) carries no transport or re-validation
concerns and knows nothing about MCP. The browser is a port (BrowserProvider) injected into the
manager, so the isolation guarantee is unit-tested with a fake browser (fast, no Chromium in CI)
while a gated integration test proves it against real Chromium. The provider launches lazily and
memoizes, so a burst of concurrent createSession calls shares one browser; over HTTP, every client
gets its own session namespace while still sharing that one Chromium.
Install
npm install -g concurrent-playwright-mcp
# one-time: download the browser Playwright drives
npx playwright install chromiumInstalling the package does not download Chromium — run
npx playwright install chromiumonce, or the firstbrowser_create_sessioncall will fail with a Playwright hint to do so.
Or run from source:
npm install
npm run setup:browser # playwright install chromium
npm run buildUse it from an MCP client
Over stdio (one client, e.g. Claude Desktop / Claude Code / Cursor)
Point your client at the binary; it launches one server process for that client:
{
"mcpServers": {
"concurrent-playwright": {
"command": "npx",
"args": ["-y", "concurrent-playwright-mcp"],
"env": {
"PW_HEADLESS": "true",
"PW_MAX_SESSIONS": "20",
"PW_IDLE_TIMEOUT_MS": "300000",
},
},
},
}Over HTTP (many remote / independent agents → one server)
Run one long-lived server and let multiple agent clients connect to it. Each client gets its own isolated session namespace (it cannot see or touch another client's sessions), while all clients share a single Chromium process:
PW_TRANSPORT=http PW_PORT=3000 npx -y concurrent-playwright-mcp
# clients connect to the Streamable HTTP endpoint at http://<host>:3000/Most clients accept an HTTP MCP URL directly; e.g.:
{
"mcpServers": {
"concurrent-playwright": { "url": "http://localhost:3000/" },
},
}HTTP mode has no built-in authentication. It binds
127.0.0.1by default and rejects mismatchedHostheaders (DNS-rebinding protection is on), so a local web page can't drive it. To serve real remote clients, setPW_HOSTand add the externally-visible host toPW_ALLOWED_HOSTS(e.g.PW_ALLOWED_HOSTS=mcp.example.com:3000), and put it behind your own authenticating proxy / network controls — anyone who can reach the port can drive a browser.
The session-per-agent pattern
The core idea: each agent or task uses its own sessionId. Create it once, then pass it to every
call; sessions never share cookies, storage, or tabs, so parallel work can't collide. Target elements
by the ref ids returned from browser_snapshot (the accessibility tree), not raw CSS:
browser_create_session { "sessionId": "userA", "viewport": { "width": 1440, "height": 900 } }
browser_create_session { "sessionId": "userB", "viewport": { "width": 375, "height": 812 } } # in parallel, fully isolated
browser_navigate { "sessionId": "userA", "url": "https://example.com" }
browser_snapshot { "sessionId": "userA" } # → YAML with refs like [ref=e7]
browser_click { "sessionId": "userA", "ref": "e7", "element": "Sign in button" }
browser_save_storage_state { "sessionId": "userA", "path": "userA.json" } # reuse the login later
browser_close_session { "sessionId": "userA" }Those
browser_… { … }lines are illustrative, not text you type. The model emits a structured tool call and the client routes it over MCP; you never hand-write tool calls.
How it works (integrating with an agent)
Three actors are involved:
Operator (you): install the package + Chromium and add the config block above. That is the entire human surface — you don't enumerate tools or write tool calls.
MCP client / harness (Claude Code, Claude Desktop, Cursor, …): spawns the server (stdio) or connects to it (HTTP), performs the MCP handshake, calls
tools/listto discover the tools and their schemas automatically, and surfaces them — plus the server's built-ininstructions— to the model.LLM / agent: drives the tools in a loop: allocate a
sessionId→browser_create_session→browser_navigate→browser_snapshot(read the page, getrefs) → act byref→ … →browser_close_session.
Configuration happens at three layers:
Layer | Set by | Where | Examples |
Server policy & limits | operator |
|
|
Per-session | agent |
|
|
Per-call | agent | each tool's args |
|
Security limits live only in the server layer — an agent can't widen them (it can't escape
PW_OUTPUT_DIR or bypass PW_ALLOWED_ORIGINS). Per-call args are validated at the edge with
defaults, so the agent can omit the optional ones.
Tools
The agent discovers these (with full JSON schemas) via tools/list; this reference is for human
integrators. Optional params are marked ?. Every tool takes sessionId except
browser_list_sessions.
Session lifecycle
Tool | Params (besides | Returns |
|
| confirmation |
| — (takes no | JSON array of live session ids |
| — | confirmation |
|
| path to saved cookies+localStorage |
Navigation & inspection
Tool | Params (besides | Returns |
|
| confirmation |
| — | confirmation |
| — | accessibility YAML with |
|
| PNG image (+ saved file if |
|
| JSON-serialized result |
|
| confirmation |
|
| confirmation |
|
| confirmation |
|
| JSON |
| — | JSON |
|
| confirmation |
|
| confirmation / tab list |
Element actions — target by ref + element (a human description) from the latest browser_snapshot:
Tool | Params (besides |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Configuration (env vars)
Invalid values (e.g. a negative PW_MAX_SESSIONS) are rejected with a warning on stderr and the
default is used; the effective config is logged to stderr at startup.
Var | Default | Meaning |
|
|
|
|
| Hard cap on live sessions |
|
| Hard cap on tabs per session |
|
| Max console/network entries retained per session |
|
| Evict a session after this long with no use |
|
| Directory screenshots are written to (paths confined to it) |
| unset (any) | Confine |
| unset (any) | Comma-separated origin allowlist for navigation |
|
| Allow |
|
| Per-action timeout for element interactions |
| unset | Use a specific Chromium build |
|
|
|
|
| Host to bind in |
|
| Port to bind in |
| unset | Extra |
Security model
This server is dual-use: it hands an MCP client real control of a browser. Treat the client as semi-trusted and any page it visits as untrusted (a hostile page can try to steer a credulous agent into calling these tools with attacker-chosen arguments). With that in mind:
Navigation (
browser_navigate) blocksfile:anddata:URLs by default — the sharpest local-file-read / SSRF vector. SetPW_ALLOW_FILE_URLS=trueto allow them. Note the default still permits anyhttp(s)URL, including internal services and cloud metadata (169.254.169.254); setPW_ALLOWED_ORIGINSto restrict navigation to an allowlist of origins for any networked deployment.Screenshots and storage state (
browser_screenshotwith apath,browser_save_storage_state, andstorageStatePathon create) are confined toPW_OUTPUT_DIR; paths that try to escape it (via..or an absolute path) are rejected. Storage-state files contain cookies and may hold auth tokens — treat the output dir accordingly.File uploads (
browser_file_upload) read local files. By default any path is allowed; setPW_UPLOAD_DIRto confine uploads to one directory.browser_evaluateruns arbitrary JavaScript in the page (sandboxed to the page, not Node). It is a privileged capability; the navigation allowlist is the most effective containment.HTTP mode binds
127.0.0.1by default, enables DNS-rebinding protection (rejects unexpectedHostheaders), caps request body size and concurrent sessions, and gives each client an isolated session namespace. It has no authentication — see the warning under "Over HTTP" before exposing it beyond localhost.
Errors are reported in-band (isError) with a stable code prefix (e.g. NAVIGATION_BLOCKED,
PATH_NOT_ALLOWED, SESSION_NOT_FOUND), never thrown across the JSON-RPC channel.
Demo and benchmark
npm run demo # two isolated sessions (desktop + mobile) drive a site in parallel
npm run benchmark # N parallel sessions, reports throughput + asserts 0 collisions
npm run benchmark 25Development
npm run check # typecheck + lint + format + unit tests
npm run test:coverage # unit tests with coverage (no browser needed)
npm run test:integration # gated real-Chromium tests: isolation + deterministic, offline e2e
# journeys through the MCP server (needs Chromium). Add
# PW_HEADLESS=false to watch the parallel, isolated windows.
npm run build # tsup -> dist/ (ESM + d.ts)Test tiers: fast unit tests (the merge gate, no browser) → deterministic real-Chromium integration
and several end-to-end journeys through the MCP server against a local styled app (gated by
RUN_INTEGRATION=1, also run in CI).
See AGENTS.md for the engineering conventions this repo is built to.
License
MIT
Available Tools
23 toolsbrowser_clickClickC
Click an element (by ref from browser_snapshot).
Inputs: ref (required), element (required), sessionId (required).
browser_close_sessionClose sessionA
Close a session and release its browser context.
Inputs: sessionId (required).
browser_console_messagesConsole messagesC
Return console messages captured in the session.
Inputs: sessionId (required), onlyErrors.
browser_create_sessionCreate sessionA
Create an isolated browser session. Each session has its own cookies, storage, and tabs; sessions never share state, so many agents can drive separate sessions at once.
Inputs: sessionId (required), viewport, storageStatePath.
browser_dragDrag and dropB
Drag one element onto another (both by ref from browser_snapshot).
Inputs: sessionId (required), sourceRef (required), targetRef (required), sourceElement (required), +1 more.
browser_evaluateEvaluate JavaScriptB
Run a JavaScript expression in the page and return the JSON-serialized result.
Inputs: script (required), sessionId (required).
browser_file_uploadUpload filesB
Set files on a file input (by ref from browser_snapshot).
Inputs: ref (required), paths (required), element (required), sessionId (required).
browser_fill_formFill formA
Fill several fields in one call (each by ref from browser_snapshot).
Inputs: fields (required), sessionId (required).
browser_handle_dialogHandle dialogC
Decide the next dialog (alert/confirm/prompt) instead of auto-dismissing it.
Inputs: accept (required), sessionId (required), promptText.
browser_hoverHoverA
Hover over an element (by ref from browser_snapshot).
Inputs: ref (required), element (required), sessionId (required).
browser_list_sessionsList sessionsA
List the ids of all live browser sessions.
Inputs: no named parameters.
browser_network_requestsNetwork requestsC
Return network responses captured in the session.
Inputs: sessionId (required).
browser_press_keyPress keyB
Press a keyboard key (e.g. "Enter", "ArrowDown").
Inputs: key (required), sessionId (required).
browser_resizeResize viewportC
Resize the session's viewport.
Inputs: width (required), height (required), sessionId (required).
browser_save_storage_stateSave storage stateA
Save the session's cookies + localStorage to a JSON file (within the output dir) for later reuse via browser_create_session.
Inputs: path (required), sessionId (required).
browser_screenshotScreenshotB
Capture a PNG of the active page and return it as an image. Optionally also save it to a file within the output dir.
Inputs: sessionId (required), path, fullPage.
browser_select_optionSelect optionB
Select one or more options in a (by ref from browser_snapshot).
Inputs: ref (required), values (required), element (required), sessionId (required).
browser_snapshotAccessibility snapshotA
Get the accessibility snapshot (YAML) of the active page, including element refs to target with other tools.
Inputs: sessionId (required).
browser_tabsTabsC
List, open, close, or select a tab within the session.
Inputs: action (required), sessionId (required), index.
browser_typeTypeA
Fill an input with text (by ref from browser_snapshot).
Inputs: ref (required), text (required), element (required), sessionId (required).
browser_wait_forWait for selectorB
Wait until a CSS selector reaches a state.
Inputs: selector (required), sessionId (required), state, timeout.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 23 tools
Each tool targets a specific browser automation action (click, type, navigate, etc.) with clear boundaries. The only potential overlap is between browser_type and browser_fill_form, but the latter is explicitly for multiple fields, so no confusion.
All tools follow the exact same `browser_<verb>` pattern in snake_case, providing a predictable and intuitive naming scheme. There are no deviations or mixed conventions.
At 23 tools, the set is comprehensive but on the higher side. However, each tool serves a distinct and necessary browser automation function, so the count is justified and not excessive.
The tool surface covers nearly all essential browser automation tasks: navigation, interaction, evaluation, dialogs, network, console, sessions, storage, tabs, waiting, and screenshots. Minor gaps like scrolling or raw DOM queries exist but are workable.
Maintenance
Related MCP Connectors
Official Browserless MCP server: browser automation, scraping, screenshots and PDFs for AI agents.
Hosted Web Crawler MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
MCP server for Mint — AI-powered QA that runs your app in a real browser on every PR.
Unofficial Browserless MCP — wraps the Browserless headless-Chromium REST API (browserless.io)
Related MCP Servers
- AlicenseNot gradedqualityNot gradedmaintenanceA Playwright-based MCP server that exposes a live browser as a traceable, inspectable, debuggable and controllable execution environment for AI agents.5,213 npm57-
- AlicenseAqualityDmaintenanceMulti-agent Playwright MCP server with tab isolation via targetId, enabling multiple agents to share a single Chrome browser while maintaining isolated tab groups and shared sessions.1412 npm3MIT
- AlicenseBqualityDmaintenanceAn MCP server for generic browser automation using Playwright. Enables MCP clients to navigate pages, inspect elements, execute JavaScript, capture screenshots, and monitor console logs and network traffic via a headless Chromium instance.7ISC
- AlicenseBqualityDmaintenanceA tab-aware Playwright MCP server that enables multiple agents to operate on different tabs concurrently while sharing a single browser context and login session.2317 npm1MIT