Playwright MCP Docker Environment
RemoteAbout Playwright MCP Docker Environment
Playwright MCP Docker Environment is a Docker Compose setup for running the @playwright/mcp server. It suits users who want to deploy the Playwright MCP server in a container and connect it to clients such as Cline or Cursor. The repository is no longer maintained, and the official Playwright MCP repository now provides its own Docker image and setup instructions.
Key features
- 01Run the @playwright/mcp server with Docker Compose
- 02Configure port and run mode through a .env file
- 03Switch between headless and headed browser modes
- 04Example SSE client configuration for MCP clients
Use cases
- 01Run a containerized Playwright MCP server for local clients
- 02Run a headed browser under WSLg
MCP support
This project runs the @playwright/mcp server and exposes it over SSE so that MCP clients such as Cline or Cursor can connect.
Configuration
Remote servers need no local install. Pick your client, then copy the config or install in one click.
http://localhost:8931/sseclaude mcp add --transport http playwright-mcp-docker http://localhost:8931/sse{"mcpServers":{"playwright-mcp-docker":{"type":"http","url":"http://localhost:8931/sse"}}}Open in Cursor{"servers":{"playwright-mcp-docker":{"type":"http","url":"http://localhost:8931/sse"}}}Open in VS Code{"mcpServers":{"playwright-mcp-docker":{"type":"http","url":"http://localhost:8931/sse"}}}{"mcpServers":{"playwright-mcp-docker":{"serverUrl":"http://localhost:8931/sse"}}}Run commands in a terminal; paste JSON into the client’s MCP config and restart. Servers that need sign-in will prompt on first connect.
Tools
Details
From the project READMEImportant
This repository is no longer maintained.
Please refer to the official Playwright MCP repository for its Docker image and setup instructions. Playwright CLI is also available as an alternative, particularly for coding-agent workflows:
Playwright MCP Docker Environment
日本語版はこちら (Japanese version here)
This project provides a Docker Compose environment to run the @playwright/mcp server. It allows you to easily set up and manage the Playwright MCP server for use with clients like Cline or Cursor.
Prerequisites
- Docker
- Docker Compose
Setup
- Clone the repository:
git clone <repository-url> cd playwright-mcp-docker - Create
.envfile: Copy the sample environment file:cp .env.sample .env - Configure
.env: Edit the.envfile to adjust settings according to your environment and preferences:MCP_HOST_PORT: The port on the host machine that the MCP server will be accessible through (default:8931).HEADLESS: Set totruefor headless mode (no browser GUI) orfalsefor headed mode (requires GUI setup). Default istrue.- (Headed Mode Only)
DISPLAY,WAYLAND_DISPLAY,XDG_RUNTIME_DIR: Environment variables needed for GUI applications in Linux environments (especially WSLg). Defaults are provided. - (Headed Mode Only)
X11_HOST_PATH,WSLG_HOST_PATH: Host paths for X11 and WSLg sockets/directories. Defaults are provided. Adjust if your system configuration differs. For Windows Docker accessing WSL paths, use the\\wsl.localhost\DistroName\...format (see.env.sample).
Running the Server
-
Build and start the container:
docker-compose up --build -dThe
--buildflag is only needed the first time or whenDockerfilechanges. The-dflag runs the container in detached mode (in the background). -
Configure MCP Client (e.g., VSCode/Cline):
- Add or enable an MCP server named
playwright_sse(or any name you prefer). - Set the connection type to SSE.
- Set the URL to
http://localhost:<MCP_HOST_PORT>/sse(replace<MCP_HOST_PORT>with the value from your.envfile, e.g.,http://localhost:8931/sse). - Example client configuration (filename depends on the client):
{ "mcpServers": { "playwright_sse": { // Server name is arbitrary "url": "http://localhost:8931/sse" // Match the port number in .env } } } - Add or enable an MCP server named
Configuration Details
.envfile: Manages environment-specific settings like ports, headless mode, and paths for headed mode.docker-compose.yml: Defines the Docker service, reads variables from.env, sets up port mapping and volumes.Dockerfile: Defines the Docker image, installs@playwright/mcpand its dependencies (including Chrome).entrypoint.sh: Script that runs when the container starts, passing the correct arguments (--headlessor--port) to thenpx @playwright/mcpcommand based on theHEADLESSenvironment variable.
Switching Modes
- Headless Mode: Set
HEADLESS=truein.env. Restart the container:docker-compose up -d. - Headed Mode: Set
HEADLESS=falsein.env. Ensure your host environment (e.g., WSLg or X Server) is correctly set up. Restart the container:docker-compose up -d.
Headed Mode Notes (WSLg)
- If you are using WSLg on Windows, the default settings in
docker-compose.ymland the WSL2-specific paths in.env.sampleshould generally work. Ensure the paths in your.envmatch your WSL distribution name if it's notUbuntu. - If you are not using WSLg (e.g., standard Linux desktop or macOS/Windows with a separate X Server), you will need to adjust the
DISPLAYvariable and potentially the volume mounts (X11_HOST_PATH) in your.envfile according to your X Server setup.
Stopping the Server
docker-compose down
Comments
New to MCP?
From what the protocol is to installing your first server, these answers cover most first questions.
An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.