Playwright MCP is an open-source server that exposes a browser to AI agents through the Model Context Protocol. Its README describes it as "A Model Context Protocol (MCP) server that provides browser automation capabilities using Playwright", which "enables LLMs to interact with web pages through structured accessibility snapshots, bypassing the need for screenshots or visually-tuned models" (Playwright MCP README, read 2026-11-26). The package is @playwright/mcp.
What is MCP, in one paragraph?
MCP is a standard way for an AI application to call tools that live outside it. The protocol's own site calls it "an open-source standard for connecting AI applications to external systems" (What is the Model Context Protocol, read 2026-11-26). An MCP client, such as a coding assistant or your own agent, starts or connects to an MCP server, reads its list of tools, and lets the model call them. Playwright MCP is one such server, and its tools are browser actions.
How does an agent use Playwright MCP?
An agent uses Playwright MCP by asking for a snapshot of the page, choosing an element from it, and calling an action tool with that element's reference.
- The agent calls
browser_navigateto open a URL. - It calls
browser_snapshot, which captures an "accessibility snapshot of the current page" and which the tool's own description calls "better than screenshot". - The snapshot is a text outline of the page's roles and names, with a reference for each element.
- The agent calls an action such as
browser_click, passing the "Exact target element reference from the page snapshot". - After the action, it reads the new state and decides the next step.
The README lists the design goals that follow from this: "Uses Playwright's accessibility tree, not pixel-based input", "No vision models needed, operates purely on structured data", and "Avoids ambiguity common with screenshot-based approaches" (Playwright MCP README, read 2026-11-26). If you are deciding between this and screenshots, see accessibility tree or screenshots.
Which tools does Playwright MCP provide?
Playwright MCP provides a core set of browser tools by default and further groups that you switch on with the --caps option.
Table: Playwright MCP tool groups, from its README
| Group | Examples | On by default |
|---|---|---|
| Core automation | browser_navigate, browser_snapshot, browser_click, browser_type, browser_fill_form, browser_select_option, browser_take_screenshot, browser_wait_for, browser_evaluate | Yes |
| Tab management | browser_tabs | Yes |
| Network | browser_route, browser_unroute, browser_network_state_set | No, --caps=network |
| Storage | browser_cookie_list, browser_localstorage_get, browser_storage_state | No, --caps=storage |
| DevTools | browser_start_tracing, browser_start_video | No, --caps=devtools |
| Coordinate-based | browser_mouse_click_xy, browser_mouse_drag_xy | No, --caps=vision |
| browser_pdf_save | No, --caps=pdf | |
| Test assertions | browser_verify_element_visible, browser_generate_locator | No, --caps=testing |
One core tool needs special care. browser_run_code_unsafe runs a Playwright snippet and, in the README's words, "executes arbitrary JavaScript in the Playwright server process and is RCE-equivalent". Treat any agent that can call it as able to run code wherever the server runs.
How do I install Playwright MCP?
Install Playwright MCP by adding it to your MCP client's server list; the client starts it with npx. It needs "Node.js 20 or newer" (Playwright MCP README, read 2026-11-26).
The README's standard configuration, which most clients accept:
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": ["@playwright/mcp@latest"]
}
}
}
For anything automated, pin a version instead of @latest, so a new release cannot change your agent's tools between runs. At the time of writing that would be @playwright/mcp@0.0.86 (npm registry entry, read 2026-11-26).
How do I run Playwright MCP headless on a server?
Run Playwright MCP headless on a server with --headless, and give it a port so clients connect over HTTP instead of starting it themselves. The browser is "headed by default" according to the option list, and the README's standalone mode uses --port.
npx @playwright/mcp@0.0.86 --headless --port 8931 --host 0.0.0.0 --allowed-hosts mcp-browser
The client then points at the server's /mcp endpoint, for example "url": "http://mcp-browser:8931/mcp", where mcp-browser is the server's name on your private network. Three options from the README matter here:
--hostis "Default is localhost. Use 0.0.0.0 to bind to all interfaces." Bind to all interfaces only on a private network.--allowed-hostslists the hosts the server will serve from; it "Defaults to localhost, loopback IPs and the host passed via --host".- The project's Docker image "only supports headless chromium at the moment".
How does Playwright MCP handle the browser profile?
Playwright MCP keeps a persistent profile by default, and offers an isolated mode that keeps it in memory.
Table: Playwright MCP profile modes
| Mode | How to choose it | What persists |
|---|---|---|
| Persistent (default) | No option, or --user-data-dir <path> | Cookies, logins and storage, on disk, between sessions |
| Isolated | --isolated | Nothing; "keep the browser profile in memory, do not save it to disk" |
| Isolated with a saved login | --isolated --storage-state <file> | Only what the storage state file holds |
| Extension | --extension | Connects to tabs in a browser you already run, with its logins |
The README warns that "A persistent profile can only be used by one browser instance at a time, so concurrent MCP clients sharing the same workspace will conflict". For agents, isolated mode with a storage state file is usually the right default; see resetting browser state between sessions and, when you do need persistence, a persistent profile for a browser agent.
Avoid the extension mode for unattended agents. It "allows you to connect to existing browser tabs and leverage your logged-in sessions and browser state", which gives the agent a person's real sessions.
What should a Playwright MCP configuration for an agent sandbox include?
A configuration for an agent sandbox should start clean, write files to a known place, and route traffic through a proxy you control. This is an example, built only from options in the README; adjust paths and the proxy address to your setup:
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": [
"@playwright/mcp@0.0.86",
"--headless",
"--isolated",
"--storage-state=/run/secrets/site-login.json",
"--block-service-workers",
"--viewport-size=1280x720",
"--output-dir=/work/out",
"--proxy-server=http://egress-proxy:3128",
"--redact-url-params=access_token,code"
]
}
}
}
What each line buys you: --isolated discards the session at close; --storage-state loads one login without a profile; --block-service-workers keeps service workers from bypassing request routing; a fixed viewport keeps screenshots comparable; --proxy-server sends traffic through a proxy where your allow-list lives. The README is explicit that some of these are conveniences only: --allowed-origins "*does not* serve as a security boundary and *does not* affect redirects", and the secrets setting "is a convenience and not a security feature". Enforce network rules outside the browser, as in restricting a browser agent's network access.
Is Playwright MCP safe to give to an agent?
Playwright MCP is as safe as the environment you run it in. Its README states: "Playwright MCP is not a security boundary" (Playwright MCP README, read 2026-11-26). Run it in a container or virtual machine that holds nothing else of value, with no personal profile, a network allow-list enforced outside the browser, and browser_run_code_unsafe out of reach of any agent that reads untrusted pages.
The README also notes a design choice worth knowing: by default, file access "is restricted to workspace root directories (or cwd if no roots are configured) only, and navigation to file:// URLs is blocked". --allow-unrestricted-file-access turns that off; leave it off.
When is the Playwright CLI a better fit than Playwright MCP?
The Playwright CLI is a better fit for coding agents that care most about context size. The README says coding agents "increasingly favor CLI–based workflows exposed as SKILLs over MCP because CLI invocations are more token-efficient", while MCP "remains relevant for specialized agentic loops that benefit from persistent state, rich introspection, and iterative reasoning over page structure" (Playwright MCP README, read 2026-11-26). For a comparison with the other widely used browser server, see Playwright MCP vs Chrome DevTools MCP.
What we read for this article
- Playwright MCP README and option list, read 2026-11-26
- npm registry entry for @playwright/mcp, read 2026-11-26
- What is the Model Context Protocol, read 2026-11-26
Frequently asked
Does Playwright MCP need a vision model?
No. Its README says it operates purely on structured data and needs no vision model, because the agent works from the page's accessibility snapshot. Screenshots and coordinate-based mouse tools exist, but the coordinate tools are opt-in with --caps=vision.
Is Playwright MCP free and open source?
Yes. The @playwright/mcp package is published under the Apache-2.0 licence. Version 0.0.86 was the latest on npm when we checked on 2026-11-26.
Can several agents share one Playwright MCP profile?
No. A persistent profile can only be used by one browser instance at a time. Start each extra client with --isolated or point it at its own --user-data-dir.
Is Playwright MCP a security boundary?
No, and its README says so. Its origin allow and block lists also do not serve as a security boundary. Run it inside an isolated container or virtual machine with network rules enforced outside the browser.
Which browsers does Playwright MCP support?
The --browser option accepts chrome, firefox, webkit and msedge. The project's Docker image supports headless Chromium only.