NewAgent Observability is live.
Back to directory
Playwright logo

Playwright MCP server: tools, cost and trade-offs

What an AI agent can drive through Playwright, what the browser tools cost your context window, and why Microsoft's own README points coding agents at its CLI instead.

Connector
Official, local
Coverage
Browser navigation, forms, assertions, tracing
Tools
24, all on by default
Biggest risk for an agent
A default tool that runs any code on your machine

Last verified 1 September 2026 · from Microsoft's repository, its documentation and the server's own tools/list response

This page is one of 90 in a directory of monitoring and developer tools. Each page checks what an AI coding agent can get out of the tool through its MCP server, the connector that lets the agent query the tool directly.

Summary

The Playwright MCP server is one of the most used anywhere, at 36,679 stars. Its README opens by suggesting that a coding agent might not want it.

Microsoft points coding agents at Playwright CLI with Skills instead. The stated reason is one this guide measures on every page: CLI calls avoid loading large tool schemas into the model's context.

The 24 browser tools cost about 3,402 tokens, which is modest. The cost the README is warning about is not the tool list; it is the page snapshots the tools return during a session.

What is the Playwright MCP server?

It is Microsoft's server for the Model Context Protocol. The agent gains tools for driving a real browser: navigate, click, fill a form, take a snapshot, assert that text is visible.

It drives the browser through Playwright's accessibility tree rather than screenshots, so the agent reads structured page state instead of pixels. That is what makes the page readable by a text model. It is also what makes the output large.

There are two ways to automate a browser from an agent, and Microsoft documents both. This server is the MCP route. Playwright CLI with Skills is the other, and the README suggests it for coding agents.

Playwright covers code, tests and review broadly through browser testing, and reaches nothing in release, production observability, agent observability or cost.

Part of the workWhat Playwright has hereCan an agent reach it
Code, tests & reviewBrowser automation and end-to-end testingYes. Core strength. An agent can drive a real browser and verify what a user would see
CI & releaseNone in this connectorNo. Playwright runs in CI, but this server drives a browser on your machine. It has no pipeline tools
Production observabilityNoneNo telemetry of any kind. It observes a browser, not a running system
Agent observability & evalsNoneNo traces, evaluations or prompt versioning for your own agents
AI cost managementNoneNo token or model spend data

In practice, Playwright answers questions you can only answer by using the product. An agent connected here can reproduce a bug, fill a form and confirm what a user sees. It cannot tell you whether the same flow is failing for real users, so pair this connector with an observability connector rather than replacing one.

What can an AI agent do with Playwright?

TaskToolsWorksWatch out for
Reproduce a reported bugbrowser_navigate browser_click browser_snapshotYesEach snapshot returns the accessibility tree, which is the expensive part of a session
Fill and submit a formbrowser_fill_form browser_type browser_press_keyYesbrowser_fill_form sets several fields in one call, which costs less than one call per field
Check what the page actually showsbrowser_find browser_snapshotYesbrowser_find returns matching nodes with context, far cheaper than a full snapshot
Read console errors and network trafficbrowser_console_messages browser_network_requestsYesA busy page returns a long list; ask for the failure rather than the whole log
Capture evidence for a bug reportbrowser_take_screenshotYesWritten to the output directory, not returned inline. PDF export is an opt-in capability
Run an existing Playwright test suiteNoThis drives a browser interactively. Running the suite is the CLI's job

The pattern across these rows is that a session's cost is dominated by what the tools return, not by how many tools exist. A snapshot of a complex page is far larger than the 24 tool definitions that make it available.

24 tools registered by default, of which the server marks 7 read-only

Navigation3Write
browser_navigatebrowser_navigate_backbrowser_tabs
Reading the page5
browser_snapshotbrowser_findbrowser_console_messagesbrowser_network_requestbrowser_network_requests
Interaction6Write
browser_clickbrowser_typebrowser_fill_formbrowser_press_keybrowser_hoverbrowser_select_option
Drag and files3Write
browser_dragbrowser_dropbrowser_file_upload
Code execution2Write
browser_evaluatebrowser_run_code_unsafe
Session4Write
browser_resizebrowser_wait_forbrowser_handle_dialogbrowser_close
Evidence1
browser_take_screenshot

