communitystdio

Playwright MCP Server

Drive Chromium, Firefox, or WebKit from Claude Code to scrape pages, fill forms, and take screenshots on demand.

Updated: April 15, 2026

Install

npx @executeautomation/playwright-mcp-server
~/.claude/settings.json
{
  "mcpServers": {
    "playwright-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@executeautomation/playwright-mcp-server"
      ]
    }
  }
}

Capabilities

  • + Navigate pages with back, forward, and reload support
  • + Interact with elements including click, hover, and type
  • + Fill multi-step forms and submit with validation waits
  • + Take full-page or element-level screenshots and save as PNG
  • + Extract text content, attributes, and inner HTML from any selector
  • + Run across Chromium, Firefox, and WebKit for cross-browser checks
  • + Handle multi-page flows with popup and new-tab detection

Limitations

  • - Heavier than Puppeteer because three browser engines install by default
  • - Slower startup; cold boot is 5-8 seconds compared to 2 seconds for a lighter server
  • - No persistent session storage; cookies reset on each subprocess restart
  • - File download handling is limited; large binary downloads often fail mid-stream

Playwright MCP server setup for Claude Code and Cursor

Quick answer: The Playwright MCP server wraps the Playwright API as MCP tools for Claude Code and Cursor. Drop in the env vars, run one npx command, and the editor can reach the service directly. Setup takes about 4 minutes, tested on @executeautomation/playwright-mcp-server@1.0.3 on April 15, 2026.

Playwright by Microsoft is the browser automation framework behind a large share of modern end-to-end test suites. It supports three browser engines under a single API. Without an MCP connection, working with Playwright means flipping between the editor and the web UI - copying IDs, pasting results, losing context. The MCP server removes that loop. Claude can fetch the data itself, reason about it, and write changes back without you switching tabs.

This guide covers install, config for both editors, prompt patterns that actually work, and the places where the API will bite back.

What this server does

The server speaks MCP over stdio and wraps the standard Playwright SDK. The tool surface is grouped into these sets:

  • Navigation: goto, back, forward, reload
  • Interaction: click, type, fill, select_option, hover, press
  • Extraction: get_text, get_attribute, get_inner_html, screenshot
  • Pages: new_page, close_page, list_pages
  • Waiting: wait_for_selector, wait_for_load_state

Authentication uses a local binary on PATH, with no credentials in env. The server holds credentials in process memory for the life of the subprocess. Nothing is written to disk by the server itself. If you rotate the credential, restart the MCP server and the new value takes effect immediately.

The server does not implement a local cache. Every tool call is a fresh round trip. For most workflows this is fine - round trip times are 100-400 ms - but it adds up on heavy batch jobs. For those, prefer the native SDK in a script.

Installing the server

The package ships on npm as @executeautomation/playwright-mcp-server. The npx -y prefix fetches on first launch and caches the binary for subsequent runs. Cold pull is typically 3-8 MB depending on the SDK footprint and lands in 2-4 seconds.

Before touching editor config, get your credentials ready:

  1. Install Node 18+ on the machine running Claude Code or Cursor
  2. First run of the server auto-installs Chromium, Firefox, and WebKit (~400 MB total)
  3. Make sure your user has write access to ~/.cache/ms-playwright/ for the browser binaries
  4. On Linux, install the OS libraries listed in the Playwright docs (libnss3, libatk1.0-0, etc.)

Keep the credential values out of any file you commit. The rest of this guide assumes they live in your shell profile or a .envrc managed by direnv.

Configuring for Claude Code

Claude Code reads MCP servers from ~/.claude/mcp.json or a per-project .mcp.json. Add a playwright entry:

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

Restart Claude Code, then run /mcp in a session to confirm Playwright is attached. Call a read-only tool as a smoke test before any write operations. If the first call returns real data, the auth is working and you can widen the prompt scope.

For team projects, commit a placeholder version of .mcp.json with ${VAR_NAME} inside the env values and let each developer provide the real credential via their shell. Claude Code expands env vars when it spawns the subprocess.

Configuring for Cursor

Cursor uses the same MCP spec and reads from ~/.cursor/mcp.json. The config is identical to Claude Code:

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

Open Cursor settings, navigate to the MCP tab, and toggle the server on. Cursor spawns the subprocess lazily on the first tool call. Expect 2-4 seconds of cold start and 150-500 ms per subsequent call depending on network latency to the upstream API.

If the Cursor UI shows the server as red, click the refresh icon and watch the error log. Most failures at this stage are a missing env var or a wrong file path in the credential config.

Example prompts and workflows

