Playwright MCP vs CLI: Token Cost per Step Is Now the Same

2026-11-15来源 dev.to AIEnglish

The Playwright MCP README says coding agents favour the CLI because CLI invocations "avoid loading large tool schemas and verbose accessibility trees into the model context". I measured both parts. On current versions the second part is not a difference: MCP 0.0.85 and CLI 0.1.24 returned the same page content for the same steps, within 25 tokens of each other on 5 scripted tasks. MCP stopped putting the page into its navigate response in 0.0.69. The first part still holds: MCP 0.0.85 comes with 4,568 tokens of tool definitions. The largest saving in these tasks was find, and both tools have it.

The scripts and every response are in the PoC repo.

The setup

Two terms first. A snapshot is a text outline of the page, built from its accessibility tree. Each element in it has a ref, such as e17, which the agent uses to click or type.

  • @playwright/mcp 0.0.68 and 0.0.85, and @playwright/cli 0.1.24, on Node 24 and macOS. Headless, with a 1280x720 viewport: the CLI default, set by a flag for MCP.
  • A script drives each tool with fixed calls. No model is involved. It saves every response and counts its tokens with gpt-tokenizer (o200k_base).
  • Only the responses are counted, because they are what the tool adds to the agent's context. The text of the calls is not counted.
  • The script fails if the result of a task is not in the last response.
Task Steps
login open a login page, fill 2 fields, click Login, read the success message
large page open a page with a 50 by 50 table, read the last cell
docs open the Playwright docs intro, click the link to the next page, read the heading

Each tool gets the page content it needs for the task. On MCP 0.0.68 the navigate and click responses hold it. On MCP 0.0.85 and the CLI they hold a file link, so the script takes a snapshot before it acts and again to read the result. The docs task is 2 calls on 0.0.68 (navigate, click) and 4 on the other two (navigate, snapshot, click, snapshot).

What changed in 0.0.69

This is the response to browser_navigate in 0.0.68. The page is in the response:

### Page - Page URL: https://the-internet.herokuapp.com/login - Page Title: The Internet ### Snapshot ```yaml - generic [active] [ref=e1]: - link "Skip to content" [ref=e2] [cursor=pointer]: ... ``` 

This is the same call in 0.0.85. The page is in a file:

### Page - Page URL: https://the-internet.herokuapp.com/login - Page Title: The Internet ### Snapshot - [Snapshot](results/raw/MCP 0.0.85/files/page-2026-11-15T11-09-41-906Z.yml) 

The CLI response has the same format. In both tools, only an explicit snapshot (browser_snapshot, or playwright-cli snapshot) puts the page into the response.

I called browser_navigate on 16 versions to find the release:

@playwright/mcp versions tested Page in the navigate response browser_find
0.0.41, 0.0.56, 0.0.64, 0.0.67, 0.0.68 yes no
0.0.69, 0.0.70, 0.0.76, 0.0.77 no, a file link no
0.0.78 to 0.0.81, 0.0.83 to 0.0.85 no, a file link yes

The timing matches microsoft/playwright#39768. It was merged on 2026-03-19, between 0.0.68 (2026-02-14) and 0.0.69 (2026-03-30). It removes the --output-mode option and says "snapshots go to files for non-explicit mode, inline for explicit". The release notes for 0.0.69 do not list it. I did not bisect commits.

The results

Tokens in the responses for each task:

Task MCP 0.0.68 MCP 0.0.85 CLI 0.1.24
login 1,417 1,168 1,193
large page 48,214 43,445 43,432
docs 15,197 19,178 19,166
large page, with find no find 340 328
docs, with find no find 1,020 1,006
  • MCP 0.0.85 and the CLI differ by 25 tokens at most. In these tasks the tool did not change the response tokens of a step.
  • The text of the calls is not in these numbers. An MCP call carries an element description that a CLI command does not.
  • The cost is the snapshot. On the large page, 43,348 of the 43,445 tokens are one browser_snapshot response.