The write marks are the server's own readOnlyHint annotations, not an editorial judgment: 7 of the 24 declare themselves read-only and 17 do not. Further tools exist behind --caps, which accepts vision, pdf and devtools. Counted from tools/list on 21 August 2026.

What connecting costs before the first question

A context window is the amount of text a model can hold at once, and connecting uses some of it before the agent asks anything. Every tool the server registers sends its name, description and input schema to the model when the session starts. The tool list is charged whether or not a single tool is called.

Playwright keeps its descriptions short for a list of its size, at 68 characters per tool. That is deliberate, and it is not where the cost lives: the schemas are.

The README makes the cost argument itself. It steers coding agents to Playwright CLI with Skills because CLI calls avoid loading large tool schemas and verbose accessibility trees into the model context. The first half of that is the table below. The second half is every snapshot the agent takes afterwards.

Tool setToolsTokens (GPT-5.6, GPT-5.5)Tokens (GPT-4, GPT-3.5)Tokens (Claude Haiku 4.5 to Opus 5)Share of a 200,000-token window
Default capabilities243,402 to 4,9963,332 to 4,9894,956 to 6,1721.7% to 3.1%

Encodings: GPT-5.6, GPT-5.5 o200k_base; GPT-4, GPT-3.5 cl100k_base; Claude Haiku 4.5 to Opus 5 count_tokens. Counted 21 August 2026 from tools/list on the published @playwright/mcp package, run locally.

Registration is static, so no browser session was involved. Figures cover name, description and input schema. They do not include what tools return at run time. The two models in column one share the o200k_base encoding, so they get one count. The spread is formatting, about 47%. Reasoning tokens are output, spent per request. The tool list is input, charged once at connection.

The Claude figures are measured rather than encoded. Anthropic publishes no local tokenizer, so the definitions were sent to the API's count_tokens endpoint and a no-tools baseline subtracted. The range covers two tokenizer generations rather than two serializations. Haiku 4.5 and Opus 4.6 sit at the low end, Opus 5 and Sonnet 5 at the high end. The gap between them is about a quarter.

Playwright MCP server limits: where answers come back incomplete

The limits below are about session cost, not about the connector failing.

The agent says: I ran a small script to check the page. That tool executes arbitrary code on the host.

browser_run_code_unsafe is in the default tool set, and its own description states that it executes arbitrary JavaScript in the Playwright server process and is RCE-equivalent. The name and the warning are Microsoft's own.

browser_evaluate is milder but related: it evaluates JavaScript in the page. The difference is where the code runs, which is the difference between the page and your machine.

Guard: Leave browser_run_code_unsafe off your client's allowlist, and run the server in a container if an agent needs it.

The agent says: Let me take another look at the page. Each look spends thousands of tokens.

browser_snapshot returns the page's accessibility tree, which for a real application is long. An agent that snapshots after every click accumulates several copies of a large document in its context, and the useful signal is usually one line of it.

Microsoft names this as the reason to prefer the CLI for coding agents. CLI invocations avoid loading verbose accessibility trees, so an agent keeps more of its window for the codebase.

Guard: Prefer browser_find over repeated snapshots, and have the agent state what it is looking for before it looks.

The agent says: I saved a screenshot of the failure. It wrote a file the agent cannot read back.

browser_take_screenshot writes to the server's output directory. The agent gets a path, not an image, so a screenshot is evidence for a human rather than something the agent reasons about.

Guard: Use screenshots for the bug report and the accessibility tree for the agent's own reasoning.

The agent says: The task is finished. The browser is still running.

The session holds a real browser process. It persists between tool calls by design, which is what allows a multi-step flow, and it does not close because the conversation moved on.

Guard: Call browser_close at the end of a flow, or run the server in a container.

How to configure Playwright MCP for agents

  1. 1

    Decide whether the agent may execute code

    browser_run_code_unsafe is in the default set and its own description calls it RCE-equivalent. There is no read-only flag, so the only gate is your client's allowlist.

  2. 2

    Choose a profile mode

    The default is a persistent profile holding your logged-in state, at a documented path per operating system. --isolated keeps the profile in memory instead, optionally seeded from --storage-state.

  3. 3

    Run one client per profile

    A persistent profile can only be used by one browser instance at a time, so parallel clients sharing a workspace conflict. Give each additional client --isolated or its own --user-data-dir.

  4. 4

    Do not treat --allowed-origins as a boundary

    The documentation is explicit that it is not a security boundary and does not affect redirects.

