New on GitHub
Sources 33Updates always the freshest
0 Newsletter
Animated illustration for: Playwright MCP: how to set it up in Claude Code and Cursoragent$ claudeMCPplaywright0.0.86Node 20$ npx @playwright/mcp@latest
Create · MCP · Guide · 8 min read

Playwright MCP: how to set it up in Claude Code and Cursor

Playwright MCP gives a coding agent a real browser to click through. Add it to Claude Code with one command or to Cursor with an mcp.json entry. Plus risks.

In short
  • Playwright MCP is a free MCP server from Microsoft (Apache-2.0 licence) that lets an agent control a browser.
  • In Claude Code you add it with one command, in Cursor with an entry in mcp.json.
  • It needs Node.js 20 or newer.
  • It is not a security boundary, so do not log it in to accounts the agent should not touch.

Playwright MCP is a free MCP server from Microsoft that gives an AI agent a real browser: it opens pages, clicks and fills in forms. In Claude Code you add it with one command, and in Cursor with an entry in mcp.json. All you need is Node.js 20 or newer.

Why bother? A coding agent sees your code but not how that code looks in a browser. With a browser it can check its own change: open the page, click a button and read the error in the console. In this guide I show how to connect it, how it works and what to watch out for.

What Playwright MCP is and how it works

Playwright MCP is an MCP server that gives an agent tools for controlling a browser. According to the project documentation the agent does not receive screenshots, but a text accessibility snapshot of the page, so it does not need a model that “sees” images.

An accessibility snapshot is a list of the page’s elements: buttons, fields and headings. The agent points at an element in that list and the server performs the click. The README calls this approach deterministic, because nothing is guessed from a picture. There are many tools, from browser_navigate and browser_click to browser_snapshot, browser_console_messages and browser_network_requests. Some of them have to be enabled separately with the --caps flag.

The whole thing runs as a program started by Node.js. The MCP client, that is Claude Code or Cursor, starts it in the background and talks to it through the shared protocol. If the terms are new to you, start with MCP in five minutes.

Screen recording: github.com/microsoft/playwright-mcp, 2026-11-24

What you need before installing

The requirements in the README are short. You need Node.js 20 or newer and an MCP client: the README lists VS Code, Cursor, Windsurf and Claude Desktop among others, and has separate instructions for Claude Code. You check the Node.js version with:

node --version

The @playwright/mcp package does not need a permanent install. The npx command fetches it on first run. On 24 November 2026 I ran npx --yes @playwright/mcp@latest --version in an empty directory, and the package answered “Version 0.0.86”, exit code 0. The npm registry shows the same version. The recording is below.

Terminal recording of a real run, 2026-11-24

I ran only --version and --help. I did not connect the server to an agent here, so the steps for adding it to the clients below come from the maker’s documentation and the clients’ documentation.

How to add Playwright MCP to Claude Code

In Claude Code one command is enough, the one given in the project README:

claude mcp add playwright npx @playwright/mcp@latest

The command saves the server in what is called the local scope. According to the Claude Code documentation such a server works only in the current project, is private and goes into the ~/.claude.json file. To save it in a .mcp.json file in the repository and share it with your team, add --scope project. For every one of your projects to have it, add --scope user.

If you want to add server flags, for example --headless, separate them from the command with a double dash. The Claude Code documentation explains that everything after -- is passed to the server unchanged:

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

Then check the list of servers with claude mcp list, or type /mcp during a session. When the server works, ask the agent for a simple task, for example: “Open https://example.com and tell me what the page heading is”. I describe the general rules for adding servers and judging trust in How to add an MCP server to Claude Code and judge whether to trust it.

How to add Playwright MCP to Cursor

In Cursor you have two routes. The first is adding it by hand through settings: the README tells you to go to Cursor Settings → MCP → Add new MCP Server, pick the command type and enter npx @playwright/mcp@latest. The second is a config file.

The Cursor documentation gives two places: .cursor/mcp.json in the project (a server for that project only) and ~/.cursor/mcp.json in your home directory (a server in every project). The entry is the same as the “standard config” in the README:

{
  "mcpServers": {
    "playwright": {
      "command": "npx",
      "args": ["@playwright/mcp@latest"]
    }
  }
}

The same config works in most MCP clients, so you can copy it to VS Code, Windsurf or another tool. After saving the file, check in Cursor’s MCP settings that the playwright server shows as enabled.

  1. 01
    Node.js 20+You check node --version.
  2. 02
    Add the serverClaude Code: claude mcp add. Cursor: mcp.json.
  3. 03
    Check the listclaude mcp list or Cursor's MCP settings.
  4. 04
    Simple taskThe agent opens a page and describes what it sees.
  5. 05
    Set the profileNormal, isolated or your own directory.

The key options: window, profile and isolation