0.0.68 against 0.0.85

The newer version is not cheaper on every task. Login has 18% fewer tokens and the large page 10% fewer. The docs task has 26% more.

Two things changed besides the file link:

  • 0.0.68 had an incremental mode, and it was the default. After the click it returned only the part of the page that changed (6,175 tokens). 0.0.85 has no incremental mode: --snapshot-mode accepts full or none. The script takes a second full snapshot to read the heading (10,411 tokens).
  • The snapshot text differs between the versions. The 0.0.78 release notes say snapshots are "distilled to reduce noise and token usage". The first docs snapshot is 9,022 tokens on 0.0.68 and 8,586 on 0.0.85.

So on current versions the cost depends on what the agent asks for after an action. In the docs task, a full snapshot after the click cost more than the old diff.

The saving is find

find searches the snapshot for a text and returns the matching elements with a few lines around them. The elements keep their refs, so the agent can act on a match without a snapshot. This is the whole response for the large page:

### Result Found 1 match for "50.50": - generic [active] [ref=f4e1]: - generic [ref=f4e5]: - main [ref=f4e7]: - generic [ref=f4e8]: - generic [ref=f4e111]: - generic [ref=f4e114]: - table [ref=f4e228]: - rowgroup [ref=f4e281]: - row [ref=f4e2781]: - cell "50.47" [ref=f4e2828] - cell "50.48" [ref=f4e2829] - cell "50.49" [ref=f4e2830] - cell "50.50" [ref=f4e2831] - contentinfo [ref=f4e2832]: - generic [ref=f4e2834]: - text: Powered by 
  • Large page: 43,445 tokens with a snapshot, 340 with find. That is 128 times fewer.
  • Docs: 19,178 tokens with two snapshots, 1,020 with two find calls. That is 19 times fewer.

These are two tasks. find needs a text to search for, and the script knew it. A 2,500-cell table is close to the worst case for a snapshot.

browser_find is in @playwright/mcp from 0.0.78 (2026-07-09). The CLI command is playwright-cli find.

The fixed cost

What is loaded Tokens
MCP 0.0.68 22 tool definitions 3,071
MCP 0.0.85 25 tool definitions 4,568
CLI 0.1.24 the SKILL.md it ships 3,760

These are not like for like. The MCP numbers are the JSON that the server returns for its tool list; a client can format it differently. A client normally sends tool definitions with every request, and some clients load them only when needed. An agent reads SKILL.md when it uses the skill. The MCP definitions grew 49% between the two versions.

What I'd do with it

  • Do not pick the CLI over MCP for the token cost of a step alone. In these tasks the responses cost the same.
  • Check the version of @playwright/mcp. On 0.0.68 the navigate and click responses put page content into the context.
  • Tell the agent to try find first, and to take a full snapshot only when find is not enough.
  • Count the snapshot calls in a session. In these tasks they were where the tokens went.

The limits: the calls are scripted, and an agent chooses its own calls. The tokenizer is not the tokenizer of any Claude model, so compare the columns and not the absolute numbers. There are three tasks on two public sites, and the docs page can change. I tested one version of the CLI, so this does not show what the CLI cost before. I ran the script twice: the MCP 0.0.85 and CLI numbers were the same in both runs, and three MCP 0.0.68 responses changed by 4 to 6%. MCP 0.0.68 ran with its defaults; it also has an --output-mode file option that I did not run. An agent with file access can read or search the snapshot file, which I did not measure.

Repo: qa-gary-parker/poc-playwright-mcp-vs-cli. More measured experiments are in the playbook.

Originally published at https://garyparker.dev/blog/playwright-mcp-vs-cli-tokens

原文:https://www.a8q9.cn/en/article/playwright-mcp-vs-cli-token-cost-per-step-is-now-the-same-f7dcda.html

相关文章