Paste this into your agent’s instructions

This connector's failure mode is cost rather than silence: snapshots are large and accumulate. The block makes the agent say what it looked at and why, so a session that spends its window on repeated snapshots is visible in the answer.

Terminal
When you answer using Playwright MCP tools, state:
- What you looked at, and how. Prefer browser_find over a full
  browser_snapshot, and say which you used.
- The URL and the page state each observation came from.
- Whether a screenshot was saved. You receive a file path, not
  an image, so you cannot read it back.
Never state that data does not exist. State that it was not
found on the page under the constraints above.
Write your answer in ASD-STE100 Simplified Technical
English. Use short sentences with one idea in each.

Do you need the MCP server at all?

Not always, and Microsoft says so itself. The README suggests that coding agents may be better served by Playwright CLI with Skills than by this server.

The argument is token efficiency. CLI invocations avoid loading large tool schemas and verbose accessibility trees, so an agent working across a codebase keeps more of its window.

The server still wins where the work is interactive and exploratory, because a CLI call cannot hold a browser open across turns. For running an existing suite, or for a repeatable flow, the CLI is the better shape.

Use the CLI with Skills for a coding agent working in a repository. Use the server when the agent needs to explore a live page across several turns.

Playwright MCP server setup

There is nothing to install beyond Node: npx @playwright/mcp@latest fetches and runs the server. Browsers are downloaded on first use.

No credentials are involved. The server drives a browser on your machine, so the sensitive input is the profile it uses rather than an API key.

Claude Code

No token appears here because the server needs none: it drives a local browser rather than calling a vendor API. --isolated keeps your logged-in state out of the session.

Terminal
claude mcp add-json "playwright" '{"command":"npx",
  "args":["@playwright/mcp@latest","--isolated"]}'

Cursor

In ~/.cursor/mcp.json. Again no credentials: authentication, if any, happens inside the browser session.

Terminal
{"mcpServers":{"playwright":{"command":"npx",
  "args":["@playwright/mcp@latest"]}}}

Codex CLI

Codex reads TOML, so the JSON blocks above will not transfer. It carries no credentials for the same reason as the others: the server drives a local browser, not a vendor API.

Terminal
[mcp_servers.playwright]
command = "npx"
args = ["@playwright/mcp@latest", "--isolated"]

Every other client

Each block below is the configuration for one client, with the file path and the key that client expects.

Claude Desktop

macOS ~/Library/Application Support/Claude/claude_desktop_config.json. Windows %APPDATA%\Claude\claude_desktop_config.json. There is no CLI. Edit through Settings, Developer, Edit Config.

Quit and restart fully for changes to load. Paths in args must be absolute. Logs at ~/Library/Logs/Claude/mcp.log.

No credentials appear in the file, and none exist. The server drives a local browser rather than a vendor API.

Terminal
{"mcpServers":{"playwright":{"command":"npx",
  "args":["@playwright/mcp@latest"]}}}
Gemini CLI

~/.gemini/settings.json globally, or .gemini/settings.json per project. Key mcpServers. CLI: gemini mcp add.

No credentials appear in the file, and none exist. The server drives a local browser rather than a vendor API.

Terminal
{"mcpServers":{"playwright":{"command":"npx",
  "args":["@playwright/mcp@latest"]}}}
VS Code Copilot

.vscode/mcp.json per workspace, or your user profile. CLI: code --add-mcp.

No credentials appear in the file, and none exist. The server drives a local browser rather than a vendor API.

Terminal
{"servers":{"playwright":{"command":"npx",
  "args":["@playwright/mcp@latest"]}}}

The key is `servers`, not `mcpServers`. VS Code is the only client that uses that name, and copying a config from anywhere else fails silently.

Windsurf

~/.codeium/windsurf/mcp_config.json, which is the path Windsurf documents. Key mcpServers, the same JSON shape as Cursor, with no credential in the file.

