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
8.79M downloads
22.8K stars

Playwright MCP is a Model Context Protocol server that enables browser automation using structured accessibility snapshots instead of screenshots. This approach allows language models to interact with web pages efficiently through a structured data format without requiring vision models.

Installation

To use the Playwright MCP server, you need to install it with your MCP client. The installation process is straightforward with most tools.

Standard Configuration

The following configuration works with most MCP clients:

{
  "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

Configuration Options

You can customize the Playwright MCP server behavior by providing additional arguments in the configuration:

npx @playwright/mcp@latest --help

Some common configuration options include:

  • --browser <browser>: Specify which browser to use (chrome, firefox, webkit, msedge)
  • --headless: Run the browser in headless mode
  • --viewport-size <size>: Set browser viewport size (e.g., "1280x720")
  • --isolated: Keep the browser profile in memory, not saving to disk
  • --user-data-dir <path>: Specify path to user data directory
  • --block-service-workers: Block service workers
  • --ignore-https-errors: Ignore HTTPS errors

Using a Configuration File

For more advanced setups, you can use a JSON configuration file:

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

Browser Profiles

You can use Playwright MCP in different profile modes:

Persistent Profile (Default)

All logged-in information is stored in the profile. Default locations vary by platform:

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

You can override this location with the --user-data-dir argument.

Isolated Mode

In isolated mode, each session starts with a fresh profile:

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

Running as a Standalone Server

You can run the MCP server as a standalone service by specifying a port:

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 several tool categories:

Core Automation Tools

  • browser_snapshot: Capture accessibility snapshot of the current page
  • browser_navigate: Navigate to a URL
  • browser_click: Click on elements
  • browser_type: Type text into elements
  • browser_hover: Hover over elements
  • browser_select_option: Select options in dropdowns
  • browser_fill_form: Fill multiple form fields
  • browser_wait_for: Wait for text or time
  • browser_take_screenshot: Take a screenshot
  • browser_close: Close the browser

Additional Capabilities

The server also offers optional capabilities:

  • Tab management: Create, close, or select browser tabs
  • PDF generation: Save pages as PDF files
  • Coordinate-based interactions: Click, drag, and move using coordinates
  • Test assertions: Verify elements and text

Example Usage

To perform a basic web interaction:

  1. Start with browser_navigate to go to a URL
  2. Use browser_snapshot to get an accessibility tree of the page
  3. Find elements in the snapshot and interact with them using tools like browser_click or browser_type
  4. Take screenshots or perform assertions as needed

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