How Playwright positions them
A lets a coding agent that can execute shell commands work with a browser through compact commands. presents browser capabilities as structured tools to an , which suits loops that repeatedly inspect, act, and reason about a page.
Playwright names Claude Code and Copilot among the target scenarios for its CLI. For a Codex workflow with direct shell access, trying the CLI first is our editorial recommendation based on that working model. It is not a claim that Playwright specifically requires Codex users to choose the CLI.
Sources: Playwright Coding Agents documentation and Playwright MCP positioning.
The core comparison
Start with the task you need to complete, then choose the interface that fits it.
Swipe horizontally to compare both options →
| What matters | Playwright CLI | Playwright MCP |
|---|---|---|
| Best fit | Coding agents | Specialized agent loops / exploratory automation |
| Interface | Shell commands | MCP tools |
| Context / tokens | Relatively lower | Relatively higher |
| Tool schema | No large MCP schema kept loaded | MCP tool schema enters context |
| Skills | Supports optional Skills | Skills are not the primary interface |
| Default browser mode | Headless | Headed |
| Page understanding | Accessibility snapshots | Accessibility snapshots |
| Browser state | Persistent daemon / sessions | Persistent profile / session |
| Setup | Install an npm CLI | Configure an MCP client |
| Coding agents | More natural | Use when needed |
| Unfamiliar-site exploration | Capable | Better suited |
| Requires an MCP client | No | Yes |
Qualitative comparison of documented workflows. No token benchmark or universal compatibility claim.
"Relatively lower" does not mean zero context use. The CLI still returns command output and page snapshots.
The workflow, default mode, and context distinctions follow Playwright's official MCP and CLI comparison. Session, Skill, and command details come from the CLI documentation.
How the CLI works
Playwright CLI lets an agent run commands directly. For example, it can open a page and then request a snapshot:
playwright-cli open https://example.com
playwright-cli snapshotInteraction commands can look like this:
playwright-cli click e15
playwright-cli type "hello"
playwright-cli screenshotAfter an operation, the CLI can return the current page state and accessibility snapshot. The agent can then use an element reference from that snapshot for the next step.
Source: Playwright element targeting.
Why the CLI fits coding agents
1. They already use the shell
Coding agents routinely work with npm, git, test, build, lint, and other CLI tools. Browser automation through commands fits the same development loop.
2. Tool definitions stay lighter
The model does not need a large MCP tool schema exposed throughout the session. Browser commands and their output can remain relatively compact.
3. Skills can be loaded when needed
Playwright CLI can install Skills:
playwright-cli install --skillsA coding agent can use those Skills for richer command guidance without permanently carrying the full MCP tool definition.
4. The browser process can persist
CLI does not mean restarting the browser for every command. Playwright CLI uses a persistent browser process and supports sessions, so several actions can continue in the same session.
Sources: CLI Skills and CLI sessions.
How MCP works
Playwright MCP runs an MCP server. A compatible AI client can see structured tools such as:
browser_navigatebrowser_snapshotbrowser_clickbrowser_hover
The agent calls them with structured parameters instead of composing each shell command itself.
Source: Playwright MCP tools.
Why MCP still matters
1. Exploring unfamiliar pages
When an agent does not know the page structure in advance, MCP suits a repeated observe-and-act loop:
Open the page
↓
Read a snapshot
↓
Choose the next action
↓
Click
↓
Read another snapshot
↓
Continue reasoning2. Persistent agent loops
Structured tool calls feel natural when an agent needs to browse for a long time, repeatedly inspect page structure, and keep browser state available.
3. A consistent MCP client experience
Users who already manage GitHub, Notion, databases, and browsers through MCP may prefer one tool interface across those services.
4. Structured tool calling
The agent receives explicit browser tools and parameter definitions rather than deciding which shell command to construct.
The official README still highlights exploratory automation and persistent agent loops. MCP has not become obsolete because another interface exists.
Why everyone talks about tokens
A is a unit a model processes. is the information available to the model while it works on the current task.
With MCP, the model may need descriptions of the available tools, their parameters, and how to call them. Browser interaction also returns page snapshots. All of that can use context.
The CLI uses compact commands and can provide extra guidance through a Skill only when needed. Playwright's official comparison therefore describes the CLI's token cost as relatively lower.
That does not mean the CLI uses no context. It also does not justify applying one percentage to different clients, tasks, and loading strategies. We provide no token benchmark.
One registration test, two interfaces
MCP: communicate through structured tools
Call browser_navigate
↓
Read a snapshot
↓
Call browser_click
↓
Fill in the form
↓
Read another snapshot
↓
Evaluate the result"Fill in the form" is a workflow step here, not a claim that a fixed tool called browser_fill exists. This diagram explains the interaction model; it is not executable test code.
CLI: communicate through commands
Run a CLI command
↓
Read the returned snapshot
↓
Run the next command
↓
Check the resultBoth paths may accomplish the browser task. The main difference is how the AI communicates with the browser.
If you use Codex
Everyday web development, QA, and testing
Try Playwright CLI first.
Codex is a coding agent that can run commands, edit code, and use development tools. Playwright positions the CLI for coding agents, and that interface often fits a Codex workflow with direct shell access.
This is editorial advice based on the workflow, not a claim that Playwright officially mandates the CLI for Codex.
Long exploratory sessions
Consider Playwright MCP, especially when the agent must repeatedly observe a page, reason about its structure, and continue interacting.
An established MCP workflow
Do not migrate merely because the CLI exists. First check whether your current setup causes a real problem.
If you use Claude Code
The Playwright Coding Agents documentation explicitly includes Claude Code among the CLI's target scenarios.
- Everyday coding: consider the CLI first.
- Exploratory automation: use MCP when needed.
The same person can use different interfaces for different tasks. This does not need to be a permanent either-or choice.
Should you remove an existing MCP setup?
Not necessarily.
Keep it if it is reliable, you use it often, context overhead is not a practical issue, and the workflow depends on MCP tools.
Try the CLI if you rarely call the server, mostly run web tests, already have shell access, and want fewer MCP integrations.
Less, but better. Every tool you keep should have a clear job.
Install Playwright CLI
These are the verified official commands. This website does not run them.
Install globally
npm install -g @playwright/cli@latestView help:
playwright-cli --helpInstall Skills:
playwright-cli install --skillsAdd it as a development dependency
npm install -D @playwright/cli@latestThen:
npx playwright-cli --helpSource: Playwright CLI installation.
Try the CLI once
Open Playwright's TodoMVC demo in a visible browser:
playwright-cli open https://demo.playwright.dev/todomvc/ --headedThen take a screenshot:
playwright-cli screenshotThis is a minimal example, not a complete test flow or a claim that we ran it during this localization.
Source: Playwright manual walkthrough.
Their default modes differ
Playwright CLI is headless by default. To see the browser window:
playwright-cli open https://example.com --headedPlaywright MCP is headed by default, so it shows a browser window.
Source: Playwright's default-mode comparison.
What they share
Both are based on Playwright. Both can operate browsers, use structured accessibility information, support major browsers, take screenshots, and retain browser state in some form.
Both target AI and agent automation. Their main difference is the interface and intended workflow, not whether one has browser capabilities and the other does not.
Common misconceptions
Is the CLI a "lightweight MCP"?
No. It is a different agent interface, not a reduced MCP implementation.
Does the CLI make MCP useless?
No. They target different workflows, and exploratory agent loops remain a strong use case for MCP.
Is MCP always a huge waste of tokens?
That is an oversimplification. Client behavior, tool-loading strategy, and task shape all affect context use. Playwright describes the CLI as relatively token-efficient, not as a universal percentage advantage.
Does every CLI command restart the browser?
No. Playwright CLI uses a persistent browser process and supports sessions.
Decide in 30 seconds
Start with the first question. Continue only when the answer says to move on.
- 01
Can your AI run shell commands?
Yes YESNext questionNo NOPlaywright MCP - 02
Is the main job web development or testing inside a large codebase?
Yes YESPlaywright CLINo NONext question - 03
Does the AI frequently explore unfamiliar pages over many steps?
Yes YESPlaywright MCPNo NOTry Playwright CLI first
This is a quick recommendation, not an absolute rule. MCP requires a compatible client, and an existing workflow that already works does not need a forced migration.
What to read next
For the installation boundaries and removal steps, read Is Playwright MCP worth installing?.
For a broader setup decision, see A minimal Codex setup for web development or How to add an MCP server to Codex.
If the terminology is unfamiliar, start with MCP, CLI, agent, context, and token.
Related terms
Continue with these published explanations.
Sources & last checked
Checked against official documentation. Editorial recommendations are distinguished from vendor positioning; no runtime benchmark was performed.
Official documentation
01Last checked: September 3, 2026
official-docs