# Playwright MCP server

> Enables LLMs to interact with web pages through structured accessibility snapshots using Playwright browser automation.

- Repository: https://github.com/microsoft/playwright-mcp
- Page: https://hostedmcp.org/servers/microsoft/playwright-mcp
- Official: yes
- Transport: stdio
- Stars: 39690
- License: Apache-2.0
- Latest version: 0.0.85

## Install

### Claude Code

```sh
claude mcp add playwright-mcp -- npx -y @playwright/mcp
```

### Cursor (`~/.cursor/mcp.json`)

```json
{
  "mcpServers": {
    "playwright-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@playwright/mcp"
      ]
    }
  }
}
```

### VS Code (`.vscode/mcp.json`)

```json
{
  "servers": {
    "playwright-mcp": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "-y",
        "@playwright/mcp"
      ]
    }
  }
}
```

### VS Code CLI

```sh
code --add-mcp '{"name":"playwright-mcp","type":"stdio","command":"npx","args":["-y","@playwright/mcp"]}'
```

### Claude Desktop (`claude_desktop_config.json`)

```json
{
  "mcpServers": {
    "playwright-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@playwright/mcp"
      ]
    }
  }
}
```

### Codex

```sh
codex mcp add playwright-mcp -- npx -y @playwright/mcp
```

### Codex config.toml (`~/.codex/config.toml`)

```toml
[mcp_servers.playwright-mcp]
command = "npx"
args = ["-y", "@playwright/mcp"]
```

### Gemini CLI

```sh
gemini mcp add -s user playwright-mcp npx -- -y @playwright/mcp
```

### Gemini settings.json (`~/.gemini/settings.json`)

```json
{
  "mcpServers": {
    "playwright-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@playwright/mcp"
      ]
    }
  }
}
```

## Tools (25)

- `browser_close`: Close the page
- `browser_resize`: Resize the browser window
- `browser_console_messages`: Returns all console messages (read-only)
- `browser_handle_dialog`: Handle a dialog
- `browser_emulate_media`: Emulate CSS media features for the page, for example switch between the light and dark color scheme. Omitted parameters are left unchanged; null clears an override.
- `browser_evaluate`: Evaluate JavaScript expression on page or element
- `browser_file_upload`: Upload one or multiple files
- `browser_drop`: Drop files or MIME-typed data onto an element, as if dragged from outside the page. At least one of "paths" or "data" must be provided.
- `browser_find`: Search the accessibility snapshot of the current page for text or a regular expression. Returns matching snapshot nodes with a few lines of surrounding context (like search snippets), each shown under its path from the root of the tree, which is cheaper than capturing the whole snapshot when you only need to locate an element and its ref. (read-only)
- `browser_fill_form`: Fill multiple form fields
- `browser_press_key`: Press a key on the keyboard
- `browser_type`: Type text into editable element
- `browser_navigate`: Navigate to a URL
- `browser_navigate_back`: Go back to the previous page in the history
- `browser_network_requests`: Returns a numbered list of network requests since loading the page. Use browser_network_request with the number to get full details. (read-only)
- `browser_network_request`: Returns full details (headers and body) of a single network request, or a single part if `part` is set. Use the number from browser_network_requests. (read-only)
- `browser_run_code_unsafe`: Run a Playwright code snippet. Unsafe: executes arbitrary JavaScript in the Playwright server process and is RCE-equivalent.
- `browser_take_screenshot`: Take a screenshot of the current page. Use browser_snapshot for actions by default. With the vision capability enabled, use screenshot coordinates with the coordinate-based mouse tools for elements not exposed in the accessibility snapshot. (read-only)
- `browser_snapshot`: Capture accessibility snapshot of the current page, this is better than screenshot (read-only)
- `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_select_option`: Select an option in a dropdown
- `browser_tabs`: List, create, close, or select a browser tab.
- `browser_wait_for`: Wait for text to appear or disappear or a specified time to pass. When both text and textGone are provided, waits for the first one to happen (read-only)

## FAQ

### How does Playwright MCP differ from the Playwright CLI?

The CLI is more token-efficient for coding agents, while MCP is better for specialized agentic loops requiring persistent state and rich introspection.

### What are the system requirements to run this server?

You need Node.js version 18 or newer installed.
