feat!: replace @playwright/mcp with playwright-cli#1
feat!: replace @playwright/mcp with playwright-cli#1pierreboissinot wants to merge 1 commit intomnapoli:mainfrom
Conversation
BREAKING CHANGE: swap MCP-based browser automation for playwright-cli (https://github.com/microsoft/playwright-cli), a CLI-based alternative that returns lightweight YAML snapshots instead of full accessibility trees, reducing token usage and speeding up test execution. - Replace @playwright/mcp dependency with @playwright/cli - Use Bash(playwright-cli:*) instead of mcp__playwright__* tools - Remove MCP config generation in runner.ts - Update prompt-template.md to use playwright-cli commands with ref-based selectors (e.g. e3, e15) and skills-less discovery via --help - Move headed/headless mode from runner to prompt interpolation
|
Oh also why not include the official skill? Because it might be useful for Claude to use the CLI optimally? (i.e. I'd be afraid we do a poorer job at teaching Claude how to use the CLI than the official skill) |
Ok, i'll look into that idea on monday, I'm attending to https://shift-hackathon.com this week end |
| prompt, | ||
| "--allowedTools", | ||
| "mcp__playwright__*", | ||
| "Bash(playwright-cli:*)", |
There was a problem hiding this comment.
If I am not mistaken we can let it load the skill by using:
Bash(playwright-cli:*) Skill
And adding the section below on prompt-template.md):5
First, invoke the playwright-cliskill (via the Skill tool with skill name "playwright-cli") to set up browser interaction capabilities. If the skill is not available, fall back to runningplaywrigh
+t-cli --help to discover available commands.
@mnapoli In my opinion playwright-cli is faster and costs less token so yes, worth it. |
|
Thanks. I'm working on a big refactor and will change to the CLI version. I've noticed (big surprise) AI sometimes fail to follow instructions correctly, so I need to improve the internals first. |
Ok so I let this PR as it is atm ? |
|
Yes, thank you for the contribution even if it wasn't that exact code the idea was great! I released a pretty major update: https://github.com/mnapoli/exspec/releases/tag/0.3.0 I fixed a lot of weird behaviors, making things (hopefully) much more stable and reliable. And since we have more logs now, we can see where the agent gets confused. That prompted me to add "Recommendations" -> the agent now can recommend improvements to tests. E.g. I had a confusing test (that is wasting time and tokens as the agent needs to figure out how to understand the website), now I can know about that. I think next features could be:
|


Context
Hey @mnapoli ! Following up on our exchange under your LinkedIn post about exspec —
I mentioned I was experimenting with playwright-cli (https://github.com/microsoft/playwright-cli)
as a more token-efficient alternative to the MCP-based Playwright integration.
Here's a working implementation.
Summary
@playwright/mcpwith@playwright/cli(playwright-cli)Bash(playwright-cli:*)) instead of MCP tool callse3,e15) instead of full accessibility treesplaywright-cli --helpWhy
The MCP approach returns verbose accessibility trees on every
browser_snapshotcall —each interaction bloats the context window. playwright-cli returns concise YAML with
numbered refs, which means:
playwright-cli showfor live session monitoringWhat changed
package.json@playwright/mcp→@playwright/clisrc/runner.ts--allowedTools "Bash(playwright-cli:*)"src/prompt.tsheadedoption with{HEADED_MODE}interpolationsrc/cli.tsheadedto prompt instead of runnerprompt-template.md--helpdiscovery, ref-based selectorsREADME.mdTest plan
npm run fixturesruns successfully against example.com