home / mcp / playwright mcp server

Playwright MCP Server

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

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "angeluis001-playwright-mcp": {
      "url": "http://localhost:8931/sse"
    }
  }
}

The Playwright MCP Server lets you control and automate web pages through a structured accessiblity snapshot interface. It avoids pixel-based interactions, enabling language models to interact with pages deterministically and efficiently by using the browser’s accessibility tree.

How to use

Use the Playwright MCP Server with an MCP client to drive browser automation tasks. You can run the server either as a remote HTTP endpoint or as a local stdio process started via a command like npx. In your client configuration, point to the SSE URL for the HTTP option or launch the local process and connect through the stdio channel.

Two connection methods are shown here. Use the HTTP method to connect to a running SSE endpoint, or use the stdio method to start the MCP server as a local process with a command like npx. Both methods expose the same set of browser interaction tools, such as clicking, typing, navigating, and taking accessibility snapshots.

{
  "mcpServers": {
    "playwright": {
      "url": "http://localhost:8931/sse"
    }
  }
}
`
{
  "mcpServers": {
    "playwright": {
      "command": "npx",
      "args": [
        "@playwright/mcp@latest"
      ]
    }
  }
}

How to install

Prerequisites: you need Node.js 18 or newer. You also need an MCP client (such as VS Code with an MCP extension, Cursor, Windsurf, Claude Desktop, or others) to connect to the server.

Option A: Run the server locally via CLI (std IO connection). This starts the MCP server in a headless or visible mode depending on your environment.

Option B: Run the server as a remote HTTP SSE endpoint (http connection). This exposes an SSE endpoint you can connect to from your MCP client.

# Start as a local stdio MCP server
npx @playwright/mcp@latest

If you prefer using a remote HTTP endpoint, you can run the server and expose an SSE endpoint on a port you choose. Then configure your MCP client to connect to the endpoint URL.

Configuration and usage notes

The server supports a range of command-line options to tailor browser behavior, including choosing the browser, headless mode, storage state, viewport size, and more. The core options include --browser to select chromium, firefox, webkit, or msedge; --headless to run without a visible browser; and --viewport-size to define the window dimensions. You can also enable an isolated mode for separate sessions that do not persist across runs.

You can run the server with a persistent user profile or in isolated contexts. Persistent profiles store login state and offline data, while isolated contexts start fresh for each session. Example configurations show using --user-data-dir for persistence or --isolated and --storage-state for isolated sessions.

If you need a specific server configuration, you can provide a JSON config file via --config. The file can define browser settings, server host/port, capabilities, vision mode, and network options.

Available tools

browser_snapshot

Capture accessibility snapshot of the current page; faster and more reliable for LLMs than pixel-based screenshots.

browser_click

Click on a web page element using a human-readable target and a precise element reference from the page snapshot.

browser_drag

Drag from one element to another using source and target element references.

browser_hover

Hover the mouse over a page element using a target reference from the page snapshot.

browser_type

Type text into an editable element; supports optional submit and slow typing modes.

browser_select_option

Select an option within a dropdown by values.

browser_press_key

Press a key or character on the keyboard.

browser_wait_for

Wait for specific text to appear or disappear, or wait for a time interval.

browser_file_upload

Upload one or more files by providing absolute paths.

browser_handle_dialog

Handle a browser dialog by choosing to accept and optionally provide prompt text.

browser_navigate

Navigate the current page to a specified URL.

browser_navigate_back

Go back to the previous page.

browser_navigate_forward

Go forward to the next page.

browser_take_screenshot

Take a screenshot of the current page or a specific element; can return as image data.

browser_pdf_save

Save the current page as a PDF file.

browser_network_requests

List all network requests made since page load.

browser_console_messages

Retrieve console messages from the page.

browser_install

Install the browser specified in the config if it is not already installed.

browser_close

Close the browser or the current page.

browser_resize

Resize the browser window to specified width and height.