How to Add Playwright MCP to Claude Code: Real Browser Automation in 2 Minutes (+ Connection Fixes)

Playwright MCP: Browser automation for Claude Code

Last Verified: October 2026 — commands, flags, and error messages checked against the microsoft/playwright-mcp docs

You ask Claude Code why the signup flow breaks, and it can only guess from the source. So you open the page, click through it yourself, copy what you see, and describe it back in words. The agent is working from your summary, not the page.

Playwright MCP takes you out of that loop. It’s Microsoft’s official browser automation server: it lets Claude Code open a real browser, click through a page, read the actual rendered text, and fill in forms, using accessibility snapshots instead of pixel screenshots. It’s become one of the most-installed MCP servers because it turns “describe this page to me” from a guess into an actual read. Setup takes about 2 minutes.

How it works

Youask in plain English
Claude Codepicks the right tool
Playwright MCPLocal (npx) · sign-in: None
Real data backOpens a real browser, clicks through flows, fills forms

Measured by us · October 22, 2026

Windows 11 laptop (build 26200), Node 24.18.1. Our own script sent the two requests any MCP client makes to learn what a server offers (initialize, then tools/list) and timed the answer. No Claude Code session, no account, no API key.

What we checkedResult
Server versionPlaywright 1.64.0-alpha-1790635538000
Tools it adds25: browser_close, browser_resize, browser_console_messages, browser_handle_dialog, browser_emulate_media, browser_evaluate, browser_file_upload, browser_drop, and 17 more
Size of the tool definitions20.8 KB, about 5,330 tokens
Time to answer16.5 s on our first launch of the day, 5.8 s on the next one
Change since our October 3 runSame tools; definitions unchanged (5,333 → 5,333 tokens)

Tokens are estimated as characters ÷ 4, the same way as in our other measured posts; we didn’t run a tokenizer. This is what the server costs when it loads, not a whole session, and Claude Code’s tool search can defer MCP tool definitions until they’re needed, so treat it as the worst case.

Quick Start

Add it as a local stdio server — no separate install step, npx handles it on first run.

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

Restart Claude Code, then run /mcp inside a session to confirm it shows as connected. Total time: about 2 minutes.

⚡ Copy This Prompt: Let Claude Code Install and Verify It For You

Skip Steps 1-4 below and hand the whole thing to the agent instead:

You have access to the `claude mcp` CLI in this project. Do the following and report back — do not tell me it's done unless step 4 actually confirms it:

1. Run `claude mcp list` to see what's already configured.
2. Add the Playwright MCP server: `claude mcp add --transport stdio playwright -- npx -y @playwright/mcp@latest`
3. Run `claude mcp list` again and confirm playwright shows as Connected.
4. Open a real page to prove it works: navigate to https://example.com and read back the page's main heading text. If step 4 fails, tell me the exact error instead of reporting success.

This works because Claude Code can run its own CLI commands and then immediately use the newly connected server — so the agent proves the browser actually works instead of just confirming the config exists.

Microsoft's Playwright MCP repo, captured October 2026.
Microsoft’s Playwright MCP repo, captured October 2026.
On this page (8 sections)
  1. Before You Add Playwright MCP
  2. Step-by-Step Setup
  3. What Each Flag Does
  4. Check Playwright MCP Is Really Connected
  5. Playwright MCP Not Connecting? Fixes for Common Errors
  6. Common Mistakes to Avoid
  7. Q&A
  8. Official Resources

Before You Add Playwright MCP

Requirement Why You Need It Time
Claude Code installed Provides the claude mcp command used to register the server 0 min
Node.js Playwright MCP runs via npx — no separate download needed beyond this ~5 min if missing
Google Chrome (or another browser) By default Playwright MCP drives your installed Chrome. No Chrome? Install it, or pick Firefox or WebKit with --browser 0 min

Step-by-Step Setup

Prefer to do it by hand instead of delegating to the agent? Here’s the manual version.

Step 1 — Add the server

~1 min

The -- separates Claude’s own flags from the command that launches the server:

claude mcp add --transport stdio playwright -- npx -y @playwright/mcp@latest
Terminal: claude mcp add --transport stdio playwright -- npx -y @playwright/mcp@latest; then claude mcp list
Real run, October 2026. Without --scope the server lands in local config: this project only, and only on your machine. Add --scope user to use it everywhere.

Step 2 — Run it headless (optional, faster in CI or background use)

~1 min

By default the browser runs headed (a visible window). For faster, invisible runs — especially useful when Claude Code is doing background verification work — add --headless and --isolated so each session starts from a clean profile instead of reusing saved cookies:

claude mcp add --transport stdio playwright -- npx -y @playwright/mcp@latest --headless --isolated

Step 3 — Pick a specific browser engine (optional)

~1 min

Defaults to your installed Google Chrome (the chrome channel). To test against Firefox or WebKit instead, pass --browser:

claude mcp add --transport stdio playwright -- npx -y @playwright/mcp@latest --browser firefox

Step 4 — Restart and approve

~1 min

Run claude to start a fresh session. Newly added servers need a restart (or the /mcp panel refresh) before Claude Code can see their tools.

Terminal connected to a browser where a robot hand clicks a button and fills a form
Claude Code drives a real browser: it clicks, types, and reads the rendered page.

What Each Flag Does

