cd /news/ai-agents/how-to-set-up-playwright-mcp-in-clau… · home › topics › ai-agents › article
[ARTICLE · art-162625] src=momentic.ai ↗ pub= topic=ai-agents verified=true sentiment=· neutral

How to Set Up Playwright MCP in Claude Code, Cursor, Codex and VS Code

Microsoft's Playwright MCP server lets coding agents in Claude Code, Cursor, Codex and VS Code control a browser through the Model Context Protocol, installed in each client via `npx @playwright/mcp@latest`. The server requires Node.js 18 or newer plus Chrome, Firefox, WebKit or Edge on the machine running it, and exposes tools for navigation, clicking, typing and screenshots, returning accessibility snapshots that identify elements by role and accessible name rather than by image. Options include `--headless`, `--browser` and `--isolated`, the last for agents that should not reuse saved cookies or logins.

key takeaway

Playwright MCP is added to each client with `npx @playwright/mcp@latest` (e.g. `claude mcp add playwright npx @playwright/mcp@latest`), needs Node.js 18+ and a local browser, and concurrent agents should each use `--isolated` or a separate `--user-data-dir` because a persistent profile can only be u

by read5 min views56 publishedOct 31, 2026
How to Set Up Playwright MCP in Claude Code, Cursor, Codex and VS Code
Image: Momentic (auto-discovered)

What Playwright MCP is #

Playwright MCP gives a coding agent browser access through the Microsoft Playwright MCP server . The agent can open a page, inspect it, and interact with elements while you work in Claude Code, Cursor, or another MCP client.

The server exposes browser tools for actions such as navigation, clicking, typing, and taking screenshots. For page inspection, it can return an accessibility snapshot that identifies elements by roles and accessible names. An agent can use that structure to find a button or form field without interpreting a screenshot. The browser session helps the agent check what a page currently does, but it does not create a saved Playwright test.

Prerequisites #

Playwright MCP needs Node.js 18 or newer and a supported browser (Chrome, Firefox, WebKit or Edge) on the machine that runs the server. The project README lists browser installation steps.

Check the environment where your coding agent launches MCP servers, not just your usual terminal. A locally installed browser will not help if the server runs in a container or remote development environment that cannot access it.

Install and configure by client #

Each client needs a configuration that starts the Playwright MCP server with npx. Use the configuration format for your coding agent below.

Claude Code

Add the server with Claude Code’s MCP command.

claude mcp add playwright npx @playwright/mcp@latest

Cursor

In Cursor, open Cursor Settings > MCP > Add new MCP Server, pick the command type and enter npx @playwright/mcp@latest. To share the config with your team, commit it as .cursor/mcp.json in the project instead:

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

Codex

Add the server with the Codex CLI:

codex mcp add playwright npx "@playwright/mcp@latest"

Or add the entry to ~/.codex/config.toml yourself:

[mcp_servers.playwright]
command = "npx"
args = ["@playwright/mcp@latest"]

VS Code and GitHub Copilot

Register the server with VS Code so GitHub Copilot can access its browser tools.

code --add-mcp '{"name":"playwright","command":"npx","args":["@playwright/mcp@latest"]}'

Useful options #

Playwright MCP lets you choose how the browser runs. The server README documents --headless for runs without a visible browser window, --browser for choosing a browser, and --isolated for a profile that stays in memory rather than being saved to disk.

npx @playwright/mcp@latest --headless --browser=firefox --isolated

Use --isolated when you do not want a session to reuse saved cookies or logins. A persistent profile can only be used by one browser at a time, so if you run several agents at once, start each extra one with --isolated or its own --user-data-dir. Leave it off when you need a persistent profile, such as one you have already signed into. Add the same flags to the server command in your client configuration if you want them to apply whenever your coding agent starts Playwright MCP.

Five example prompts #

Replace the URLs and UI labels with ones from your application. Each prompt asks the coding agent to report what it observed rather than assume an interaction succeeded.

  1. Check navigation. “Open http://localhost:3000. Click the Pricing link and report the final URL and page heading.” The agent follows the link and checks whether the destination matches its label.
  2. Inspect form validation. “Open http://localhost:3000/signup. Submit the form without entering any values. List the validation messages you can see, and do not create an account.” The agent tests the empty-form state without supplying credentials.
  3. Verify a code change. “Open http://localhost:3000/settings. Check whether the Save button becomes enabled after I change a field. Do not click Save.” The agent checks the behavior affected by your change without modifying stored settings.
  4. Check a narrow viewport. “Open http://localhost:3000 at a 375-pixel viewport width. Check whether the main navigation is accessible and report any controls you cannot reach.” The agent resizes the browser and tests navigation rather than judging appearance alone.
  5. Inspect a failed request. “Open http://localhost:3000/products. If the product list fails to load, report the visible error and any relevant browser console messages.” The agent gathers evidence you can use to investigate the failure.

Troubleshooting #

Browser fails to launch

If the agent reports a missing browser executable, check which browser you selected in the Playwright MCP configuration. Install that browser using the instructions in the project README , then restart the MCP server. A successful server startup does not confirm that the selected browser can launch.

Permission or port errors

If the browser cannot start, check whether the process can write to its configured profile directory. An isolated profile still needs a writable location. If you configured a network port, check whether another process already uses it. A port conflict does not apply to configurations that communicate with the server through standard input and output.

Slow or oversized browser output

If an accessibility snapshot takes too long or floods the agent’s context, ask the agent to search the page with the browser_find tool or pass a depth limit to browser_snapshot instead of capturing the whole page again. Close tabs the task no longer needs, and avoid taking another snapshot when the previous one already contains the element the agent needs.

What Playwright MCP doesn't do #

Playwright MCP lets a coding agent drive a browser during a session. The server does not save that session as a test, rerun it after a later commit, or gate a deploy in CI. An agent could write a Playwright test using its other tools, but browser access alone does not create a maintained test suite.

If you need the agent to work with tests that run beyond the current session, Momentic’s MCP server connects it to a testing system. The comparison of browser and testing MCP servers explains where each fits.

── more in #ai-agents 4 stories · sorted by recency
── more on @microsoft 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/how-to-set-up-playwr…] indexed:0 read:5min 2026-10-31 · —