Run End-to-End Tests from Your Terminal with Kane CLI
Author and Run Tests Right from the Terminal in Natural Language, with an Evidence-Backed Pass or Fail from a Real Browser.
npm install -g @testmuai/kane-cli
Playwright MCP: Setup, Tools, Limits and Alternatives
Playwright MCP is Microsoft's MCP server that lets AI agents drive a browser through accessibility snapshots. Setup, tools, limits, safety and alternatives.
Last Updated on:
Playwright MCP is Microsoft's Model Context Protocol (MCP) server that lets an AI client such as Claude Code, Cursor, Codex or GitHub Copilot drive a real browser through Playwright. By default it reads each page as an accessibility snapshot, a text tree with a reference for every element, so the model needs no screenshots or vision model. The agent acts by calling tools such as browser_navigate, browser_click and browser_snapshot.
Playwright MCP suits exploring an app, reproducing a bug and drafting Playwright tests. The agent still decides whether its own run worked, so a release gate needs a separate pass or fail check. The setup commands, tool names and flags below were checked against Microsoft's README and the playwright.dev docs in November 2026.
Overview
Playwright MCP is an open source MCP server from Microsoft, published on npm as @playwright/mcp, that gives an AI agent a real browser. The agent reads each page as an accessibility snapshot and passes element references to tools such as browser_click, so it works on structured text rather than pixels.
What Tools Does Playwright MCP Have?
- Core tools: Playwright MCP turns on its core tools by default, including browser_navigate, browser_snapshot, browser_click and browser_type, plus tools for forms, screenshots, dialogs, console messages and network requests.
- Opt-in capabilities: The Playwright MCP --caps flag adds tool groups that are off by default, such as testing for assertions and locator generation, network for request mocking and vision for clicks at screen coordinates.
What Can Playwright MCP Not Do for Test Authoring?
- Pass or fail verdicts: Playwright MCP has no fixed pass or fail rule of its own. The agent judges each run from the snapshots it read, which helps while debugging but is weak evidence for a release decision.
- Repeatable runs: Each new Playwright MCP session re-reads the pages and plans the flow again, so reruns get neither cheaper nor more consistent. Reviewed Playwright test code replays the same steps every time.
- Release checks: For a verdict the Playwright MCP agent does not decide, TestMu AI's Kane CLI checks a plain-English flow against criteria you write and returns exit code 0 for a pass and 1 for a failure, which a CI pipeline can act on.
What Is Playwright MCP?
Playwright MCP is a Model Context Protocol server, built by Microsoft's Playwright team and published on npm as @playwright/mcp, that exposes a real browser to an AI agent as a set of tools. The protocol and the server are separate things:
- MCP (Model Context Protocol) - an open protocol that lets AI apps call external tools in a standard way. Anthropic open-sourced MCP in November 2024 and donated it to the Linux Foundation's Agentic AI Foundation in December 2025.
- Playwright MCP - one MCP server, which drives Google Chrome by default and also supports Firefox, WebKit and Microsoft Edge (as of October 2026).
For a quick visual walkthrough of this concept, watch the video below from TestMu AI.
Subscribe to the TestMu AI YouTube channel for more tutorials on testing and automation.
When the agent asks to see a page, Playwright MCP returns an accessibility snapshot: a text tree of the page's elements, each with a reference such as e5. The model passes that reference as the target of a tool call, and most tools return a fresh snapshot after each action. This excerpt from the playwright.dev install guide shows a snapshot and the call that types into its textbox:
- heading "todos" [level=1] [ref=e3]
- textbox "What needs to be done?" [ref=e5]
browser_type {
target: "e5", text: "Buy groceries", submit: true
}Microsoft's docs rate snapshots more reliable and token-efficient than screenshots for most web apps. Vision mode (--caps=vision) adds coordinate-based mouse tools for canvas and other content the accessibility tree misses, and needs a vision-capable model.
Should You Use Playwright MCP?
Use Playwright MCP when you want a coding agent to look at and work with a running app while you build it. Skip it as the check that gates releases, because the agent decides whether its own run passed.
| Good fit | Poor fit |
|---|---|
| "Open localhost and tell me why the signup button does nothing" | A regression suite that runs on every pull request |
| Reproducing a bug from a ticket, step by step | Anything where the agent's own opinion decides pass or fail |
| Drafting Playwright test code you'll review | Canvas-heavy apps, maps, games and custom widgets |
| Checking a UI change before you commit | Running many logged-in sessions in parallel from one profile |
| Scraping a page you have rights to, once | Untrusted pages while the browser is signed in to things that matter |
How Do You Set Up Playwright MCP?
Add one server to your MCP client, with npx as the command and @playwright/mcp@latest as the argument. You need Node.js 18 or newer (the playwright.dev install guide lists 20, the safer pick), and the browser downloads automatically on first use.
Set Up Playwright MCP for Claude Code
claude mcp add playwright npx @playwright/mcp@latestGenerating, debugging and refactoring Playwright tests from Claude Code is covered in Using Playwright With Claude Code.
Set Up Playwright MCP for OpenAI Codex
codex mcp add playwright npx "@playwright/mcp@latest"Per-repository config, OAuth sign-in and tool approvals in Codex are covered in Codex MCP.
Set Up Playwright MCP for VS Code (GitHub Copilot)
code --add-mcp '{"name":"playwright","command":"npx","args":["@playwright/mcp@latest"]}'Set Up Playwright MCP for Cursor
Open Cursor Settings, go to MCP and choose Add new MCP Server, then pick the command type and enter npx @playwright/mcp@latest. Project-level config, tool approvals and connection fixes are covered in Cursor MCP.
Set Up Playwright MCP in Other MCP Clients
Windsurf, Claude Desktop, Gemini CLI, Kiro, LM Studio and Warp take this standard config. Cline, Copilot CLI, Junie and opencode wrap the same command in their own fields (the README covers each).
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": ["@playwright/mcp@latest"]
}
}
}Playwright MCP Flags Worth Knowing
Add flags to args after the package name. These are the most useful for testing work, per the README as of November 2026.
| Flag | What it does | When to use it |
|---|---|---|
--headless | No visible window (headed is the default) | Remote machines, CI, or when you don't need to watch |
--isolated | Keeps the profile in memory, so closing the browser discards it | Every session where you don't need to stay logged in |
--browser chrome| | Picks the browser; Google Chrome is the default | Checking the WebKit engine that Safari uses |
--storage-state <file> | Loads cookies and local storage into an isolated session | Starting already logged in, without a persistent profile |
--caps testing, | Turns on opt-in tool groups | Assertions, mocking requests, managing cookies |
--device "iPhone 15" | Emulates a device | Quick mobile-layout checks |
--snapshot-mode none | Stops tools from attaching a snapshot to every response | Long flows where the agent snapshots only when needed |
--extension | Attaches to your running Chrome or Edge via the Playwright extension | Reusing signed-in tabs, with the safety rules below |
--port 8931 | Serves over HTTP at http://localhost:8931/mcp instead of stdio | Sharing one server, or a headed browser on a machine without a display |
A sensible default for daily work is --isolated --caps=testing: a clean profile in every session plus the assertion tools.
What Tools Does Playwright MCP Have?
Playwright MCP turns on its core tools by default, and the --caps flag adds the rest. The table groups them by job, from Microsoft's Playwright MCP README for @playwright/mcp 0.0.85, the npm release of November 9, 2026.
| Job | Tools | Needs --caps |
|---|---|---|
| Look at the page | browser_snapshot, browser_find, browser_take_screenshot | No |
| Move around | browser_navigate, browser_navigate_back, browser_tabs, browser_wait_for, browser_close | No |
| Change the viewport | browser_resize, plus browser_emulate_media for CSS media features such as the light or dark color scheme | No |
| Interact | browser_click, browser_type, browser_fill_form, browser_select_option, browser_hover, browser_drag, browser_drop, browser_press_key, browser_file_upload, browser_handle_dialog | No |
| Debug | browser_console_messages, browser_network_requests, browser_network_request, browser_evaluate, browser_run_code_unsafe | No |
| Assert | browser_verify_element_visible, browser_verify_text_visible, browser_verify_list_visible, browser_verify_value, browser_generate_locator | testing |
| Mock the network | browser_route, browser_route_list, browser_unroute, browser_network_state_set | network |
| Manage state | cookie, localStorage and sessionStorage tools, plus browser_storage_state and browser_set_storage_state | storage |
| Record | tracing, video, action recording, highlight and annotation tools | devtools |
| Click by coordinates | browser_mouse_click_xy and other x/y mouse tools | vision |
| Save as PDF | browser_pdf_save | pdf |
| Read the settings | browser_get_config, which returns the config after flags, environment variables and the config file are merged | config |
Tool names change between releases. If a prompt names a tool that doesn't exist, run /mcp in Claude Code to see the live list.
Which Prompts Work Best With Playwright MCP?
Prompts that name the URL, the steps and what "correct" looks like work best. Vague prompts add turns, and every turn re-sends the snapshots already in context.
Reproduce a bug
Open http://localhost:3000/invoices. Create an invoice for "Acme Ltd" with two line items, $120 and $80. Apply a 10% discount. Tell me the total shown, and paste any console errors.
Check your own change
I just changed the date picker on /bookings. Open it, pick next Friday, submit, and confirm the confirmation page shows the same date. Take a screenshot of the confirmation.
Find out why something is slow
Load /dashboard and list every network request that takes longer than 1 second, with its URL and status.
Test an error path with mocking (needs --caps network)
Make requests to /api/orders return a 500. Load /orders and tell me exactly what the user sees.
Draft a test you will review
Walk through password reset on staging, then write a Playwright test in TypeScript for that flow using role-based locators. Don't run it, I'll review it.
Where Does Playwright MCP Fall Short?
Its biggest gaps are token cost and an agent that grades its own work. Reruns, parallel sessions, canvas-heavy pages and security add smaller ones.
1. It's token-heavy. Every snapshot of a busy page enters the context, and the whole conversation is re-sent each turn. In Slack Engineering's June 2026 experiments, one search flow through Playwright MCP used about 3.5 million tokens with Claude Sonnet 4.5 and 3.8 million with Claude Opus 4.6, and agent-driven runs typically cost $15 to $30 each. Microsoft's README recommends Playwright CLI as more token-efficient for coding agents, yet in Slack's same flow the CLI used about 6 million tokens on Opus 4.6, so measure on your own flows.
2. The agent grades its own work. When the run ends, the model tells you whether it worked. That helps while you develop, but it is weak evidence for a release decision.
3. Every rerun starts from scratch. The agent re-reads and re-plans the same flow each time, so the second run is no faster or cheaper than the first. Slack also found that most action sequences differed from run to run, even when the final outcome was correct.
4. One browser per profile. A persistent profile can be used by only one browser at a time, so parallel clients need --isolated or separate --user-data-dir values.
5. The accessibility tree has blind spots. Canvas, WebGL, maps, charts and widgets without ARIA roles show up poorly or not at all, which leaves vision mode and coordinate clicks.
6. It isn't a security boundary. Microsoft says so in the README's Security section.
Which browser build Playwright MCP launches, and when its Chromium sandbox is on, is covered in Playwright sandbox for AI agents.
Is Playwright MCP Safe to Use?
Playwright MCP is as safe as the browser profile and machine you give it, because Microsoft states that it is not a security boundary. These rules cut the risk:
- Use
--isolatedby default - a persistent profile means the agent is signed in to whatever you were signed in to. - Keep it off untrusted sites while logged in - text on a page can contain instructions aimed at the model. This is prompt injection, and the browser can't tell the difference.
- Load a test account, not your own login - pass
--storage-statewith a file from a test account, and keep secrets out of prompts. - Redact tokens in URLs -
--redact-url-params access_token,codereplaces the values of those query and fragment parameters with<redacted>in tool responses, so tokens from sign-in redirects never reach the model. - Review code before it runs -
browser_evaluateruns JavaScript in the page, andbrowser_run_code_unsaferuns Playwright code in the server process on your machine, which the README calls RCE-equivalent. - Treat origin lists as a filter only -
--allowed-originsand--blocked-originslimit browser requests, but the README says they are not a security boundary and do not affect redirects. - Point it at staging - use production only for read-only tasks.
How Much Does Playwright MCP Cost to Run?
The server is free and open source under the Apache-2.0 license, so you pay only for model tokens. Snapshot size, the number of turns and the model drive the bill, and these levers from Microsoft's docs cut it:
- Write specific prompts and start on the exact URL, so the agent takes fewer turns.
- Use
browser_findto locate an element; the README calls it cheaper than a whole snapshot. - Limit
browser_snapshotwith itsdepthortargetparameters, or set--snapshot-mode none. - Enable only the
--capsyou need: the capabilities docs note that fewer tools mean a smaller tool schema. - Try
--mobilewhen layout doesn't matter; the README notes that mobile pages are usually lighter. - Close sessions when you're done, since long sessions keep re-sending old snapshots.
How Does Playwright MCP Compare With Other Browser Tools for Agents?
Playwright CLI is the closest alternative: the same Playwright automation from Microsoft, driven through shell commands instead of MCP tool calls. The full decision, with Kane CLI added, is in Playwright CLI vs MCP vs Kane CLI.
| Playwright MCP | Playwright CLI | |
|---|---|---|
| How the agent drives it | MCP tool calls such as browser_click | Shell commands such as playwright-cli click e21 |
| Where snapshots go | Into the tool response, so into the model's context | Into a .yml file the agent opens only when it needs it |
| Setup | Add one server to your MCP client | npm install -g @playwright/cli@latest, then playwright-cli install --skills |
| Browser window | Headed by default | Headless by default |
| Microsoft's pick for | Exploratory automation, self-healing tests and long-running workflows that need a continuous browser context | Coding agents that share a limited context window with a large codebase |
| Who decides pass/fail | The agent | The agent |
Chrome DevTools MCP, from Google's Chrome DevTools team, is the pick when the job is debugging or performance analysis in Chrome rather than driving a flow. The roundup of Playwright MCP alternatives compares it with Kane CLI, mobile and Selenium-based servers and other options.
How Do Playwright's Test Agents Relate to Playwright MCP?
Playwright's test agents are a planner, a generator and a healer whose definitions combine instructions with MCP tools, and they leave you with Playwright test code you own. Install them with npx playwright init-agents --loop=claude (the other loops are vscode, codex and opencode), and regenerate them whenever you update Playwright, as the Playwright test agents docs advise. The Playwright 1.65 release guide covers what else to check when you update.
The planner explores your app and writes a test plan, the generator turns the plan into Playwright tests, and the healer runs the suite and repairs failing tests. The hands-on guide to Playwright agents covers each one, and AI and Playwright MCP follows one agent workflow from a Jira ticket to a self-healing test run.
Where Does Kane CLI Fit With Playwright MCP?
The difference between Playwright MCP and Kane CLI is who decides: Playwright MCP hands the agent browser snapshots and leaves the judgment to the model; Kane CLI runs the objective itself and hands the agent a verdict. Use Playwright MCP to explore and debug, and Kane CLI from TestMu AI when you need a pass or fail verdict that the agent does not decide.
Before you ship, you need a result that runs the same way in CI and leaves evidence someone else can check. Kane CLI is built for that: you describe the flow in plain English, it drives a real Chrome, checks the outcome against your criteria and returns a typed result. Kane CLI is free to install; every run, local runs included, uses KaneAI credits, and you can claim 10,000 free credits, valid for 30 days.
npm install -g @testmuai/kane-cli
kane-cli run "Create an invoice for Acme Ltd with items of 120 and 80, \
apply a 10% discount, and verify the total shows 180.00" \
--url http://localhost:3000/invoices --agent --headless \
| tail -1 | jq '{status, one_liner, test_url}'The agent gets one line back instead of a stack of page snapshots. Exit code 0 is a pass, 1 a failed assertion, 2 an environment error such as a failed login or a Chrome crash, and 3 a timeout.
A workflow that uses both:
- Explore with Playwright MCP. Ask your agent to reproduce the bug and find the cause.
- Fix the code.
- Verify with Kane CLI. Your agent runs
kane-cli run "..." --agentand only says "done" on exit code 0. To enforce that rule with a hook, see how to add testing to AI coding tools. - Keep it. Save the flow as a
_test.mdfile.kane-cli testrun run --parallel 4replays saved tests on every pull request, and autoheal finds elements again when the UI moves them.
If your agent builds from a written spec, the comparison of spec-driven development tools shows where a verification step like step 3 fits in each one.
To let your coding agent call Kane CLI on its own, install the skill once:
npx @testmuai/kane-cli-skillIt works with Claude Code, Codex CLI and Gemini CLI. How Codex discovers and triggers an installed skill is covered in Codex skills. Pull requests from always-on agents such as OpenAI Dots arrive tested by the agent that wrote them, so they still need a verdict that agent does not decide.
Can Playwright MCP Run in CI?
Yes, with --headless or Microsoft's Docker image (mcr.microsoft.com/playwright/mcp, headless Chromium only as of October 2026), but an open-ended agent session makes a poor CI gate. A CI step needs a fixed pass or fail rule, a time limit and a cost you can predict, and an agent session guarantees none of them. Use Playwright MCP while developing. In CI, run Playwright test code or a verifier with exit codes, such as Kane CLI.
To run agent-written tests across real browsers and operating systems, see scaling agentic Playwright tests on a cloud grid.
Author
Srinivasan Sekar is Director of Engineering at TestMu AI, where he leads engineering and open-source initiatives behind the Selenium and Appium automation grid and owns TestMu AI's MCP Server. A committer to Appium and a contributor to Selenium, WebdriverIO, Taiko, and AppiumTestDistribution, he brings over 15 years of experience in quality engineering and open-source technologies. He is the author of the Apress book 'The MCP Standard: A Developer's Guide to Building Universal AI Tools with the Model Context Protocol,' a Certified Kubernetes and Cloud Native Associate, and an international conference speaker. Before TestMu AI he spent over eight years at Thoughtworks as a Principal Consultant and Quality Architect. Srinivasan holds a B.Tech in Information Technology from Anna University.
Reviewer
Sai Krishna is Director of Engineering at TestMu AI, where he leads agentic AI for quality engineering, building AI agents that autonomously drive mobile and conversational test automation. His current focus is Agent Testing and Model Context Protocol (MCP) support for mobile. He is a core contributor and member of the Appium open-source project and the creator of AppiumTestDistribution and appium-device-farm. With over 14 years of experience including more than 9 years at Thoughtworks as a Principal Consultant, he holds a BSc in Electronics and speaks regularly at TestMu and Appium Conf on Appium, mobile automation, and agentic AI in testing.
Playwright MCP FAQs
Did you find this page helpful?
More Related Blogs
TestMu AI forEnterprise
Get access to solutions built on Enterprise
grade security, privacy, & compliance
- Advanced access controls
- Advanced data retention rules
- Advanced Local Testing
- Premium Support options
- Early access to beta features
- Private Slack Channel
- Unlimited Manual Accessibility DevTools Tests















