MCP server, by Microsoft
Playwright MCP Server
Microsoft MCP server that automates a real browser through Playwright from accessibility snapshots, without a vision model.
Quick facts
What it does
Playwright MCP gives a model browser automation through Playwright. It works from structured accessibility snapshots, so no vision model is required, and actions target elements deterministically from the page structure. The README contrasts MCP, built for persistent stateful agentic loops, with the Playwright CLI, built for token-efficient coding-agent workflows.
The standard install runs with npx @playwright/mcp@latest and needs Node.js 18 or newer. The browser can run headed or headless, can use chrome, firefox, webkit, or msedge, can emulate devices, and can connect to an existing browser through CDP or the Playwright extension.
Browser state can persist in a user data directory, run isolated in memory, or start from a storage state file. A JSON config file sets browser, server, capabilities, and context options.
Configuration
Run with npx @playwright/mcp@latest. Node.js 18 or newer is required. Install a browser through Playwright if none is present.
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": ["@playwright/mcp@latest"]
}
}
}Source: https://github.com/microsoft/playwright-mcp. Placeholders only. Replace them in your own environment, and never commit real keys to a repository.
| Environment variable | Required | Purpose |
|---|---|---|
PLAYWRIGHT_MCP_BROWSER | Optional | Browser or Chrome channel to use: chrome, firefox, webkit, or msedge. |
PLAYWRIGHT_MCP_HEADLESS | Optional | Runs the browser in headless mode. Environment form of the --headless option. |
PLAYWRIGHT_MCP_PORT | Optional | Port to listen on for SSE transport. |
PLAYWRIGHT_MCP_CONFIG | Optional | Path to the JSON configuration file. |
PLAYWRIGHT_MCP_ALLOWED_HOSTS | Optional | Comma-separated list of hosts the server may serve from. Pass * to disable the host check. |
PLAYWRIGHT_MCP_USER_DATA_DIR | Optional | Path to the user data directory for browser profile persistence. |
Tools and features on record
browser_navigate Config checked
Navigates the browser to a URL.
browser_snapshot Config checked
Returns the page accessibility tree with element references for later actions.
browser_click and browser_type Config checked
Clicks an element and types text, addressed by accessibility references.
browser_fill_form Config checked
Fills multiple form fields in one call.
browser_take_screenshot Config checked
Captures a screenshot of the current page.
browser_evaluate Config checked
Executes JavaScript in the page context.
Harness notes: snapshots are the context cost
From the Harness pillar: what the vendor documentation says about running this server inside an agent harness.
- The server works from structured accessibility snapshots rather than screenshots. Each observation stays text-shaped and referenceable (click by ref) instead of image-priced.
- browser_snapshot takes a depth limit and can write the snapshot to a file instead of returning it, so the harness controls how much of the page enters the context. Keep full-page snapshots out of the run unless a step needs one.
- The Microsoft README frames MCP servers as token-heavier than driving the same browser through CLI plus skills. For long browser jobs, that trade belongs in harness design, not in the prompt.
Source: Playwright MCP README (snapshots, tools, token cost), checked 2026-10-08.
Security notes
- The server controls a real browser and can reach any page that browser can reach, including logged-in sessions when a persistent profile or extension connection is in use.
- File access is restricted to workspace roots by default. --allow-unrestricted-file-access removes that restriction and also allows file:// URLs. Avoid it unless required.
- Allowed hosts and origin allow/block lists shape network reach. The README states these lists do not serve as a security boundary and do not affect redirects.
- Persistent profiles store login state on disk. Use --isolated or a separate --user-data-dir for parallel or sensitive sessions.
An MCP server runs with the permissions of the process you start it from. Scope credentials to the narrowest access the job needs, and review what the client will send before connecting anything sensitive.
Stacks featuring this server
Sources and freshness
- Official source: https://github.com/microsoft/playwright-mcp
- Repository: https://github.com/microsoft/playwright-mcp
Checked 2026-10-29. Config-checked means the configuration and feature list trace to the official source above; it does not mean AgentsUse ran the server. Send corrections through the contact page. Back to the MCP server index.