home / mcp / playwright mcp server

Playwright MCP Server

Provides Playwright-based browser automation via structured accessibility snapshots for LLMs and MCP clients.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "georgelochner-playwright-mcp-mod": {
      "url": "http://localhost:8931/mcp"
    }
  }
}

Playwright MCP is a lightweight server that exposes browser automation capabilities through Playwright’s accessibility tree. It lets you drive web pages using structured data, which is fast, deterministic, and friendly to language models that don’t rely on pixel-based inputs.

How to use

You connect to the Playwright MCP server from an MCP client (such as VS Code, Windsurf, or Claude) and issue automation commands through a defined tool API. Use the accessible snapshot and context data to navigate pages, interact with elements, and extract information without rendering full screenshots. This approach helps you build reliable automations that remain robust across visual changes.

Typical usage patterns include navigating to URLs, clicking elements, filling forms, taking page snapshots for accessibility, and inspecting network activity. You can also run arbitrary Playwright code snippets against the current page when needed, or manage browser tabs and view console output for debugging.

How to install

Prerequisites you need before installing the Playwright MCP server:

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

Install the Playwright MCP server using the standard configuration. The server runs locally via a package manager command.

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

Standalone MCP server

If you run the server as a standalone process, you can expose it over HTTP so clients connect via a URL. Start the server on a display-enabled system or from an IDE worker process, and provide the HTTP endpoint to your MCP client.

Start the server on port 8931 and connect clients via the HTTP URL.

npx @playwright/mcp@latest --port 8931
```

```json
{
  "mcpServers": {
    "playwright": {
      "url": "http://localhost:8931/mcp"
    }
  }
}

Docker

You can run the Playwright MCP server in Docker as a headless container. The container version is suitable for automated environments and CI pipelines.

{
  "mcpServers": {
    "playwright": {
      "command": "docker",
      "args": ["run", "-i", "--rm", "--init", "--pull=always", "mcr.microsoft.com/playwright/mcp"]
    }
  }
}
```

Or run the container long-lived with a mapped port and an entrypoint for the MCP server:

```bash
docker run -d -i --rm --init --pull=always \
  --entrypoint node \
  --name playwright \
  -p 8931:8931 \
  mcr.microsoft.com/playwright/mcp \
  cli.js --headless --browser chromium --no-sandbox --port 8931

Programmatic usage

You can integrate Playwright MCP directly into a Node.js service. The following snippet shows how to create a connection and expose an SSE transport for client communication.

import http from 'http';

import { createConnection } from '@playwright/mcp';
import { SSEServerTransport } from '@modelcontextprotocol/sdk/server/sse.js';

http.createServer(async (req, res) => {
  // ...

  // Creates a headless Playwright MCP server with SSE transport
  const connection = await createConnection({ browser: { launchOptions: { headless: true } } });
  const transport = new SSEServerTransport('/messages', res);
  await connection.connect(transport);

  // ...
});
```
" 
]},{

Available tools

browser_click

Click on a web page element using a target reference and optional modifiers and mouse button.

browser_close

Close the current page or browser context.

browser_snapshot

Capture an accessibility snapshot of the current page, preferred over pixel-based screenshots.

browser_take_screenshot

Capture a screenshot of the current page or a specific element.

browser_navigate

Navigate the browser to a specified URL.

browser_type

Type text into an editable element with optional submission and speed controls.

browser_wait_for

Wait for specific text to appear, disappear, or a timeout to elapse.

browser_tabs

Manage tabs: list, create, close, or switch between tabs.

browser_console_messages

Retrieve console messages from the page.

browser_run_code

Run a block of Playwright code against the current page.

browser_verify_text_visible

Verify that specific text is visible on the page.

browser_verify_element_visible

Verify that a specific element is visible using accessibility data.