Playwright Browser Automation MCP server

Enables web browser control for navigating websites, capturing page snapshots, interacting with elements, and taking screenshots through Playwright's automation capabilities.
Back to servers
Setup instructions
Provider
Microsoft
Release date
Mar 22, 2025
Language
TypeScript
Package
Stats
11.20M downloads
23.6K stars

Playwright MCP is a server that enables automation of web browsers through structured accessibility snapshots, allowing Large Language Models (LLMs) to interact with web pages without requiring screenshots or vision-based models.

Installation

To install the Playwright MCP server, you need to configure it with your MCP client. Most tools use a standard configuration:

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

Requirements

  • Node.js 18 or newer
  • An MCP client like VS Code, Cursor, Windsurf, Claude Desktop, or Goose

Client-Specific Installation

VS Code

Click the install button or add manually by following the MCP install guide with the standard config. You can also install using the VS Code CLI:

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

Cursor

Go to Cursor SettingsMCPAdd new MCP Server. Use command type with the command npx @playwright/mcp@latest.

Claude Desktop/Windsurf/Other Clients

Follow your client's MCP server installation documentation, using the standard config shown above.

Configuration Options

The Playwright MCP server supports numerous command-line arguments to customize its behavior:

npx @playwright/mcp@latest --help

Common options include:

  • --browser <browser> - Specify browser to use (chrome, firefox, webkit, msedge)
  • --headless - Run browser in headless mode (headed by default)
  • --viewport-size <size> - Set browser viewport size (e.g., "1280x720")
  • --user-agent <ua string> - Specify a custom user agent
  • --caps <caps> - Enable additional capabilities like vision, pdf, testing
  • --isolated - Keep browser profile in memory, don't save to disk
  • --user-data-dir <path> - Specify path to user data directory

User Profiles

Playwright MCP can run in different profile modes:

Persistent Profile (Default)

All login information is stored in a persistent profile located at:

  • Windows: %USERPROFILE%\AppData\Local\ms-playwright\mcp-{channel}-profile
  • macOS: ~/Library/Caches/ms-playwright/mcp-{channel}-profile
  • Linux: ~/.cache/ms-playwright/mcp-{channel}-profile

Override with --user-data-dir argument.

Isolated Mode

Each session starts in an isolated profile with all storage state lost after closing:

{
  "mcpServers": {
    "playwright": {
      "command": "npx",
      "args": [
        "@playwright/mcp@latest",
        "--isolated",
        "--storage-state={path/to/storage.json}"
      ]
    }
  }
}

Browser Extension

Connect to existing browser tabs using the Playwright MCP Chrome Extension.

Initial State Configuration

Storage State

  • Use --user-data-dir to persist all browser data between sessions
  • Use --storage-state to load cookies and local storage from a file

Page State

  • Use --init-page to point to a TypeScript file for page setup:
// init-page.ts
export default async ({ page }) => {
  await page.context().grantPermissions(['geolocation']);
  await page.context().setGeolocation({ latitude: 37.7749, longitude: -122.4194 });
  await page.setViewportSize({ width: 1280, height: 720 });
};
  • Use --init-script to add initialization scripts:
// init-script.js
window.isPlaywrightMCP = true;

Using a Configuration File

Create a JSON configuration file and specify it with --config:

npx @playwright/mcp@latest --config path/to/config.json

Standalone MCP Server

Run the MCP server on a separate port for HTTP transport:

npx @playwright/mcp@latest --port 8931

Then in your MCP client config, set the URL:

{
  "mcpServers": {
    "playwright": {
      "url": "http://localhost:8931/mcp"
    }
  }
}

Available Tools

The Playwright MCP server provides various tools for browser automation, including:

  • Core automation (click, type, navigate, take screenshots)
  • Tab management
  • Browser installation
  • PDF generation (requires --caps=pdf)
  • Test assertions (requires --caps=testing)
  • Coordinate-based interaction (requires --caps=vision)
  • Tracing (requires --caps=tracing)

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

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

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

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

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

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

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later