Playwright CLI vs MCP: which browser tool fits?
Playwright CLI vs MCP comes down to shell access and how the agent should call the browser. Pick Playwright CLI if your coding agent has shell access and the task belongs beside your code. Pick Playwright MCP for structured browser tools; use Chrome DevTools MCP for Chrome diagnostics, or Vercel's agent-browser when a compact CLI and reusable Chrome profile suit the job.
The choice turns on what the agent needs to inspect, where its login state lives, and whether it can call a terminal or an MCP server. “MCP uses more tokens” is not enough to decide: the official docs checked October 2026 describe a design tradeoff, but don't publish a reproducible four-tool benchmark.
Playwright CLI vs MCP: what should you pick?
For a coding agent that can run commands, start with Playwright CLI. For a tool-calling agent that needs a persistent browser and structured page inspection, start with Playwright MCP.
The docs and defaults below were checked October 2026. Each table cell links to the project's own documentation; “none published” means I found no comparable token figure in the linked project docs.
| Tool and maintainer | Page model | Login and session | Install | Failure mode to plan for | Token-cost evidence | Best fit |
|---|---|---|---|---|---|---|
| Playwright CLI — Microsoft (CLI docs, checked October 2026) | Accessibility snapshot saved as a file; commands return the current page summary (CLI docs, checked October 2026) | Memory-only by default; --persistent keeps profile data across browser restarts (CLI docs, checked October 2026) |
npm install -g @playwright/cli@latest (install guide, checked October 2026) |
Closing the browser loses its in-memory profile unless you use --persistent (CLI docs, checked October 2026) |
Microsoft calls it token-efficient and says it avoids pushing page data into the model; no comparable published count (CLI docs, checked October 2026) | Coding agents, repeatable flows, or debugging a paused test (--debug=cli, then playwright-cli attach) (test-debugging docs, checked October 2026) |
| Playwright MCP — Microsoft (MCP docs, checked October 2026) | Structured accessibility tree with refs; snapshots and browser_find inspect the page (snapshot docs, checked October 2026) |
Persistent profile by default; isolated profiles or a browser extension for existing signed-in tabs (MCP docs, checked October 2026) | claude mcp add playwright npx @playwright/mcp@latest (MCP docs, checked October 2026) |
Two clients sharing one persistent profile conflict; isolated state is lost when that browser closes (MCP docs, checked October 2026) | Microsoft says CLI is more token-efficient for coding agents; no comparable published count (MCP docs, checked October 2026) | MCP clients, exploratory work, or reusing an existing Chrome/Edge login via extension (MCP docs, checked October 2026) |
| Chrome DevTools MCP — ChromeDevTools (project docs, checked October 2026) | Accessibility snapshot plus Chrome console, network, screenshots, and performance traces (project docs, checked October 2026) | Persistent Chrome profile by default; connect to a running debuggable browser or use --isolated (config docs, checked October 2026) |
npx -y chrome-devtools-mcp@latest (project docs, checked October 2026) |
Official support is Chrome and Chrome for Testing; usage statistics are enabled by default (project docs, checked October 2026) | No comparable token benchmark published in its docs (project docs, checked October 2026) | Debugging Chrome behavior, requests, console errors, or performance (project docs, checked October 2026) |
agent-browser — Vercel Labs (project docs, checked October 2026) |
Native Rust CLI; accessibility snapshots have @eN refs, and read can return rendered page text (project docs, checked October 2026) |
Reuse a Chrome profile with --profile; use a named session with --restore to retain login state (project docs, checked October 2026) |
npm install -g agent-browser then agent-browser install (project docs, checked October 2026) |
networkidle can hang on pages with WebSockets, polling, or long-lived requests (command docs, checked October 2026) |
No comparable token benchmark published in its docs; interactive-only snapshots can reduce what the agent reads (project docs, checked October 2026) | Text extraction, ad hoc browser work, or a CLI workflow that needs an existing Chrome profile (project docs, checked October 2026) |
The useful split is narrower than “CLI versus MCP.” If you're weighing agent-browser vs Playwright CLI, both are CLI-first, though agent-browser mcp also starts an MCP server over stdio. For Chrome DevTools MCP vs Playwright MCP, both are MCP servers, but only Chrome DevTools MCP specializes in Chrome's debugging data. Both Playwright tools document a browser extension for handing an existing tab and its login to the agent (playwright-cli attach --extension in the CLI docs).
What does the same task look like?
These docs-only examples open a login page, inspect its fields, fill test values, submit, then read console errors. First take a snapshot: refs such as e5 are page-specific, so replace them with the refs your page actually returns. Don't put a real password in an agent prompt or shell history.
Playwright CLI:
playwright-cli open https://example.com/login --headed
playwright-cli snapshot
playwright-cli fill e5 "$TEST_USER"
playwright-cli fill e6 "$TEST_PASSWORD"
playwright-cli click e7
playwright-cli console error
Playwright MCP:
browser_navigate { url: "https://example.com/login" }
browser_snapshot {}
browser_type { target: "e5", text: "TEST_USER" }
browser_type { target: "e6", text: "TEST_PASSWORD" }
browser_click { target: "e7" }
browser_console_messages { level: "error" }
Chrome DevTools MCP's bundled CLI:
chrome-devtools new_page "https://example.com/login"
chrome-devtools take_snapshot 1
chrome-devtools fill 1 "1_4" "$TEST_USER"
chrome-devtools fill 1 "1_5" "$TEST_PASSWORD"
chrome-devtools click 1 "1_6"
chrome-devtools list_console_messages 1 --types error
Vercel agent-browser:
agent-browser open https://example.com/login
agent-browser snapshot -i
agent-browser fill @e2 "$TEST_USER"
agent-browser fill @e3 "$TEST_PASSWORD"
agent-browser click @e4
agent-browser console # console messages, including errors
agent-browser errors # uncaught page errors
The exact tool-call forms for Playwright MCP and the Chrome DevTools CLI commands are in Microsoft's Playwright MCP guide (checked October 2026) and ChromeDevTools' CLI reference (checked October 2026). These are examples, not tested credentials or a claim that the selectors match a particular site's login page. For public pages with no interaction, agent-browser read https://example.com/article skips launching a browser and fetches readable text first (Vercel's agent-browser docs, checked October 2026).
Is Playwright CLI deprecated, and is Playwright MCP free?
No—the current Microsoft docs still document Playwright CLI for coding agents. The package is @playwright/cli; playwright-cli is the installed command name. To install Playwright CLI, use the current install guide (checked October 2026), not an older similarly named package.
The Playwright MCP install instructions don't list a per-call server price. Your MCP client or model provider may bill separately; check its current pricing for the account you use. The official docs' token-efficiency language is qualitative, not a promise that CLI costs less for every task. Snapshots read into context, outputs saved to disk, and the model's tool-call behavior all affect the total.
Measure your own workflow in three steps:
- Fix the same page, test account state, agent, model, task, and tool versions. Use a non-production test account and the same browser start state.
- Run each tool five times. Record total input and output tokens, elapsed time, tool calls, and whether the task completed correctly; include setup/schema tokens separately from task tokens.
- Compare medians, not the best run. Report tokens per successful task and cost using your provider's current rates. Keep the task transcript with the result so another developer can repeat it.
Which tool fits each browser job?
- Create or debug E2E tests: Playwright CLI. It's built for coding agents and can record browser actions as Playwright code; install it with
npm install -g @playwright/cli@latest. If the goal is simply to execute a stable regression suite in CI, write and run a normal Playwright Test rather than asking an agent to rediscover the flow. - Scrape readable public text: Vercel's
agent-browser. Start withagent-browser read https://example.com/article; useopenplus an accessibility snapshot when the page needs JavaScript interaction. Install withnpm install -g agent-browserandagent-browser install. - Debug a Chrome page: Chrome DevTools MCP. It exposes console messages, network requests, screenshots, and performance tracing; install with
npx -y chrome-devtools-mcp@latest. It supports Chrome and Chrome for Testing officially, and the docs say usage statistics are on by default. Add--no-usage-statisticsif you want to turn them off. - Act in a logged-in Chrome or Edge tab: the Playwright MCP extension. The extension attaches the agent to an existing tab and browser state. Start the server with the
--extensionoption (for examplenpx @playwright/mcp@latest --extension), then follow the extension setup instructions (checked October 2026). For an isolated E2E profile, use--isolatedand provide saved storage state instead.
One more option: connect the agent to your browser
If the job is to act on the page open in a local browser, Octoweb has an MCP server at http://localhost:3434/mcp that starts with the browser. It exposes 31 tools, can work in background tabs, routes calls to workspaces, and fences page content as <untrusted>. I build Octoweb, so weigh that accordingly. The tradeoff is that any local process can reach its loopback server and read page content and history; don't treat localhost as an access-control boundary. The MCP post shows client setup, and WebMCP vs MCP explains the page-exposed protocol.
For client configuration and the available tools, see the browser MCP server reference.
Octoweb is free and open source, for macOS.
Install it →