← All posts

AI tool reviews › MCP servers

What is Playwright MCP? How AI agents drive a real browser

How Playwright MCP lets an AI agent read web pages as accessibility snapshots and drive a browser, with a small hands-on comparison against playwright-cli.

If you’ve looked for a way to have an AI coding agent check a web page for you, you’ve probably run into the name Playwright MCP. It sits in Claude Code’s official plugin list, and its README carries setup steps for 20 clients, Cursor and VS Code among them. Still, it may not be obvious what the agent actually sees once it’s installed, or what it can do with the browser.

Playwright MCP is an MCP server that Microsoft released in March 2025. MCP is an open standard for connecting AI applications to outside tools and data (What is MCP?), and the tool this server offers through it is a browser. It launches a browser with Playwright, the web automation framework, turns each page into a text snapshot of its accessibility tree for the agent to read, and then clicks, types, and navigates on the elements the agent picks. That’s why the README says it works without screenshots or visually tuned models.

The numbers show why the name comes up so often. On October 28, 2026, the GitHub API showed 38,725 stars on the repository. By the counts in Claude Code’s official plugin list, the playwright plugin had 358,117 unique installs as of October 16, seventh among 315 plugins. Interestingly, though, the README says right at the top that a coding agent might be better off with a CLI and a skill than with MCP. So I handed the same small task to both and compared what happened.

Reading a page through its accessibility tree

The accessibility tree is a structure the browser builds from the DOM for assistive technology such as screen readers, and it records each element’s role and name (MDN). To test with, I made a small HTML page with a name field and a Greet me button that shows a greeting 0.3 seconds after you press it. When I served the page locally and called the browser_snapshot tool, the response held the snapshot below. The page URL and title also come back in the response, so I’ve kept only the snapshot part.

- generic [active] [ref=e1]:
  - heading "Say hello" [level=1] [ref=e2]
  - generic [ref=e3]:
    - text: Your name
    - textbox "Your name" [ref=e4]
    - button "Greet me" [ref=e5]
  - status

Every element gets a reference such as e4. Instead of coordinates, the agent passes these refs to browser_type or browser_click, and the server turns them into Playwright code, runs it, and writes that code into the response. The typing step came back with await page.getByRole('textbox', { name: 'Your name' }).fill('Ada');, and after the click, the last line of the new snapshot read status [ref=e6]: Hello, Ada! Nice to meet you. Because the agent works through these refs, tools that click by screen coordinates aren’t in the default list, and they appear only when you turn them on with --caps=vision.

Twenty-five default tools and what they cost up front

When I asked the 0.0.83 server for its tool list, it offered 25 tools by default. Alongside navigating, snapshots, clicking, typing, filling forms, and waiting, there are tools for console messages and network requests, and also browser_run_code_unsafe, which runs arbitrary code in the server process. The browser opens a window by default, so you pass --headless to run without one, and --isolated keeps the browser profile in memory instead of saving it to disk. --browser picks chrome, firefox, webkit, or msedge.

You might expect the definitions of 25 tools to sit in the context all the time. Claude Code, though, turns on tool search by default, so it loads only the names of MCP tools at first and fetches their definitions when they’re needed (Claude Code docs). In my runs, the first request with Playwright MCP attached was only 392 tokens larger than the same request without it. With tool search off through ENABLE_TOOL_SEARCH=false, on the other hand, every definition loaded up front, and the first request came out about 6,700 tokens larger than one sent with the same setting and no MCP server. Snapshots don’t land in every response either. In the 0.0.83 I tested, responses to navigating or clicking carried only a link to a snapshot file saved in a .playwright-mcp/ folder, and the tree came back inline only when the agent called browser_snapshot.

How the README itself compares MCP and the CLI

The README and the playwright-cli repository carry the same explanation. Modern coding agents increasingly favor CLI workflows packaged as skills, it says, because CLI calls are more token-efficient: they avoid loading large tool schemas and verbose accessibility trees into the model’s context. It adds that MCP remains relevant for specialized loops such as exploratory automation, self-healing tests, or long-running autonomous workflows, where keeping a continuous browser context outweighs the token cost.

A skill is a SKILL.md instruction file that the agent reads when it needs it. In Claude Code, only the skill’s description stays in the context, and the body loads when the skill is invoked (skills docs). playwright-cli does the same work through commands like open, fill, click, and snapshot, while a background daemon holds the browser open between commands. Underneath it runs the same Playwright code, so its output had the same format as the MCP responses.

Filling the same form three ways

I served the page on 127.0.0.1:8417 with Python’s http.server and gave headless Claude Code the same prompt in three setups: one allowed only curl, one had Playwright MCP attached, and one had playwright-cli with its skill. Every run used --model haiku and started in a fresh, empty folder. Here are the config and the command for the MCP run.

{
  "mcpServers": {
    "playwright": {
      "command": "npx",
      "args": ["@playwright/mcp@latest", "--headless", "--isolated"]
    }
  }
}
claude -p "Open http://127.0.0.1:8417/ in a browser, type Ada into the name field, press the Greet me button, and reply with only the exact sentence that appears on the page." \
  --mcp-config mcp.json --model haiku \
  --allowedTools "mcp__playwright__browser_navigate,mcp__playwright__browser_snapshot,mcp__playwright__browser_type,mcp__playwright__browser_fill_form,mcp__playwright__browser_click,mcp__playwright__browser_wait_for" \
  --output-format stream-json --verbose < /dev/null > run.jsonl