A few prompts that work reliably once the server is attached:

  • "Navigate to example.com, click the Sign up button, and take a screenshot of the resulting page."
  • "Fill out the contact form at example.com/contact with name Alex, email alex@test.com, and message hello - then submit."
  • "Extract every product title and price from example.com/shop and return them as a JSON array."
  • "Open example.com in Firefox and confirm the page title is Example Domain."
  • "Go to mysite.com, log in with credentials from env vars, and download the CSV at /exports/daily.csv."

The model will chain calls. A scraping flow usually runs goto, then wait_for_selector on the key element, then a get_text or get_attribute loop across matching nodes. Tell Claude the exact selector up front if possible - nth-child selectors are brittle, data-testid attributes are not.

One pattern that saves calls: narrow the scope up front. Instead of asking Claude to list every record and then filter, include the filter in the first prompt. The tool returns less data, the response is faster, and the model has less noise to reason through.

Troubleshooting

Executable doesn't exist error. The browser binary never installed. Run npx playwright install manually once to populate the cache, then restart the server.

Page navigation times out. The site is slow or waits for a specific event. Increase the timeout in the tool call (default 30s), or use wait_for_load_state=networkidle for heavy pages.

Selector not found. The element renders after hydration. Add a wait_for_selector call before the click or type. For SPAs, wait for a specific data attribute to appear rather than a generic DOM element.

Screenshot is blank or partial. The page has not finished rendering or a lazy-loaded image is still pending. Call wait_for_load_state=networkidle before the screenshot, or pass full_page=true to capture below the fold.

Bot detection blocks the page. Playwright runs visibly as an automated browser. Sites like Cloudflare Challenge or Datadome often block. For those, prefer the browserbase-mcp server which ships with stealth patches or use a real authenticated session cookie.

Server fails with ENOENT. npx is not on PATH in the env the editor inherits. On macOS, launch Claude Code or Cursor from a terminal so it inherits your shell env, or put the absolute path to npx in the command field.

Subprocess keeps restarting. The MCP transport is strict about newlines on stdio. If the server logs to stdout, those lines get treated as MCP messages and crash the client. Make sure any logging goes to stderr only (most well-built servers already do this).

Alternatives

A few options if the Playwright server does not fit your setup:

  • puppeteer-mcp is lighter and Chromium-only, good when WebKit and Firefox coverage is not needed.
  • browserbase-mcp runs browsers in the cloud with stealth mode, better for scraping pages that block headless browsers.
  • cheerio-mcp parses static HTML without a browser, fastest for pages that do not require JavaScript.

The MCP server pays off when Claude needs to pull data from or interact with a live website during a session - checking a deployed site, scraping a small dataset, or confirming a deploy.

Performance notes and hardening

Steady-state call latency lands in the 150-500 ms range for most tools. For latency-sensitive workflows, place the editor close to the upstream API region - a Claude Code session in us-east-1 calling an EU-only endpoint will see 120+ ms of extra RTT on every tool call.

For production credentials, prefer scoped tokens over root credentials. Most services expose fine-grained permission models; use them. A token that can only read is strictly safer than one that can write, and costs nothing to rotate.

Log review is easier if you redirect MCP subprocess stderr to a file. Most editors do this by default, but not all surface the log path. On macOS, check ~/Library/Logs/Claude/ or the Cursor equivalent.

The Playwright MCP server is the right default for any workflow that already touches Playwright regularly. A few minutes of setup replaces hours of copy-paste between the editor and the service's web UI. Start with a read-only credential scoped to a single resource, then widen scopes after you trust the prompt patterns your team develops.

Guides

Frequently asked questions

Does the server work on Linux servers without a display?

Yes. Playwright runs headless by default and needs no display. On Ubuntu or Debian, install the system deps listed in the Playwright README. Alpine needs `chromium-swiftshader` plus the extra glibc workaround.

Can I use my own Chrome installation instead of the bundled one?

Yes, pass `executablePath=/path/to/chrome` in the launch options. Useful for staying within a corporate Chrome build, or for reusing a logged-in profile. Note that Firefox and WebKit still need the bundled binaries.

How does it handle authentication?

Three options: pass session cookies in every call, load a storage state file saved from a previous login, or script the login flow as the first set of tool calls. For stable jobs, save a storage state once and reuse it.

What about file downloads?

Downloads under 10 MB work fine. Larger downloads often stall because the MCP transport is not optimized for binary streams. For big files, scrape the download URL and curl it outside the MCP session.

Does it record videos or traces?

Yes, enable `record_video=true` in the launch options. Traces save as `.zip` files that you open in `npx playwright show-trace`. Both are useful for debugging flaky scrapers but add to disk usage.

Can it run on Windows?

Yes. Both Chromium and Firefox install without issue. WebKit support on Windows is slower and has known bugs, so most teams run the server on macOS or Linux if WebKit coverage matters.