Environment Variables
PLAYWRITER_AUTO_ENABLE
Automatically create a tab when Playwright connects, without requiring a manual extension click.The CLI enables this by default. This is only needed for MCP server usage.
about:blank. The AI can navigate it to any URL.
PLAYWRITER_HOST
Connect to a remote relay server instead of starting a local one. Values:- Remote tunnel URL:
https://my-machine-tunnel.traforo.dev - LAN IP address:
192.168.1.10 - Docker host:
host.docker.internal
PLAYWRITER_TOKEN
Authentication token for remote relay servers. Required when connecting to a relay server started withplaywriter serve --token <secret>.
PLAYWRITER_PORT
Override the default relay server port (19988).Not needed when using traforo tunnels, which handle port mapping automatically.
Command-Line Arguments
Alternatively, pass configuration as command-line arguments:--host <url>- Remote relay server URL or IP--token <secret>- Authentication token
Docker & Devcontainer Setup
Run the MCP server inside a container while controlling Chrome on the host machine.Architecture
Step 1: Host Machine
Start the relay server on the host (where Chrome is running):--host localhost binds to 127.0.0.1 so no token is needed. Docker containers reach it through host.docker.internal.
Step 2: Container Configuration
Configure the MCP server to connect to the host:Platform Support
| Platform | Works out of the box? | Notes |
|---|---|---|
| macOS (Docker Desktop) | Yes | Supported since Docker Desktop 18.03 |
| Windows (Docker Desktop) | Yes | Supported since Docker Desktop 18.03 |
| Linux (Docker Engine) | No | Requires --add-host (see below) |
Linux Setup
On Linux,host.docker.internal must be added explicitly:
Devcontainer Configuration
In.devcontainer/devcontainer.json:
Configuration by Environment
Local Development (Default)
No configuration needed. The MCP server starts a local relay automatically:Docker/Devcontainer
Connect to the host machine’s relay server:Remote Machine (Internet)
Connect through a traforo tunnel:LAN (Same Network)
Connect directly via IP address:Security Best Practices
Store tokens securely
Never commit tokens to version control. Use environment variables or secret managers.
Bind to localhost when possible
Use
playwriter serve --host localhost for local-only access (no token required)Troubleshooting
Cannot connect to remote relay server
Error:Cannot connect to remote relay server at <host>
Solution: Make sure playwriter serve is running on the host machine:
Connection refused from Docker
Error:ECONNREFUSED when connecting to host.docker.internal
Solutions:
- Verify relay is running on host:
playwriter serve --host localhost - On Linux, add
--add-host=host.docker.internal:host-gateway - Check firewall rules aren’t blocking port 19988
Token authentication failed
Error:401 Unauthorized
Solution: Ensure PLAYWRITER_TOKEN matches the token used in playwriter serve --token <secret>
Next Steps
Remote Access
Control Chrome on remote machines over the internet
CLI Usage
Use the recommended CLI workflow instead of MCP