Zed

~/.config/zed/settings.json, with no credential in the file, as in the blocks above.

The key is `context_servers`. Zed does not call them MCP servers in config, so searching its settings for mcp finds nothing.

Google Antigravity

~/.gemini/config/mcp_config.json globally, or .agents/mcp_config.json per project. Key mcpServers. There is no CLI. Use the /mcp overlay in the editor. Supports stdio, streamable HTTP, SSE and websocket.

No credentials appear in the file, and none exist. The server drives a local browser rather than a vendor API.

Terminal
{"mcpServers":{"playwright":{"command":"npx",
  "args":["@playwright/mcp@latest"]}}}
Amp (Sourcegraph)

~/.config/amp/settings.json or .amp/settings.json, with no credential in the file. The amp mcp CLI covers approve, doctor and oauth.

The key is `amp.mcpServers`, namespaced. A bare mcpServers block is ignored.

Cline

~/.cline/mcp.json per the docs. The source also reads ~/.cline/data/settings/cline_mcp_settings.json. Key mcpServers, standard JSON shape, with no credential in the file. Supports stdio, streamable HTTP and SSE.

Goose (Block)

~/.config/goose/config.yaml, with no credential in the file.

YAML, and servers are called `extensions`. Goose does not use the MCP vocabulary in config at all. Add one interactively with goose configure, or per session with goose session --with-extension.

Kiro (AWS)

.kiro/settings/mcp.json per workspace, or ~/.kiro/settings/mcp.json globally. Key mcpServers, standard JSON shape, with no credential in the file.

Warp

~/.warp/.mcp.json or .warp/.mcp.json. Key mcpServers, standard shape, with no credential in the file. Also addable through the /agent-add-mcp skill.

JetBrains Junie

.junie/mcp/mcp.json per project, or ~/.junie/mcp/mcp.json. Key mcpServers, with no credential in the file. Use /mcp in the CLI to manage.

Roo Code

.roo/mcp.json per project. The global file is mcp_settings.json, opened from the Roo Code MCP settings view with Edit Global MCP. Key mcpServers, with no credential in the file.

Continue

