Reliable Playwright MCP servers for Docker/DevContainer development
When developing inside Docker containers, you can't run browsers directly in the container. To use Playwright via MCP, you need to:
- Run Playwright MCP servers on your host machine
- Connect from your container to the host ports
- Deal with frequent crashes of the MCP servers during development
This wrapper solves the crashing problem by using PM2 to automatically restart Playwright MCP servers when they crash, making container-based development reliable.
What it does: This tool creates a reliable bridge between containerized development environments and browser automation by running persistent Playwright MCP servers on your host machine.
How it works:
- Process Management: Uses PM2 to spawn and monitor 6 separate Playwright MCP server processes
- Auto-Recovery: Monitors each server process and automatically restarts them when they crash or become unresponsive
- Port Allocation: Assigns dedicated ports (8931-8936) to each browser type for consistent access
- Container Bridge: Exposes servers on host network interfaces so containers can connect via
host.docker.internal
or host IP - Zero Configuration: Pre-configured browser settings, profiles, and output directories eliminate manual setup
Result: Developers get reliable, always-available browser automation from any container without dealing with crashes or complex networking setup.
npm install -g pm2 playwright # Install dependencies
npm install # Install project
npm start # Start all browsers
npm stop # Stop all servers
npm test # Test all endpoints
Configure your project to use these Playwright MCP servers based on your environment:
Simple MCP server configuration, change the port and names as per your need.
{
"mcpServers": {
"playwright-chrome": {
"transport": {
"type": "sse",
"url": "http://localhost:8932/sse"
}
},
"playwright-brave": {
"transport": {
"type": "sse",
"url": "http://localhost:8933/sse"
}
},
}
}
For containers, replace localhost
with:
- Docker:
host.docker.internal:[PORT]/sse
- Alternative: Your host IP like
192.168.1.100:[PORT]/sse
Browser | Port | Profile Type |
---|---|---|
Chrome | 8932 | Default |
Brave | 8933 | Default |
Firefox | 8934 | Default |
Chromium | 8931 | Default |
WebKit | 8935 | Default |
Comet | 8936 | Default |
Brave Persistent | 8941 | Persistent |
Comet Persistent | 8942 | Persistent |
npm test # Verify all servers are responding
This tests both MCP and SSE endpoints for all browsers and reports their status.
Edit configuration files as needed:
- PM2 settings:
ecosystem.config.js
- Browser settings:
configs/[browser].json
- Profiles: Store in
profiles/
directory
All servers auto-restart on crash with memory limits and structured logging.