Skip to content

Menu

Playwright MCP Server logo

Playwright MCP Server

Published · Updated

At a glance

GitHub repository
microsoft/playwright-mcp
Watch out for
Snapshots of large pages are big, so long sessions eat context quickly. The Playwright CLI is the lighter option for coding agents.

Playwright MCP is Microsoft's browser automation server, built on the same Playwright library that a lot of teams already use for end-to-end tests. It lets an agent open pages, click, type, fill forms, read console output and inspect network requests in a real Chromium, Firefox or WebKit browser.

What makes it different from screenshot-driven browser tools is that it works from the page's accessibility tree. After each action the agent gets a structured snapshot of the page, with elements it can refer to by reference rather than by pixel coordinates. That means it does not need a vision model, and clicks land on the element you meant rather than the one that happened to be near a coordinate.

The Playwright team is open about one trade-off: those snapshots are large. Their own README now suggests that coding agents with tight context budgets may be better served by the separate Playwright CLI with skills, and that the MCP server fits longer, stateful sessions such as exploratory testing or debugging a flow step by step. That is honest advice and worth following.

How it connects

Your AI app

An assistant or agent that supports MCP

Playwright MCP Server

Runs as

  • npx (Node.js)

Gives the agent

  • Accessibility snapshots
  • Forms and input
  • Debugging tools
  • Storage and session state
  • Optional capabilities

A web browser

The data or system the tools act on

Your AI app talks to Playwright MCP Server over the Model Context Protocol, and the server carries out the work. Built from the setup and capability sections on this page.

What it can do

Accessibility snapshots
browser_snapshot returns the page as a structured tree of roles, names and element references. Most other tools, such as browser_click and browser_type, take a reference from the latest snapshot.
Forms and input
browser_fill_form, browser_select_option, browser_file_upload, browser_press_key and browser_handle_dialog cover most of what a person does on a page, including file pickers and confirm dialogs.
Debugging tools
browser_console_messages and browser_network_requests show what the page logged and fetched. browser_start_tracing records a Playwright trace you can open in the trace viewer afterwards.
Storage and session state
With --caps=storage, cookies, localStorage and sessionStorage get their own browser_cookie_*, browser_localstorage_* and browser_sessionstorage_* tools. Separately, --storage-state loads a saved login into an isolated session.
Optional capabilities
--caps turns on extras such as vision for coordinate-based mouse tools, pdf for saving pages as PDF, devtools, network, storage and testing. They are off by default to keep the tool list shorter.

Setting it up

Requires Node.js 20 or newer. The standard config runs npx @playwright/mcp@latest as a stdio server. In Claude Code: claude mcp add playwright npx @playwright/mcp@latest. In Codex: codex mcp add playwright npx "@playwright/mcp@latest". The browser runs headed by default so you can watch it; add --headless for CI or remote machines. By default it keeps a persistent profile, so logins survive between sessions; use --isolated for a fresh in-memory profile each time, and --browser to pick chrome, firefox, webkit or msedge.

Run in a terminal
claude mcp add playwright -- npx -y @playwright/mcp@latest

Runs the @playwright/mcp package from npm. Add any API keys, environment variables or extra arguments the setup notes above list. Combine several servers in the MCP config generator

Where each client keeps its MCP config file, and the JSON it expects (cheat sheet)

Where it helps

  • Reproducing a bug report by having the agent follow the steps in a real browser and read the console errors
  • Checking that a page you just changed renders and behaves correctly before you commit
  • Exploratory testing of a sign-up or checkout flow, then turning the steps into a Playwright test
  • Inspecting which network requests a page makes and which ones fail
  • Filling in repetitive internal admin forms during development

Limitations and things to watch

  • Snapshots of large pages are big, so long sessions eat context quickly. The Playwright CLI is the lighter option for coding agents.
  • --allowed-origins and --blocked-origins are documented as not being a security boundary; they do not cover redirects.
  • browser_run_code_unsafe runs arbitrary JavaScript in the Playwright server process, as the name warns. Treat it as code execution on your machine.
  • The default persistent profile keeps cookies. If you log in to real accounts during a session, those sessions remain available to the agent later.

Sources

Written from the project's own documentation, checked November 2026.

How we research: where our facts come from, how often we re-check them, and why no one can pay for a review or a verdict.

Video

From our YouTube channel. The player loads from YouTube only when you press play.

Reviews and commentsShow

Reviews

Sign in to leave a review.

Loading reviews…

Comments

Sign in to leave a comment.

Loading comments…