Playwright Browser Automation MCP server

Enables AI models to perform web automation tasks by controlling headless browsers through a server-side Playwright implementation.
Back to servers
Setup instructions
Provider
torohash
Release date
Mar 26, 2025
Language
TypeScript
Stats
6 stars

This server provides Playwright functionality through a Model Context Protocol (MCP) interface, allowing MCP clients to leverage Playwright's browser automation capabilities. The server uses Server-Sent Events (SSE) for communication with clients.

Prerequisites

  • Docker installed
  • docker-compose installed
  • A Docker network named "mcp-network"

If the mcp-network doesn't exist, create it with:

docker network create mcp-network

Installation and Setup

Clone or download the repository and run the server from the project's root directory:

docker compose up --build

This starts the server on the default port 3002. You'll see a confirmation message:

playwright-sse-mcp-server  | Server is running on port 3002

Custom Port Configuration

To run the server on a different port, set the PORT environment variable:

PORT=4000 docker compose up --build

Usage

Connecting from Containers on the Same Network

From other containers on the same mcp-network, connect using:

playwright-sse-mcp-server:${PORT}/sse

With the default port:

playwright-sse-mcp-server:3002/sse

Connecting from the Host Machine

From your host machine, connect using:

localhost:${PORT}/sse

With the default port:

localhost:3002/sse

Connecting from Roo Code

In Roo Code, go to MCP Servers -> Edit MCP configuration and enter:

{
  "mcpServers": {
    "playwright-sse-mcp-server-local": {
      "url": "http://localhost:${PORT}/sse"
    }
  }
}

With the default port:

{
  "mcpServers": {
    "playwright-sse-mcp-server-local": {
      "url": "http://localhost:3002/sse"
    }
  }
}

Note: As of March 27, 2025, Cline does not support SSE.

Connecting from Roo Code Container

From a Roo Code container on the same Docker network:

{
  "mcpServers": {
    "playwright-sse-mcp-server-local": {
      "url": "http://playwright-sse-mcp-server:3002/sse"
    }
  }
}

docker-compose.yml example:

services:
  # Roo Code container
  roo-code:
    # ...

networks:
  mcp-network:
    external: true

Connecting from Development Container (via Host)

When running Roo Code in a development container without joining mcp-network:

For Docker Desktop (Mac/Windows):

{
  "mcpServers": {
    "playwright-sse-mcp-server-local": {
      "url": "http://host.docker.internal:<PORT>/sse"
    }
  }
}

For Linux (using bridge gateway IP):

{
  "mcpServers": {
    "playwright-sse-mcp-server-local": {
      "url": "http://172.17.0.1:<PORT>/sse"
    }
  }
}

Connecting from Development Containers (via Host)

When connecting from a development container not on the mcp-network:

Connection URL:

http://<host_ip_or_dns_name>:<PORT>/sse

Host IP or DNS name determination:

  • Docker Desktop (Mac/Windows): Use host.docker.internal
    • Example: http://host.docker.internal:3002/sse
  • Linux:
    • Use host IP address (found via ifconfig or ip addr)
      • Example: http://192.168.1.10:3002/sse
    • Or use Docker bridge network gateway (usually 172.17.0.1)
      • Example: http://172.17.0.1:3002/sse

Convenience Scripts

This project includes shell scripts to easily manage the server from anywhere.

  1. Clone the repository:
git clone https://github.com/torohash/playwright-sse-mcp-server.git /path/to/installation
  1. Add the following to your .bashrc or .zshrc:
# Playwright MCP Server
export PLAYWRIGHT_MCP_HOME="/path/to/installation"
source "$PLAYWRIGHT_MCP_HOME/scripts/playwright-mcp.sh"
  1. Reload your shell configuration:
source ~/.bashrc

Using the Convenience Commands

  • playwright-mcp-start - Start the server (default port 3002)
  • playwright-mcp-stop - Stop the server
  • playwright-mcp-logs - View server logs

Persistent Mode

playwright-mcp-start -p
# or
playwright-mcp-start --persistent

Custom Port

playwright-mcp-start -P 4000
# or
playwright-mcp-start --port 4000

Combined Options

playwright-mcp-start -P 4000 -p
# or
playwright-mcp-start --port 4000 --persistent

Specific Restart Policy

playwright-mcp-start -r always
# or
playwright-mcp-start --restart always

Show Help

playwright-mcp-start -h
# or
playwright-mcp-start --help

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-sse-mcp-server-local" '{"url":"http://localhost:3002/sse"}'

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-sse-mcp-server-local": {
            "url": "http://localhost:3002/sse"
        }
    }
}

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-sse-mcp-server-local": {
            "url": "http://localhost:3002/sse"
        }
    }
}

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