Skip to content

Playwright MCP for Claude Code: Browser Testing That Verifies Itself

Add the Playwright MCP server so Claude Code can drive a real browser — navigate, click, screenshot, assert. The verify-my-change loop, headless vs headed, WSL notes.

MGMCSA Guru Team June 13, 2026 5 min read
Claude Code driving a browser through the Playwright MCP server to verify a UI change

Most agent frustration on frontend work comes down to one gap: the agent edits a component, says it’s done, and has no idea whether the page actually renders. The Playwright MCP server closes that gap. With it connected, Claude Code can open a real browser, click through your change, and confirm the result before claiming success.

This guide shows how to add it, what it can do, and the verify-my-change loop that makes it useful day to day. It also covers headless versus headed mode and the Windows and WSL specifics, since browser automation is where the two environments diverge most.

If you’re still setting up MCP in general, start with the MCP setup guide for Windows and WSL.

What it can actually do

The server exposes browser actions as tools Claude can call. In practice that means:

  • Navigate to a URL and wait for the page to load
  • Click buttons and links, fill form fields, submit forms
  • Read the page — text content, the accessibility tree, element state
  • Screenshot the full page or a specific element
  • Assert that something is present, visible, or has the expected text

That last group is the point. Claude can check its own work instead of handing you a change and hoping.

Install the server

The Playwright MCP server runs through npx. Add it to Claude Code:

claude mcp add playwright -- npx -y @playwright/mcp@latest

On native Windows PowerShell, npx-based servers sometimes need a command wrapper to launch correctly:

claude mcp add playwright -- cmd /c npx -y @playwright/mcp@latest

The first run downloads browser binaries, which takes a minute. If you’ve never installed Playwright on this machine, you may also need its browsers and dependencies — the Playwright installation docs cover the per-OS steps.

npx playwright install --with-deps

Confirm the connection with claude mcp list, or run /mcp inside a session to see the Playwright tools.

The verify-my-change loop

Here’s the workflow that makes this worth installing. Start your dev server, then ask Claude to make a change and check it:

The submit button on /signup isn't disabling while the form is in flight.
Fix it, then open the page in a browser and confirm the button disables
after I click submit. Screenshot the disabled state.

What happens next is the difference from a normal agent session. Claude edits the component, navigates to the page through Playwright, clicks submit, reads the button’s state, and reports back with a screenshot of the disabled button. If it didn’t work, it sees that too and keeps going.

You can make this a standing expectation:

After any change to a page under /dashboard, load it in the browser and
confirm it renders without console errors before telling me it's done.

That turns “I updated the layout” into “I updated the layout and verified it renders,” which is a much more useful kind of done. For more patterns like this, see the Claude Code power-user guide.

Headless vs headed

Two modes, and the choice is simple once you know what each is for.

Headless vs headed

Headless (default) No visible window; fast; best for verification and CI-style checks
Headed Visible browser; watch actions live; best for debugging a flaky interaction
On WSL Headless works out of the box; headed needs a display (WSLg/X server)
Day to day Stay headless and let Claude screenshot; switch to headed only to debug

Headless is the right default. You don’t need to watch the browser to trust a screenshot and an assertion, and headless is faster and works everywhere. Reach for headed only when an interaction behaves oddly and you want to see it happen.

Windows and WSL notes

This is where the two environments split.

On WSL, headless Playwright is the smooth path. Install the browsers and their Linux dependencies inside the distro with npx playwright install --with-deps, run headless, and let Claude screenshot when you want to see the result. Headed mode works only if you have WSLg or an X server providing a display, so unless you specifically need a visible window, stay headless.

On native Windows, both headless and headed work without a display server, but remember the cmd /c wrapper on the add command if the server fails to launch. The browsers install under your user profile.

Playwright MCP setup checklist

  • Add the server with claude mcp add (use cmd /c on native Windows)
  • Run npx playwright install --with-deps the first time
  • Verify with claude mcp list or /mcp
  • Start your dev server and note the local URL
  • Stay headless unless you're debugging a flaky interaction
  • On WSL, only attempt headed mode if you have WSLg/X
  • Point it at local or staging, never production

Wrapping up

The Playwright MCP server is the cheapest way to make Claude Code accountable for frontend changes. Add it per-project, keep it headless, run your dev server alongside, and ask Claude to verify what it changes. The result is fewer “looks done but isn’t” moments and a tighter loop between edit and confirmation.

It’s one of a small set of servers genuinely worth the context — see the rest in the best MCP servers for Claude Code in 2026.

Frequently asked questions

What does the Playwright MCP server let Claude Code do?

It lets Claude drive a real browser: open pages, click elements, fill forms, navigate, take screenshots, and assert on what's rendered. Instead of guessing whether a UI change worked, Claude can load the page and check, then describe or screenshot the result.

Do I need to write Playwright tests to use it?

No. The MCP server exposes browser actions Claude can call directly, so it can verify a change interactively without a test file. You can still ask it to write and run formal Playwright test scripts when you want a repeatable suite, but it isn't required for the verify loop.

Headless or headed — which should I use?

Headless is the default and best for speed and CI-style checks. Use headed when you want to watch the browser act in real time, usually while debugging a flaky interaction. On WSL, headed mode needs a working display, so most people stay headless there.

Does Playwright MCP work under WSL?

Yes, headless works well. You install the Playwright browsers and their Linux dependencies inside the WSL distro. Headed mode needs an X server or WSLg for a visible window, so if you only need verification, run headless and let Claude screenshot instead.

Will it slow down my session?

It adds tool definitions to the context like any MCP server, and launching a browser takes a moment. The cost is worth it on frontend work but unnecessary on backend-only projects, so add it per-project rather than globally.

Sources & further reading

Official vendor documentation referenced while writing this guide.

MG

MCSA Guru Team

IT & Systems Administration

We are working IT pros and system administrators who spend our days in Windows Server, Microsoft 365, and the wider Microsoft stack. MCSA Guru is where we write down the fixes and walkthroughs we wish we had found the first time.

MCSA Guru provides independent, educational IT guidance. Microsoft, Windows, Windows Server, Microsoft 365, Exchange, and Microsoft Teams are trademarks of Microsoft Corporation; Docker is a trademark of Docker, Inc. MCSA Guru is not affiliated with or endorsed by Microsoft or Docker. Always test changes in a safe environment before applying them in production.

Related guides

Fixing something right now?

Jump straight into the guide library or search for the exact error or task you are dealing with.