home / mcp / playwright mcp server

Playwright MCP Server

Provides a Playwright-based MCP server that enables persistent, structured browser automation via accessibility snapshots.

Installation
Add the following to your MCP client configuration file.

Configuration

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

Playwright MCP is a server that exposes browser automation capabilities through Playwright using a Model Context Protocol interface. It lets you control web pages via structured accessibility snapshots, enabling language models to reason about page structure without relying on screenshots or vision models. This approach supports persistent contexts, introspection of page structure, and long-running automation workflows.

How to use

To use Playwright MCP, run the server locally and connect your MCP client or coding agent to its HTTP endpoint. You can perform actions, inspect page structure, and capture page data using the MCP tools provided. Choose between a remote HTTP connection for lightweight interactions or a local standard I/O (stdio) setup for persistent, stateful automation.

How to install

Prerequisites: Node.js 18 or newer. Ensure you have a compatible MCP client installed (for example, an editor extension or coding agent that supports MCP). Then install and run the Playwright MCP server using the examples below.

# Start the Playwright MCP server using npx and the latest package
npx @playwright/mcp@latest --port 8931

Configuration

You can configure the server with a JSON configuration object. The standalone setup shown runs with an HTTP transport and a manual client URL configuration.

{
  "mcpServers": {
    "playwright": {
      "type": "http",
      "url": "http://localhost:8931/mcp",
      "args": []
    }
  }
}

Standalone MCP server

If you are running the server on a system with a display or from IDE worker processes, start in an environment with a display and enable HTTP transport.

npx @playwright/mcp@latest --port 8931

Security

Playwright MCP is not a security boundary. Implement appropriate security measures for exposing the MCP endpoint, including network controls, authentication as needed, and following security best practices for model-assisted automation.

Tools and capabilities (high level)

The server provides a set of browser automation actions that can be invoked via the MCP client. These include actions to navigate, interact with elements, capture page state, and inspect network activity, as described in the available tool list.

Initial state and persistence

You can run Playwright MCP with a persistent profile or in isolated mode. A persistent profile stores login state and cookies between sessions. Isolated mode starts every session with a fresh storage state, which can be loaded from a file if desired.

Configuration file details

The configuration file supports options for browser selection, context options, initialization scripts, and more. You can specify options such as browserName, isolated, userDataDir, initPage, and initScript to tailor the Playwright session.

Examples

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

Troubleshooting

If you encounter a browser not installed or a transport error, verify that the server process is running on the expected port and that the MCP client is configured to reach the correct URL. Check logs for any initialization errors and ensure the required Playwright browsers are installed.

Additional notes

The Playwright MCP server emphasizes fast, lightweight interactions based on accessibility data rather than rendering screenshots. This makes it well suited for exploratory automation, long-running autonomous tasks, and workflows where maintaining a browser context is advantageous.

Available tools

Core automation

A collection of actions to interact with and query a web page, such as clicking, navigating, filling forms, and taking snapshots.