Pick a server by job
Playwright MCP vs Playwright CLI for a coding agent that reads pages
What changes when a coding agent reads public pages through Playwright CLI and skills instead of Playwright MCP: snapshots, sessions, defaults and setup.
By Shannon Mcbride, MCPScraper team · Published
This article was drafted with AI assistance from the sources listed below and edited and published by the MCPScraper team. Disclosure: the MCPScraper API, which this article mentions, is this site's own product.
| Criterion | Playwright MCP | Playwright CLI |
|---|---|---|
| Snapshot | In the response by default (--snapshot-mode full) | Written to a YAML file, linked in the output |
| Browser | Headed by default, --headless to change | Headless by default, --headed on open |
| Profile | Persistent by default, --isolated keeps it in memory | In memory by default, --persistent saves it |
| Requirement | Node.js 18 or newer | Node.js 20 or newer |
A coding agent that needs to read a public docs page can reach Playwright two ways: as an MCP server with browser tools, or as a command-line tool it runs from its shell. Both drive the same browser automation library. They differ in what lands in the model's context, which defaults apply and how much setup each takes.
The job here is narrow: open a known public page and read it. Test automation, form flows and self-healing tests are a different job. All values below were checked on 2026-11-16 against each project's own docs. Both tools ship often; recheck before relying on a default.
What the Playwright docs say
The Playwright MCP README answers the question itself: "If you are using a coding agent, you might benefit from using the CLI+SKILLS instead."
The Playwright CLI README gives the reason. It says "CLI invocations are more token-efficient" because they avoid "loading large tool schemas and verbose accessibility trees into the model context". It keeps a place for MCP: "MCP remains relevant for specialized agentic loops that benefit from persistent state", along with rich introspection and iterative reasoning over page structure.
For a coding agent that only reads pages, the project's own guidance points to the CLI.
Documented defaults, side by side
| Point | Playwright MCP | Playwright CLI |
|---|---|---|
| Interface | MCP server, tools such as browser_navigate and browser_snapshot | Shell commands such as playwright-cli goto <url> and playwright-cli snapshot |
| Snapshot after an action | In the response; --snapshot-mode is full or none, default full | Written to a timestamped YAML file in .playwright-cli/; the output links to it |
| Browser mode | Headed by default; --headless to change | Headless by default; --headed on open |
| Profile | Persistent profile by default; --isolated keeps it in memory | In memory by default; --persistent saves it to disk |
| Requirement | Node.js 18 or newer | Node.js 20 or newer |
The table compares two interfaces of one open-source project. It is not a ranking. Each row comes from the docs of that interface.
Where the snapshot goes
This row matters most for reading pages.
Playwright MCP. The --snapshot-mode option sets how snapshots are taken for responses: full (the default) or none. The browser_snapshot tool has a filename parameter that will "Save snapshot to a file instead of returning it in the response", and a depth parameter to "Limit the depth of the snapshot tree".
Playwright CLI. "After each command, playwright-cli provides a snapshot of the current browser state." The snapshots page describes it as an accessibility tree with element refs for interaction, saved to a file. The page suggests --depth on complex pages to reduce output size, and a snapshot can be scoped to a CSS selector or an element ref. Refs stay valid until the next page change, so a new page needs a new snapshot.
Commands for a read-only session
npm install -g @playwright/cli@latest
playwright-cli install --skills
playwright-cli open https://example.com
playwright-cli snapshot --filename=example.yml
playwright-cli close-all
install --skills copies the skill to .claude/skills/playwright-cli in the current workspace, per the skills page. --skills=agents uses the .agents/skills layout, and -g installs into the home directory for every project. The skill gives the agent reference documentation for the commands; the agent then runs them from its shell.
The global --raw option strips page status and generated code from the output and keeps the result, errors and the snapshot or its file link. A headless CLI session shuts down on its own after an hour without commands. Headed browsers stay open.
Session state
The two defaults run opposite ways. Playwright MCP starts with a persistent profile, stored per channel and workspace under the ms-playwright cache folder. Playwright CLI "keeps the browser profile in memory by default": cookies and storage carry over between calls within a session and are lost when the browser closes.
For reading public pages, no stored login is needed. An in-memory profile keeps cookies from one task out of the next. On Playwright MCP, --isolated gives the same behavior: each session starts in an isolated profile, and its storage state is lost when the browser closes.
Picking one for the job
- Coding agent, reading known public pages: Playwright CLI with skills, as the Playwright docs suggest. Snapshots are written to files and linked in the output.
- Agent loop that reasons over page structure across many steps: Playwright MCP, per the scope the CLI README gives MCP.
- Client without a shell: MCP is the only one of the two that applies.
Both are browser-control tools. For the plain job of reading one public page, a page reader is a separate category. MCPScraper API is this site's own page reader; the MCP server registers 2 tools, listed in the MCP docs. Tool counts of open-source browser servers are in Too many MCP tools in the context window, and Playwright MCP is set against Chrome DevTools MCP in Chrome DevTools MCP vs Playwright MCP for reading pages.
Whichever interface runs the browser, read only public pages, and check robots.txt, the site's terms and any acceptable-use policy first.
Frequently asked questions
Does Playwright recommend the CLI or MCP for coding agents?
The Playwright MCP README says: "If you are using a coding agent, you might benefit from using the CLI+SKILLS instead." The Playwright CLI README keeps MCP for specialized agentic loops that benefit from persistent state, rich introspection and iterative reasoning over page structure.
Why is Playwright CLI described as more token-efficient than Playwright MCP?
The Playwright CLI README says CLI invocations avoid loading large tool schemas and verbose accessibility trees into the model context. The CLI writes each snapshot to a file and returns a link to it.
How do I install the Playwright CLI skills for Claude Code?
Install the CLI with npm install -g @playwright/cli@latest, then run playwright-cli install --skills. The skill is copied to .claude/skills/playwright-cli in the current workspace; --skills=agents uses the .agents/skills layout and -g installs it in the home directory.
Can Playwright MCP keep snapshots out of the tool response?
Yes, in part. The --snapshot-mode option accepts full or none, with full as the default, and the browser_snapshot tool has a filename parameter that saves the snapshot to a file instead of returning it in the response.
Sources
- Playwright MCP README (Documentation)
- Playwright CLI README (Documentation)
- Playwright CLI: Snapshots (Documentation)
- Playwright CLI: Skills (Documentation)