Flag What It Does
--headless Runs the browser with no visible window — headed (visible) is the default
--isolated Keeps the browser profile in memory only, so every session starts fresh instead of reusing saved logins/cookies
--browser Chooses the engine: chrome (default), firefox, webkit, or msedge
--caps vision Adds coordinate-based mouse tools (click at x,y) for elements the accessibility tree can’t describe. Replaces the old --vision flag. Other opt-in caps: pdf, devtools
--device Emulates a specific device, e.g. "iPhone 15", for responsive/mobile testing

Check Playwright MCP Is Really Connected

Check that it’s registered and healthy:

claude mcp list
✔ playwright    Connected
✘ playwright    Failed to connect

A config entry showing up is not the same as it working — the real test is asking Claude Code to actually drive the browser. In a session, ask it to navigate to a real page and read something back:

Navigate to https://example.com using the playwright MCP tools and tell me the exact text of the page's main heading.

If it comes back with the actual heading text (“Example Domain”), the browser is genuinely working end to end — not just listed as connected.

Playwright MCP Not Connecting? Fixes for Common Errors

Most failures happen before a browser ever opens: the npx process exits, Claude Code shows Failed to connect or connection_closed, and the real error stays hidden. Run the package yourself first. If this prints the flag list, Node.js, npx, and the package are fine:

npx -y @playwright/mcp@latest --help
What You SeeUsual CauseFix
✘ playwright Failed to connectnpx couldn’t start the server: Node.js missing or old, or the package download was blockedCheck node -v and run the --help command above. On native Windows, if npx works in your terminal but not from Claude Code, re-add it through cmd /c: claude mcp add --transport stdio playwright -- cmd /c npx -y @playwright/mcp@latest
failed to reconnect to plugin:playwright:playwright: connection_closedThe same server installed as a Claude Code plugin (plugin servers are named plugin:<plugin>:<server>) exited on startupSame checks as above, then reconnect from /mcp. If you also added it with claude mcp add, remove one copy so two servers don’t share one browser profile
Browser "chrome" is not installedThe default engine is your installed Google ChromeInstall Chrome, run the install command the error prints (npx @playwright/mcp install-browser <browser>), or switch with --browser firefox
Browser is already in use for <userDataDir>Another session is holding the saved browser profileClose the other session, or add --isolated so each session gets its own in-memory profile
Missing system dependencies required to run browserLinux or CI image without the browser’s shared librariessudo npx playwright install-deps chrome, and add --headless when there’s no display

Common Mistakes to Avoid

  • Forgetting the -- separator. Without it, Claude Code can’t tell where its own flags end and the server’s launch command begins.
  • Assuming “Connected” means the browser itself works. The MCP handshake can succeed even if the first real navigation later fails — always test with an actual page load, not just claude mcp list.
  • Running headed by default in a CI or background context. If there’s no display available, add --headless or the browser launch will fail.
  • Turning on --caps vision by default. Accessibility snapshots handle almost every page, and clicking by coordinates breaks as soon as the layout shifts. Only add it when an element genuinely isn’t in the accessibility tree.
  • Not restarting after adding the server. Claude Code needs a fresh session or an /mcp panel refresh to pick up a newly added server.

Q&A

Does this take screenshots of every page?

No, by default it reads the page’s accessibility tree (an accessibility snapshot) rather than capturing pixels — that’s faster and lets Claude read actual text and structure instead of interpreting an image. It only takes a screenshot when the agent calls the screenshot tool, for example when you ask it to capture the page.

Will this affect my regular browser’s saved logins?

Not if you use --isolated — that keeps each session’s profile in memory only. Without it, Playwright MCP uses a persistent profile stored in a separate cache directory, not your regular browser’s profile.

Can I have the agent test my own site with this?

Yes — that’s one of the most common uses: ask Claude Code to navigate your local dev server or a staging URL, click through a flow, and report back what it actually saw rendered.

Why does it fail in a CI environment?

Usually a missing display for headed mode — add --headless, and if Chromium itself is missing in the CI image, its first-run download step needs network access.

How do I add Playwright MCP to Claude Code?

Run claude mcp add --transport stdio playwright -- npx -y @playwright/mcp@latest, restart Claude Code, and check /mcp. Microsoft’s README uses the shorter claude mcp add playwright npx @playwright/mcp@latest, which registers the same server. Add --scope user to use it in every project.

Playwright MCP or a Puppeteer MCP server?

Playwright MCP. It’s Microsoft’s actively maintained server, drives Chrome, Firefox, and WebKit, and reads pages through accessibility snapshots. The original reference Puppeteer MCP server was archived by the MCP project, so it no longer gets fixes.

Can I remove it later?

Yes — claude mcp remove playwright deletes it from the config.

Official Resources

Comments

4 responses to “How to Add Playwright MCP to Claude Code: Real Browser Automation in 2 Minutes (+ Connection Fixes)”

  1. […] already have their own dedicated setup guides — see Playwright MCP, GitHub MCP, and Context7 […]

  2. […] runs as an independent MCP connection. If you use Playwright or GitHub MCP alongside these, see our Playwright MCP guide and GitHub MCP guide for the same install […]

  3. […] using our Playwright MCP setup? The two are complementary. Playwright is built for driving the browser through flows. DevTools MCP […]

  4. […] uses GitHub and Playwright as the example servers. If you set up Playwright the direct way with our Playwright MCP guide, this is the containerized […]