claude -p is a headless run that executes once without opening a chat, and --allowedTools lists only the six tools this task needs. In the actual runs, I added a few environment variables to mcp.json so that caches and temporary files stayed inside the work folder, and I wrapped playwright-cli in a small script for the same reason. Here’s the stream-json log, summarized by a short script. The number on the left is the input token count of the request that made each call, which is the size of the whole context the model read at that moment.

model: claude-haiku-5-5
 19449 > ToolSearch {"query": "select:mcp__playwright__browser_navigate,mcp__playwri
         < 4 tool definitions
 20777 > browser_navigate {"url": "http://127.0.0.1:8417/"}
 20777 > browser_snapshot {}
         < 225 chars
         < 291 chars
 21250 > browser_type {"target": "e4", "text": "Ada", "element": "Your name textbox"}
         < 101 chars
 21430 > browser_click {"target": "e5", "element": "Greet me button"}
 21430 > browser_snapshot {}
         < 244 chars
         < 336 chars
 21945 > answer: Hello, Ada! Nice to meet you.
turns: 7, time: 10.5s, cost: $0.0035

The first call went to ToolSearch, one of Claude Code’s own tools, and loading four definitions made the next request 1,328 tokens larger. After that, each step added only 180 to 515 tokens. The playwright-cli run began by invoking the skill through the Skill tool, which loaded about 15,600 characters of skill text at once and added 6,275 tokens. It then finished in two Bash calls, each chaining commands with &&. The curl-only run read the HTML, tried to write and run a Python Playwright script, and was stopped by the permission check. It answered that the source suggested the same sentence but that it hadn’t seen it on the page.

No tool (curl) Playwright MCP playwright-cli with skill
Result Guessed from the source Read it from the page Read it from the page
Turns, time 7 turns, 15.2s 7 turns, 10.5s 5 turns, 11.0s
Input tokens of last request 21,619 21,945 26,288
Cost $0.0044 $0.0035 $0.0043

On this small page, the CLI used about 4,300 more tokens of context, the opposite of what the README describes. The skill body that loads all at once was simply larger than the four deferred tool definitions. A second run of each came out about the same, at 22,077 tokens for MCP and 26,289 for the CLI, while the MCP run with tool search off reached 42,377 tokens and $0.0106, roughly three times the cost. Of course, a few small runs like these don’t make a benchmark, so in long sessions where snapshots pile up, or in clients that load every tool up front, the README’s point may well hold.

How it differs from similar tools

Vercel Labs’ agent-browser is also a CLI for agents that works through accessibility-tree snapshots and refs such as @e1. Its CLI and daemon are written in Rust, though, and they talk to the browser over the Chrome DevTools Protocol without Playwright. agent-browser mcp starts an MCP server as well. It had 44,729 stars on October 28, and I didn’t run it, so this is based only on its README and skill files. Google’s Chrome DevTools MCP also works with a running Chrome, but it leans more toward debugging and performance analysis.

Where it fits, and what you take on

It fits best when you want to confirm that a web app you just changed actually works, since unlike the curl run above, it answers from what appeared on the page. Because every action shows the Playwright code it ran, it’s also a handy starting point for writing tests, and --caps=testing adds tools that verify elements and text. It suits exploring an unfamiliar site’s flow, too. On the other hand, for a static page where you only need the content, curl is cheaper, and things you have to see, such as layout or color, don’t make it into a text snapshot.

The first cost is tokens. When I built a 100-row order table and took a snapshot, the response ran to 23,748 characters, more than twice the 10,751-byte HTML, or about 7,900 tokens by a tiktoken estimate. Searching the same page for just “Order 1042” with browser_find brought the response down to 389 characters. And whatever the page says goes straight to the model inside the snapshot.

Logged-in browsers need care as well. Without --isolated, the server uses a persistent profile on disk, and the README says all logged-in information is stored in that profile. With --extension or --cdp-endpoint, it attaches to a browser that’s already running, so if the agent follows instructions hidden in a page, it could end up acting through your logged-in accounts. The README states that neither Playwright MCP nor --allowed-origins is a security boundary, and the description of browser_run_code_unsafe calls it equivalent to remote code execution. That’s why I’d suggest allowing only the tools you need, as in the command above. The license is Apache-2.0, the source lives in the Playwright repository, and the latest release is v0.0.83 from September 28, 2026. With 73 releases so far, it changes often, so it’s safest to recheck the options in whichever version you use.

Installing it and a first thing to try

claude mcp add playwright npx @playwright/mcp@latest
claude mcp remove playwright
npm install -g @playwright/cli@latest
playwright-cli install --skills

The first line is the Claude Code install command from the README, the second removes the server, and the third and fourth install playwright-cli and add its skill to your project. The official plugin holds nothing more than a config that starts this server, and you install it with /plugin install playwright@claude-plugins-official. To pass options, put -- before the server command, as in claude mcp add playwright -- npx @playwright/mcp@latest --headless --isolated. I attached everything for a single run only so I wouldn’t change any settings, which means I didn’t run these install commands myself.

If you’re new to it, I’d suggest starting your web app’s local dev server and asking the agent to fill in one form and report the result, with --headless --isolated and only the tools it needs. I ran these examples on October 28, 2026, on macOS with Claude Code 2.1.304, where --model haiku resolved to claude-haiku-5-5. The server was @playwright/mcp 0.0.83 (Playwright 1.64.0-alpha), the CLI was @playwright/cli 0.1.22, and the browser was the installed Google Chrome 156.

AI tools helped with the research for this post.