Skip to main content
← Back to Articles
MCPPlaywrightBrowser AutomationClaude DesktopCursor IDEAI integration

How to Set Up the Playwright MCP Server (2026)

Give Claude, Cursor, and VS Code a real browser with the official Playwright MCP server. Navigate pages, click, fill forms, and scrape using the accessibility tree — full setup, headless config, and troubleshooting.

By Web MCP GuideJune 28, 20268 min read

Most MCP servers connect your AI assistant to an API. The Playwright MCP server does something more powerful: it hands Claude, Cursor, or VS Code a real web browser. Your assistant can open a page, read it, click buttons, fill forms, and extract data — driving Chromium, Firefox, or WebKit the way a person would. And because it works from the page's accessibility tree instead of screenshots, it's fast, reliable, and cheap on tokens. This guide covers the complete setup.

What This Integration Enables

With the Playwright MCP server connected, your AI assistant can:

  • Navigate to any URL and read the page through a structured accessibility snapshot
  • Click links and buttons, type into fields, and submit forms
  • Extract text and data from pages for research and scraping
  • Run multi-step browsing flows (log in, navigate, fill, verify)
  • Capture screenshots or PDFs when you explicitly need them

Why the Accessibility Tree Beats Screenshots

Older browser-automation approaches feed the model screenshots and ask it to guess where to click. That is slow, error-prone, and burns enormous numbers of vision tokens. Playwright MCP instead gives the model a structured snapshot of the page's accessibility tree — every button, link, and field as labeled, addressable elements. The model acts on real targets rather than interpreting pixels, which makes automation dramatically more reliable and far cheaper to run.

Prerequisites

  • Node.js 18+ installed and on your PATH
  • An MCP client: Claude Desktop, Cursor, or VS Code
  • No API keys or accounts — Playwright drives a local browser and downloads its binaries on first run

Step 1: Test the Server Locally

Confirm the server runs before wiring it into a client. The official package is @playwright/mcp:

npx -y @playwright/mcp@latest

On first run it will fetch the browser binaries it needs. If it starts without error, stop it with Ctrl+C and move on. If the browser binaries are missing later, install them explicitly:

npx playwright install

Step 2: Add the Server to Your Client

Claude Desktop

Edit claude_desktop_config.json (macOS: ~/Library/Application Support/Claude/):

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

Cursor & VS Code

Use the identical block in ~/.cursor/mcp.json or your VS Code MCP settings. The command and args are the same across clients. See our filesystem MCP setup guide for the same pattern with a different server.

Headless and Other Flags

By default the server opens a visible browser window so you can watch what the AI does — useful while debugging. To run without a window (ideal for servers, CI, or background scraping), add --headless to the args. You can also pin a browser with --browser firefox:

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

Step 3: Restart and Verify

Fully quit and reopen your client, then try a simple browsing task:

Open example.com, take a snapshot, and tell me the page heading and links

If the assistant opens the page and reports its structure, the integration is live.

Real-World Use Cases

  • "Log into this dashboard and pull the latest numbers from the reports page"
  • "Fill out and submit this multi-step form with these values, then confirm success"
  • "Scrape the product names and prices from this category page into a table"
  • "Reproduce this bug by clicking through these steps and tell me what breaks"

Troubleshooting

The browser never opens

Confirm Node 18+ is installed, run npx playwright install to ensure the browser binaries exist, and make sure you fully restarted the client (not just closed the window).

Tools don't appear after setup

Validate the JSON in your config — a missing comma or bracket stops the entire file from loading. Our GitHub MCP guide covers the same config-validation steps.

Automation is slow or times out

Heavy pages can take time. Prefer running headless for speed, and keep tasks focused — ask for one flow at a time rather than a sprawling multi-site session.

Security

  • The server can browse anywhere and submit forms — treat it like giving the AI control of a browser
  • Avoid handing it long-lived logged-in sessions to sensitive accounts unless you trust the workflow
  • Be cautious automating actions that have real consequences (purchases, posts, deletes)
  • Run headless in isolated environments for unattended scraping tasks

Frequently Asked Questions

Is there an official Playwright MCP server?

Yes. Microsoft maintains the official Playwright MCP server, published as @playwright/mcp. It exposes browser-automation tools — navigate, click, type, take snapshots, and more — and is designed to drive a real Chromium, Firefox, or WebKit browser from any MCP-compatible AI client.

Does the Playwright MCP server use screenshots or the DOM?

By default it uses Playwright's accessibility tree (a structured snapshot of the page) rather than pixel screenshots. This is faster, more reliable, and far cheaper in tokens than vision-based approaches because the model reads structured elements instead of interpreting an image. A vision/screenshot mode is also available when you specifically need it.

Do I need API keys to use the Playwright MCP server?

No. Playwright MCP drives a local browser, so there are no API keys or accounts to configure. You only need Node.js installed; the server downloads the browser binaries it needs on first run. This makes it one of the simplest MCP servers to set up.

Can I run the Playwright MCP server headless?

Yes. By default it opens a visible browser window so you can watch the automation, which is great for debugging. Pass the --headless flag to run without a visible window, which is ideal for servers, CI, and background scraping tasks.

Why is the Playwright MCP server not controlling the browser?

The most common causes are Node.js being too old, the browser binaries not being installed (run npx playwright install), or the client not being fully restarted after editing the config. Also confirm the JSON in your MCP config is valid — a single missing comma stops the whole file from loading.

More MCP Integrations

Browse the full MCP server directory to connect Slack, the Google Drive server, and 50+ more tools to your AI workflow.