Skip to content

ssv445/playwright-mcp-wrapper

Repository files navigation

Playwright MCP Server Manager

Reliable Playwright MCP servers for Docker/DevContainer development

The Problem This Solves

When developing inside Docker containers, you can't run browsers directly in the container. To use Playwright via MCP, you need to:

  1. Run Playwright MCP servers on your host machine
  2. Connect from your container to the host ports
  3. 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 and How

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:

  1. Process Management: Uses PM2 to spawn and monitor 6 separate Playwright MCP server processes
  2. Auto-Recovery: Monitors each server process and automatically restarts them when they crash or become unresponsive
  3. Port Allocation: Assigns dedicated ports (8931-8936) to each browser type for consistent access
  4. Container Bridge: Exposes servers on host network interfaces so containers can connect via host.docker.internal or host IP
  5. 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.

Quick Start

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

🧪 MCP Client Configuration

Configure your project to use these Playwright MCP servers based on your environment:

📋 Local Development

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"
      }
    },
  }
}

🐳 DevContainer/Docker

For containers, replace localhost with:

  • Docker: host.docker.internal:[PORT]/sse
  • Alternative: Your host IP like 192.168.1.100:[PORT]/sse

🌐 All Available Browsers

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

🔍 Testing Your Configuration

npm test   # Verify all servers are responding

This tests both MCP and SSE endpoints for all browsers and reports their status.

Customization

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.

About

A wrapper for PlayWright MCP server, to manage it easily for devcontainers

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published