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
811.9K downloads
13.4K stars

The Playwright MCP server provides browser automation capabilities using Playwright, enabling Large Language Models (LLMs) to interact with web pages through structured accessibility snapshots rather than requiring screenshots or visually-tuned models.

Installation

The Playwright MCP server can be installed and configured with various MCP clients. The basic installation requires Node.js 18 or newer and a compatible MCP client like VS Code, Cursor, Windsurf, or Claude Desktop.

Basic Installation

Install the Playwright MCP server with this typical configuration:

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

VS Code Installation

You can install the Playwright MCP server using the VS Code CLI:

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

Cursor Installation

Go to Cursor Settings -> MCP -> Add new MCP Server. Name it to your liking, use command type with the command npx @playwright/mcp. You can verify config or add command arguments by clicking Edit.

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

Configuration Options

The Playwright MCP server supports various command-line arguments that can be provided in the JSON configuration:

npx @playwright/mcp@latest --help

Key configuration options include:

  • --browser <browser>: Choose the browser to use (chrome, firefox, webkit, msedge)
  • --headless: Run browser in headless mode (headed by default)
  • --isolated: Keep the browser profile in memory, not on disk
  • --vision: Run server that uses screenshots (Aria snapshots used by default)
  • --port <port>: Port to listen on for SSE transport
  • --allowed-origins <origins>: Semicolon-separated list of origins to allow
  • --blocked-origins <origins>: Semicolon-separated list of origins to block

User Profiles

The Playwright MCP server can run in two profile modes:

Persistent Profile (Default)

All logged-in information is stored in a persistent profile. Default locations:

# 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 the location with the --user-data-dir argument.

Isolated Mode

In isolated mode, each session starts with a fresh profile. Storage state is lost when the browser closes:

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

Configuration File

You can specify a JSON configuration file using the --config option:

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

The configuration file can include browser settings, server configuration, capabilities, network settings, and more.

Standalone MCP Server

For running a headed browser on systems without display or from worker processes:

npx @playwright/mcp@latest --port 8931

Then in the MCP client config, set the URL to the SSE endpoint:

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

Using the Tools

The server provides tools in two modes:

Snapshot Mode (Default)

Uses accessibility snapshots for better performance and reliability.

Vision Mode

Uses screenshots for visual-based interactions. Enable with the --vision flag:

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

Available Tool Categories

Interaction Tools

  • browser_snapshot: Capture accessibility snapshot of the current page
  • browser_click: Perform click on a web page
  • browser_drag: Perform drag and drop between elements
  • browser_hover: Hover over element on page
  • browser_type: Type text into editable element
  • browser_select_option: Select an option in a dropdown
  • browser_press_key: Press a key on the keyboard
  • browser_wait_for: Wait for text to appear/disappear

Navigation Tools

  • browser_navigate: Navigate to a URL
  • browser_navigate_back: Go back to the previous page
  • browser_navigate_forward: Go forward to the next page

Resource Tools

  • browser_take_screenshot: Take a screenshot of the current page
  • browser_pdf_save: Save page as PDF
  • browser_network_requests: List all network requests
  • browser_console_messages: Get console messages

Utility Tools

  • browser_install: Install the browser specified in the config
  • browser_close: Close the page
  • browser_resize: Resize the browser window

Tab Management

  • browser_tab_list: List browser tabs
  • browser_tab_new: Open a new tab
  • browser_tab_select: Select a tab by index
  • browser_tab_close: Close a tab

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