By default the server starts the browser with a window. The README says so plainly: “headed by default”. The --headless flag turns on headless mode, useful on a server with no screen. The --browser flag picks the browser: chrome, firefox, webkit or msedge.

The second important matter is the browser profile. By default the server uses a persistent profile, so logins survive between sessions. According to the README it lives in the cache directory (on macOS under ~/Library/Caches/ms-playwright/), and its name contains a hash of the project path, so different projects get separate profiles. Only one browser can use such a profile at a time. For several clients in parallel add --isolated or a separate --user-data-dir.

The --isolated mode keeps the profile in memory only and loses it when the browser closes. With --storage-state=<file> you can load saved cookies into such a session.

Three ways to run the browser (according to the Playwright MCP README)
Persistent profile (default)--isolatedExtension (--extension)
Where state livesA folder on diskMemory onlyYour running browser
Logins after closingKeptGoneKept in your browser
Several clients at onceConflictYesDepends on the browser
When to use itThe site needs a loginTests that leave no traceThe agent should use your tabs and logins

The extension mode connects the agent to a running Chrome or Edge and its logged-in sessions. It needs the “Playwright Extension”, and the README sends you to a separate description in the Playwright repository for installation. It is convenient, but it also has the widest blast radius, as I explain below.

What to watch out for: security

The README is unambiguous: Playwright MCP “is not a security boundary”. A browser steered by an agent can visit any page, and the content of a page can be hostile input.

The most realistic risk is prompt injection. A page contains hidden text that the agent reads as an instruction. General recommendations are on the MCP Security Best Practices page. My own rules, which are my opinion and not a quote from the documentation:

  • Work with the server in a separate profile or with --isolated, with no logins to your own mail, bank or company accounts.
  • Start with pages you know: your own local app or test sites.
  • The --allowed-origins and --blocked-origins options limit where the browser sends requests, but the README notes they are not a security boundary and do not cover redirects.
  • The browser_run_code_unsafe tool is described in the README as running arbitrary code on the machine where the server runs, so do not approve it without reading the code.
  • Keep the client’s approval prompt on tools that change the state of a page, and read what the agent wants to do.

If you prefer terminal commands: Playwright CLI

The README opens with a comparison to Playwright CLI. Its authors write that coding agents increasingly prefer terminal commands with skills, because they use fewer tokens: they do not load large tool descriptions or long page trees into the context. MCP, they say, stays good for loops where persistent browser state matters, such as exploring sites or long autonomous tasks.

I think that is a sensible split. For everyday checking of your own code change, start with short tasks and watch how much context the server eats. If it is too much, look at the CLI.

Common problems

  • npx cannot find the package. Check the spelling: “Playwright”, not “playwrite”, and the full name @playwright/mcp@latest.
  • Node.js too old. The README requires 20 or newer. Check node --version and update.
  • The server will not connect in a second window. The persistent profile serves one browser at a time. Use --isolated or a separate --user-data-dir.
  • A server on a machine with no screen. The README recommends --headless mode or a separate run with the --port flag (the README example uses port 8931) and the address http://localhost:8931/mcp in the client config.

Newsletter: once a week I write about which MCP servers really help developers, with ready-to-paste commands and notes on safety.

Newsletter · knowledge from the workshop

Build with AI. Step by step.

I do not copy headlines. Once a week I write about what I test myself while building Frinter, the warehouse agent and sites in 1:1 workshops: what worked, what did not and why.

  • Behind the scenes of my projects
  • Decisions, mistakes and their cost
  • One proven way of working

Checklist

Task for today: add Playwright MCP to the client you use and ask the agent to open https://example.com. You are done when the agent reports the page heading and claude mcp list or Cursor’s MCP settings show the playwright server.

  • node --version shows 20 or more.
  • The server is added with one command (Claude Code) or an mcp.json entry (Cursor).
  • The server is visible in the client’s server list.
  • For first tries, an isolated or separate profile, with no logins to important accounts.
  • You turn on the extension mode only deliberately.
  • You know it is not a security boundary.

Last checked: 24 November 2026. The package version is 0.0.86 and the project moves fast, so confirm option and tool names in the README that the sources below link to.

Frequently asked questions

Is Playwright MCP free?
Yes, the server itself is free and open source (Apache-2.0 licence, published by Microsoft). You only pay for the model your agent uses, for example a Claude Code or Cursor plan.
What does MCP stand for?
Model Context Protocol. It is a shared standard that lets an AI agent use outside tools, such as a browser.
How do I set up Playwright to work with an agent?
Check that you have Node.js 20 or newer, then add the server to your client. In Claude Code run claude mcp add playwright npx @playwright/mcp@latest, and in Cursor add an entry with the command npx and the argument @playwright/mcp@latest in mcp.json.
Is it "Playwright" or "playwrite"?
It is "Playwright", the name of the tool and of the @playwright/mcp package. "Playwrite" is a typo, and in the install command it gives a package-name error.

Sources

MCP

Related