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
4.55M downloads
19.9K stars

The Playwright MCP server enables LLMs to interact with web pages through structured accessibility snapshots, providing browser automation capabilities without requiring screenshots or vision models. It uses Playwright's accessibility tree to create a fast, lightweight solution for deterministic web interactions.

Installation

To get started with the Playwright MCP server, you'll need Node.js 18 or newer and a compatible MCP client such as VS Code, Cursor, Windsurf, Claude Desktop, or Goose.

Standard Installation

Install the Playwright MCP server with your client using this standard configuration:

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

Client-Specific Installation

VS Code

You can install in VS Code manually by going to the settings, then to MCP section, and adding a new MCP server with the configuration above. Alternatively, use the VS Code CLI:

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

Cursor

Go to Cursor SettingsMCPAdd new MCP Server. Name it as you prefer, use command type with the command npx @playwright/mcp@latest.

Claude Desktop/Windsurf/Others

For other MCP clients, follow their respective documentation for adding MCP servers and use the standard configuration provided above.

Configuration Options

The Playwright MCP server supports various configuration options that can be passed as arguments:

Basic Options

npx @playwright/mcp@latest --browser chrome  # Choose browser: chrome, firefox, webkit, msedge
npx @playwright/mcp@latest --headless        # Run in headless mode (default is headed)
npx @playwright/mcp@latest --viewport-size "1280, 720"  # Set viewport size

User Profile Options

By default, Playwright MCP uses a persistent profile that stores login information. You have three profile options:

  1. Persistent Profile (Default):

    • Login information is saved between sessions
    • Located in system-specific folders (can be overridden with --user-data-dir)
  2. Isolated Mode:

    • Each session starts with a clean profile
    • Data is lost when browser is closed
    npx @playwright/mcp@latest --isolated
    
  3. Browser Extension:

    • Connect to existing browser tabs with --extension flag
    • Leverage your logged-in sessions

Network Options

# Allow only specific origins
npx @playwright/mcp@latest --allowed-origins "example.com;github.com"

# Block specific origins
npx @playwright/mcp@latest --blocked-origins "ads.example.com;tracking.com"

# Ignore HTTPS errors
npx @playwright/mcp@latest --ignore-https-errors

# Configure proxy
npx @playwright/mcp@latest --proxy-server "http://myproxy:3128"

Using a Configuration File

Instead of command-line arguments, you can use a JSON configuration file:

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

Example configuration file:

{
  "browser": {
    "browserName": "chromium",
    "isolated": false,
    "launchOptions": {
      "channel": "chrome",
      "headless": false
    },
    "contextOptions": {
      "viewport": {
        "width": 1280,
        "height": 720
      }
    }
  },
  "server": {
    "port": 8931,
    "host": "localhost"
  },
  "capabilities": ["tabs", "pdf"],
  "network": {
    "allowedOrigins": ["example.com", "github.com"],
    "blockedOrigins": ["ads.example.com"]
  }
}

Running as a Standalone Server

To run the MCP server on a system without display or from worker processes:

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 a comprehensive set of tools for browser automation:

Core Automation Tools

  • Page Navigation: Navigate to URLs, go back, take snapshots
  • Element Interaction: Click, hover, type, fill forms, select options
  • Keyboard/Mouse: Press keys, handle dialogs
  • Information Gathering: Get console messages, network requests

Additional Capabilities

Enable additional capabilities using the --caps flag:

# Enable PDF generation
npx @playwright/mcp@latest --caps pdf

# Enable coordinate-based interactions
npx @playwright/mcp@latest --caps vision

# Enable multiple capabilities
npx @playwright/mcp@latest --caps "vision,pdf"

With these tools, you can automate nearly any browser interaction through your MCP client, enabling AI assistants to effectively navigate and interact with web content.

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