Playwright SSE MCP Server

by torohash
Verified

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

Integrations

  • Provides containerized environment for running the Playwright MCP server, allowing integration with other services through Docker networks and environment variables for deployment flexibility.

  • Offers specific configuration options for running the Playwright MCP server in Linux environments, including special network addressing considerations.

  • Provides persistence options for the server, allowing automatic startup on system reboot through a dedicated persistent mode.

playwright-sse-mcp-server

This is a service that provides Playwright as an MCP (Model Context Protocol) server. By using this server, you can use Playwright functions from an MCP client.

Prerequisites

  • Docker installed
  • Docker-compose installed
  • A Docker network named mcp-network has been created.

If the mcp-network does not exist, you can create it with the following command:

docker network create mcp-network

How to set up and start

  1. Clone or download the repository
  2. Run the following command in the project root directory:
docker compose up --build

This will start the server on the default port 3002. Once it's finished, you'll see a message like this:

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

Configuring a Custom Port

If you want to start the server on a port other than the default port (3002), set PORT environment variable:

PORT=4000 docker compose up --build

This will start the server on the port you specify (4000 in this example):

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

How to use

Connections from containers participating in the same mcp-network

From other containers participating in the same mcp-network, you can connect to the server with the following URL (where PORT is the server's startup port):

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

If you are using the default ports:

playwright-sse-mcp-server:3002/sse

This allows you to take advantage of Playwright's MCP functionality.

Connecting from the host side

From the host machine, you can connect to the server with the following URL (where PORT is the server's running port):

localhost:${PORT}/sse

If you are using the default ports:

localhost:3002/sse

Connecting from Roo Code

MCP Servers -> Edit MCP Settings -> Fill in the following ( PORT is the server start port):

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

If you are using the default ports:

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

*As of March 27, 2025, Cline does not support SSE and cannot be used.

Connecting from Roo Code in a container environment

From a Roo Code container running in the same Docker Network, configure the MCP as follows:

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

docker-compose.yml configuration example :

services: # Roo Code コンテナ roo-code: # 略 networks: mcp-network: external: true

With this setting, you can connect to the playwright-sse-mcp-server container from the Roo Code container and use the browser operation function. By using the container name ( playwright-sse-mcp-server ) as the hostname, name resolution is possible within the Docker Network.

Connecting from Roo Code in a development container environment (via host)

If you want to run Roo Code in a development container and connect to this MCP server via your host machine without joining mcp-network , configure the MCP as follows:

For Docker Desktop (Mac/Windows):

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

For Linux (example: using the bridge gateway IP):

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

Note:

  • Replace <PORT> with the port number that your MCP server exposes on your host (default: 3002).
  • For Linux, replace 172.17.0.1 with your host IP address or the gateway IP address of your Docker bridge network, see the Connecting from Development Containers (via Host) section for more information.

Connecting from a development container (via the host)

If you need to access this MCP server from a development container that is not part of mcp-network (e.g. when it is difficult to change the network due to an existing project), you can connect via the host machine.

With this method, you specify the IP address or special DNS name of the "host machine" from the perspective of your development container, and the port that the MCP server exposes on the host (set by ports in compose.yml , default is 3002).

Destination URL:

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

Replace <PORT> with the port number on which the MCP server is running.

How to determine <host_ip_or_dns_name> :

  • Docker Desktop (Mac/Windows): You can use the special DNS name host.docker.internal .
    • Example: http://host.docker.internal:3002/sse
  • Linux:
    • Host IP Address: Use the IP address assigned to a network interface on the host machine (for example, found with ifconfig or ip addr commands).
      • Example: http://192.168.1.10:3002/sse (IP address may vary depending on your environment)
    • Docker bridge network gateway: You can use the gateway IP address of the Docker default bridge network ( bridge ), usually 172.17.0.1 . You can check it with docker network inspect bridge command.
      • Example: http://172.17.0.1:3002/sse

Please note:

  • Depending on your host's firewall settings, your development container may not be allowed to access ports on the host.
  • Check the port number to use with docker compose ps command or in compose.yml file.

Convenient usage

It is tedious to go to the project directory and run the docker compose command every time. Using the following method, you can easily start and stop the server from anywhere.

Shell script method

This project contains shell scripts to easily start and stop the server and view logs.

  1. Clone or download the project:
# 任意のディレクトリにクローン git clone https://github.com/torohash/playwright-sse-mcp-server.git /path/to/installation
  1. Add the following line to .bashrc (or .zshrc or whatever shell configuration file you're using) to include the shell script:
# Playwright MCP Server export PLAYWRIGHT_MCP_HOME="/path/to/installation" source "$PLAYWRIGHT_MCP_HOME/scripts/playwright-mcp.sh" # 具体例(絶対パス利用) export PLAYWRIGHT_MCP_HOME="$HOME/mcps/playwright-sse-mcp-server" # 実際のパスに置き換えてください source "$PLAYWRIGHT_MCP_HOME/scripts/playwright-mcp.sh"
  1. Restart your shell or reload the configuration file:
source ~/.bashrc

Now you can use the following command from anywhere:

Basic Usage

  • playwright-mcp-start - Starts the server with default settings (port 3002, no restart)
  • playwright-mcp-stop - Stop the server
  • playwright-mcp-logs - View server logs

Using Persistent Mode

Persistent mode will ensure that the server starts automatically on system reboot:

playwright-mcp-start -p # または playwright-mcp-start --persistent

Using a Custom Port

playwright-mcp-start -P 4000 # または playwright-mcp-start --port 4000

Combining Persistence Mode with Custom Ports

playwright-mcp-start -P 4000 -p # または playwright-mcp-start --port 4000 --persistent

Specifying a Specific Restart Policy

playwright-mcp-start -r always # または playwright-mcp-start --restart always

Getting Help

playwright-mcp-start -h # または playwright-mcp-start --help

This method is easier to use because it provides more flexibility in changing settings using flag options, and by separating the shell scripts into separate files, the .bashrc file is simpler and easier to maintain.

Customizing the shell script

The shell script is located at scripts/playwright-mcp.sh . You can edit this file to customize it as needed.

environmental variables

The shell script uses the following environment variables:

  • PLAYWRIGHT_MCP_HOME : Project installation directory, if not set it will be automatically detected from the location of the script.

For example, you can specify a custom path by setting an environment variable like this:

export PLAYWRIGHT_MCP_HOME="/path/to/custom/installation"

Notes

  • This server runs Playwright in headless mode
  • The server communicates with the MCP client using SSE (Server-Sent Events)
ID: g7db39ipsk