.continue/mcpServers/*.yaml, one file per server, with no credential in the file.

YAML, and `mcpServers` is a list, not an object. Every JSON client keys servers by name. Continue takes an array, so a converted config will not parse.

Trae

.trae/mcp.json per project, or paste into the UI under Raw Config (JSON). Key mcpServers, standard shape, with no credential in the file.

Devin

Devin has no config file to edit. Servers are added through a web form in the settings UI, and Devin's documentation states you do not need to write or paste JSON. The block below is the shape those fields describe, shown for reference. Neither route uses credentials.

Docker

Runs the browser inside the container, which also contains browser_run_code_unsafe.

Terminal
docker run -i --rm --init mcr.microsoft.com/playwright/mcp
Headless with a saved login

The server itself needs no credentials. For a flow that has to be signed in, seed an isolated profile from a storage-state file rather than reusing your own browser profile. That file holds session cookies, so treat it as a secret.

Terminal
npx @playwright/mcp@latest --headless --isolated \
  --storage-state ./auth.json

Read-only access, permissions and security

  • One default tool is RCE-equivalent

    browser_run_code_unsafe executes arbitrary JavaScript in the Playwright server process, which is your machine. The description is Microsoft's own. Keep it off the allowlist.

  • The server marks only 7 of 24 tools read-only

    The remaining 17 carry no readOnlyHint. That is accurate: clicking, typing and navigating all change state somewhere.

  • The default profile is your logged-in state

    A persistent profile stores session cookies at a documented path. An agent driving that profile is acting as you, on whatever you are signed into.

  • --allowed-origins is not a boundary

    The documentation states plainly that it does not serve as a security boundary and does not affect redirects.

Troubleshooting

The browser will not start, or two clients conflict
A persistent profile can only be used by one browser instance at a time. Start additional clients with --isolated, or give each its own --user-data-dir.
The agent burns its context after a few clicks
browser_snapshot returns the full accessibility tree each time. Use browser_find, which returns matching nodes with a few lines of context instead.
The agent cannot read the screenshot it took
Screenshots are written to the output directory and the agent receives a path. Use the accessibility tree for the agent's own reasoning and the screenshot for a human.
A documented tool is missing
Some tools sit behind --caps, which accepts vision, pdf and devtools. The default set is 24 tools; the documented set is larger.
The browser is still running after the task
The session holds a real browser process between calls by design. Call browser_close, or run the server in a container.

Playwright MCP server: Reference

ItemValue
StatusRepository pushed 20 August 2026 · Apache 2.0
Adoption36,679 stars
Package@playwright/mcp, run with npx; Docker image also published
Transportstdio by default, with an HTTP mode available
AuthNone. The server drives a local browser rather than a vendor API
Tools24 by default · 7 marked read-only by the server · more behind --caps
Read-onlyNo server-side flag. Gate browser_run_code_unsafe in the client
ProfilePersistent by default; --isolated keeps it in memory

What engineers report

Playwright's MCP server is among the most starred in the ecosystem, so the useful signals are its own guidance and its tool economy.

What was checkedWhat it shows
Stars36,679
LicenseApache 2.0
Tools24, all on by default
Average description length68 characters per tool, among the shortest measured here
Vendor guidanceREADME points coding agents at Playwright CLI with Skills

“When using the browser_take_screenshot tool in Playwright MCP v0.0.47, the returned screenshot data causes a permanent conversation-breaking error in Claude Code.”

larbifattah, GitHub issue, 19 November 2025 · A tool result that broke the conversation rather than the tool, with 30 comments.

“Every time the AI calls playwright MCP, it always prompts a browser instance conflict problem. How should this problem be solved? Otherwise, this MCP cannot be used normally.”

578691200, GitHub issue, 26 July 2025 · Browser instance conflicts, and where the `--isolated` flag belongs.

Repository facts from the GitHub API, retrieved 21 August 2026. Tool counts and description lengths come from the server's own tools/list response on the published npm package.

Should you connect an agent to Playwright?

Yes. Best for interactive browser investigation. For a coding agent running tests in a repository, take Microsoft's advice and use the CLI.

Strongest fit
Agents doing exploratory browser work across several turns: reproducing a bug, walking a signup flow, checking what a user actually sees.
Main advantage
A real browser driven through structured page state, with unusually terse tool descriptions for its size.
Main weakness
Session cost. What the tools return dwarfs what they cost to register, and snapshots accumulate.
Operational risk
The browser process persists between calls and does not close on its own.

From Oodle

One platform for agent traces and infrastructure

Agent traces usually sit in a different product from the rest of your telemetry, so when a slow database makes an agent slow the symptom is in one tool and the cause is in another. Oodle keeps both in one query surface, from $10 per million spans.

See agent observability

Frequently asked questions

How many tools does the Playwright MCP server have?

24, all enabled on connection. Counted from the server's own tools/list response on the published npm package, 21 August 2026.

Why does Microsoft suggest using the CLI instead?

Token efficiency. The README states CLI invocations avoid loading large tool schemas and verbose accessibility trees into the model context, which matters for a coding agent balancing browser work against a codebase.

What does it actually cost to connect?

About 3,402 tokens for the tool definitions, under 2% of a 200,000-token window. The larger cost is what the tools return during a session, especially page snapshots.

Can the agent see a screenshot it takes?

No. Screenshots and PDFs are written to the server's output directory and the agent receives a path. Use the accessibility tree for the agent's own reasoning.

Does it run my existing test suite?

No. This server drives a browser interactively. Running a suite is the Playwright CLI's job.

Changelog

  • 6 August 2026. microsoft/playwright-mcp v0.0.79 released. v0.0.80 followed on 1 September 2026.
  • 28 March 2025. First release, v0.0.7.
  • 21 March 2025. microsoft/playwright-mcp created on GitHub.

Sources

Every number on this page traces to one of these

  1. Repository facts from the GitHub API · microsoft/playwright-mcp, retrieved 21 August 2026
  2. CLI guidance and its stated reasoning from the repository README
  3. Tool counts and description lengths from the server's own tools/list response on the published npm package

Playwright’s own MCP documentation

Also code, tests and review:

For what happens after the deploy: