Playwright MCP server

Provides browser automation capabilities through Playwright integration, enabling navigation, element interaction, screenshot capture, form handling, file uploads, PDF generation, tab management, and both accessibility tree and vision-based web control for scraping, testing, and automated workflows.
Back to servers
Setup instructions
Provider
Lewis von Cken
Release date
Jul 01, 2025
Language
JavaScript

The Playwright MCP server provides browser automation capabilities using Playwright, enabling LLMs to interact with web pages through structured accessibility snapshots. This lightweight solution doesn't require screenshots or visually-tuned models, making it ideal for automated web interaction.

Installation

The Playwright MCP server can be installed with your MCP client. A typical configuration looks like this:

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

Prerequisites

  • Node.js 18 or newer
  • VS Code, Cursor, Windsurf, Claude Desktop or any other MCP client

Installation for Specific Clients

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.

Claude Code Installation

Use the Claude Code CLI to add the Playwright MCP server:

claude mcp add playwright npx @playwright/mcp@latest

Configuration Options

The Playwright MCP server supports various configuration arguments that can be provided in the JSON configuration as part of the "args" list:

npx @playwright/mcp@latest --help

Key Configuration Options

  • --allowed-origins <origins>: Semicolon-separated list of origins to allow
  • --blocked-origins <origins>: Semicolon-separated list of origins to block
  • --browser <browser>: Browser to use (chrome, firefox, webkit, msedge)
  • --headless: Run browser in headless mode (headed by default)
  • --isolated: Keep browser profile in memory, not saving to disk
  • --vision: Use screenshots instead of accessibility snapshots

User Profile Options

You can run Playwright MCP with:

  1. Persistent profile (default): All logged-in information is stored in a persistent profile
  2. Isolated mode: Each session starts in an isolated profile

Persistent Profile 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

Isolated Mode Configuration

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

Using a Configuration File

You can specify a JSON configuration file:

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

Running as Standalone Server

For environments without a display or from worker processes of IDEs:

npx @playwright/mcp@latest --port 8931

Then in your MCP client config:

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

Usage Modes

The tools are available in two modes:

1. Snapshot Mode (Default)

Uses accessibility snapshots for better performance and reliability

2. Vision Mode

Uses screenshots for visual-based interactions. Enable with:

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

Available Tools

Interaction Tools

  • browser_snapshot: Capture accessibility snapshot of current page
  • browser_click: Perform click on a web page
  • browser_drag: Perform drag and drop between two 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 or time to pass
  • browser_file_upload: Upload one or multiple files
  • browser_handle_dialog: Handle dialog boxes

Navigation Tools

  • browser_navigate: Navigate to a URL
  • browser_navigate_back: Go back to previous page
  • browser_navigate_forward: Go forward to 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 network requests
  • browser_console_messages: Get console messages

Utility Tools

  • browser_install: Install the browser specified in config
  • browser_close: Close the page
  • browser_resize: Resize 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