Playwright MCP Server
Browser automation via structured accessibility snapshots. No screenshots or vision models needed.
Playwright MCP is Microsoft's official Model Context Protocol server that gives LLM agents the ability to drive a real browser (Chromium, Firefox, WebKit, or Edge). Instead of relying on screenshots and vision models, it exposes the page's accessibility tree as structured data, which is faster, deterministic, and works without GPU-heavy vision inference. It is intended for agentic workflows like exploratory automation, self-healing tests, web scraping, and end-to-end tasks that require persistent state.
The server ships 50+ tools organized into capability groups. Core automation (click, type, navigate, hover, drag, evaluate JavaScript, fill forms, handle dialogs, take screenshots) is enabled by default. Optional capability flags (--caps=network|storage|devtools|vision|pdf|testing) unlock additional tools for network mocking, cookie and storage management, tracing and video recording, coordinate-based mouse control, PDF export, and test assertion helpers. Sessions can be isolated (ephemeral) or run against a persistent user profile, and a browser extension mode can attach to an existing logged-in browser.
As Microsoft's official Playwright MCP integration, it is actively maintained and supports virtually every major MCP client including VS Code, Cursor, Claude Desktop, Claude Code, Windsurf, Cline, Goose, Gemini CLI, LM Studio, Copilot, and more. Transport options include stdio (default), HTTP/SSE via --port, and a Docker image at mcr.microsoft.com/playwright/mcp.
Tools
| Tool | Description |
|---|---|
browser_navigate |
Navigate the current tab to a URL. |
browser_navigate_back |
Navigate back in browser history. |
browser_click |
Click on an element identified by an accessibility ref. |
browser_hover |
Hover over an element on the page. |
browser_drag |
Drag from one element to another. |
browser_drop |
Drop a payload on a target element. |
browser_fill_form |
Fill multiple form fields in a single call. |
browser_file_upload |
Upload one or more files to a file input. |
browser_handle_dialog |
Accept or dismiss an open dialog. |
browser_evaluate |
Run JavaScript in the page context. |
browser_take_screenshot |
Capture a PNG/JPEG screenshot of the page or an element. |
browser_console_messages |
Return console messages logged by the page. |
browser_close |
Close the page or browser. |
browser_tabs |
List, create, close, or switch browser tabs. |
browser_route / browser_route_list / browser_unroute |
Intercept and mock network requests (requires --caps=network). |
browser_network_state_set |
Toggle offline mode or throttle network (requires --caps=network). |
browser_pdf_save |
Save current page as PDF (requires --caps=pdf). |
browser_generate_locator |
Generate a Playwright locator for an element (requires --caps=testing). |
browser_verify_element_visible / browser_verify_list_visible / browser_verify_text_visible |
Test assertion helpers (requires --caps=testing). |
browser_mouse_click_xy / browser_mouse_move_xy / browser_mouse_drag_xy / browser_mouse_down / browser_mouse_up |
Coordinate-based mouse control for vision-driven agents (requires --caps=vision). |
browser_start_tracing / browser_stop_tracing |
Capture Playwright traces (requires --caps=devtools). |
browser_start_video / browser_stop_video / browser_video_chapter |
Record video of the session (requires --caps=devtools). |
browser_highlight / browser_hide_highlight / browser_annotate |
Visual debugging helpers (requires --caps=devtools). |
Prerequisites
- Node.js 18 or newer
- An MCP-compatible client (Claude Desktop, Cursor, VS Code, Windsurf, Cline, Goose, etc.)
Install
The server runs directly via npx, no global install required. Add this to your MCP client config:
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": ["@playwright/mcp@latest"]
}
}
}
For Claude Desktop, place this in ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows).
Common configuration flags
Pass flags after the package in args:
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": [
"@playwright/mcp@latest",
"--headless",
"--browser=chrome",
"--caps=network,storage,pdf",
"--isolated"
]
}
}
}
Useful flags:
--headlessrun without a visible browser window--browser=chrome|firefox|webkit|msedgechoose engine--isolateduse an ephemeral in-memory profile--user-data-dir=<path>use a persistent profile--caps=network,storage,devtools,vision,pdf,testingenable optional tool groups--allowed-origins/--blocked-originsnetwork allow/block lists--port=<n>run as an HTTP/SSE server instead of stdio
All flags have matching PLAYWRIGHT_MCP_* environment variables.
Docker
docker run -i --rm mcr.microsoft.com/playwright/mcp
Docker mode supports headless Chromium only.
- Run end-to-end test flows from a natural-language description, with the agent generating Playwright locators on the fly.
- Scrape structured data from JavaScript-heavy sites by navigating, filling forms, and reading the accessibility tree.
- Automate logged-in workflows (dashboards, internal tools) using a persistent user profile or the browser extension mode.
- Mock or intercept network requests to test how a web app behaves under failure or offline conditions.
- Generate PDFs, screenshots, and video recordings of multi-step browser sessions for QA or reporting.
- "Open example.com, click the Sign in link, fill the login form with these test credentials, and confirm I land on the dashboard."
- "Go to news.ycombinator.com and return the top 10 story titles, URLs, and point counts as JSON."
- "Navigate to our staging checkout, complete a purchase with the test card 4242 4242 4242 4242, and save a PDF of the receipt."
- "Record a video session walking through the password reset flow and stop when the success message appears."
- "Intercept all requests to /api/pricing and return a mocked 500 response, then verify the UI shows the fallback banner."
- Official Microsoft project, actively maintained alongside Playwright itself.
- Accessibility-tree approach is fast, deterministic, and avoids the cost and ambiguity of vision models.
- Very broad tool coverage (50+ tools) spanning automation, network mocking, storage, tracing, video, PDF, and test assertions.
- Works across Chromium, Firefox, WebKit, and Edge with stdio, HTTP/SSE, and Docker transports.
- Optional capabilities (network, storage, devtools, vision, pdf, testing) are gated behind
--capsflags and must be explicitly enabled. - Docker image only supports headless Chromium, so multi-browser testing requires a local install.
- Not a security boundary: the agent can navigate to and execute scripts against any origin unless you configure allowed/blocked origins.
- Browserbase MCP: hosted cloud browser sessions with stealth and CAPTCHA handling.
- Puppeteer MCP: reference Puppeteer-based browser server from the MCP project.
- Stagehand: AI-first browser automation framework, also offered as an MCP server.