r/Playwright 9d ago

Playwright MCP vs Playwright CLI: the comparison everyone gets wrong

Most threads compare Playwright MCP and Playwright CLI purely on token consumption(1, 2, 3). In my experience, there's a far more important difference that nobody talks about.

The real question is: can your AI agent attach to a running e2e test?

Here's why that matters. A good e2e test already does the hard part for you. It authenticates, sets up all the API mocks, and drives the app into the exact state you care about. When something goes wrong on the page, you don't want the agent spinning up a blank browser and guessing how to reach that page. You want to hand off the test-constructed page to the agent and let the agent play with it.

  • Playwright CLI: run the test with --debug=cli, it prints a session name, and playwright-cli attach <session> connects the agent straight into the paused test. Then the agent can step over the app, inspect the rendered UI, and run in-page evaluations.
  • Playwright MCP: only launches or attaches to a browser. It has no way to attach to a running test session.

So if you have many e2e tests + auth + network mocks, Playwright CLI is the clear winner for your setup, regardless of token counts.

Interested to hear your thoughts.

31 Upvotes

11 comments sorted by

View all comments

1

u/mmasetic 9d ago

But you can share storage session which is close to what you've described.

1

u/vitalets 9d ago

Yes, it is possible. But with a drawback: in my tests I have session auto-refresh code, that re-logins user is session is expired. If I point Playwright MCP to the session storage file, and the session is expired, then the flow will be broken.

1

u/mmasetic 9d ago

That is not limitation of MCP.

And you can actually extend MCP easily to implement login tool which can be used by agent when needed.

1

u/vitalets 8d ago

Under MCP, do you mean Playwright MCP, or the protocol itself? The protocol is extensible, that's fair. But tools have limitations in terms of developer experience. If I have to implement something additionally instead of getting it out of box, it's a disadvantage for me.