playwright-browser-mcp
v1.0.0
Published
A lightweight wrapper around [`@playwright/mcp`](https://github.com/nicholasgriffintn/playwright-mcp) that automatically starts a Chrome instance and connects it to a Playwright MCP server via the Chrome DevTools Protocol (CDP).
Readme
playwright-browser-mcp
A lightweight wrapper around @playwright/mcp that automatically starts a Chrome instance and connects it to a Playwright MCP server via the Chrome DevTools Protocol (CDP).
What it does
- Launches Chrome using
simple-browser - Auto-detects an available CDP port (starting from 9222)
- Starts the
@playwright/mcpserver connected to that browser
This gives MCP clients (like Claude Code) full browser automation capabilities — clicking, typing, navigating, taking screenshots, and more — without manual browser setup.
Prerequisites
- Node.js and npm
lsof(standard on macOS/Linux)
Quick start
With npx (no install)
npx --yes playwright-browser-mcp@latestInstallation
Claude Code
claude mcp add playwright -- npx --yes playwright-browser-mcp@latestOr add to your project's .mcp.json:
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": ["--yes", "playwright-browser-mcp@latest"]
}
}
}Cursor
Go to Cursor Settings > MCP > Add new global MCP server and paste:
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": ["--yes", "playwright-browser-mcp@latest"]
}
}
}Codex CLI
codex mcp add playwright -- npx --yes playwright-browser-mcp@latestGemini CLI
gemini mcp add playwright npx --yes playwright-browser-mcp@latestOr add to ~/.gemini/settings.json (user-level) or .gemini/settings.json (project-level):
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": ["--yes", "playwright-browser-mcp@latest"]
}
}
}CLI flags
| Flag | Default | Description |
|------|---------|-------------|
| --port <N> | Auto-detected from 9222 | Chrome CDP debugging port |
| --output-dir <path> | .playwright-mcp/output | Directory for screenshots and artifacts |
| --cdp-endpoint <url> | http://localhost:<port> | CDP endpoint URL (overrides port) |
All other arguments are passed through to @playwright/mcp.
Examples
# Use a specific port
./main.sh --port 9333
# Custom output directory
./main.sh --output-dir ./screenshots
# Connect to an existing Chrome instance
./main.sh --cdp-endpoint http://localhost:9222How it works
- On first run, the wrapper finds an available port starting from 9222 and saves it to
.playwright-mcp/port.txtfor reuse across runs. - Chrome is started via
simple-browser(fetched automatically via npx). - The
@playwright/mcpserver is then launched with--cdp-endpointpointing at the running Chrome instance.
Port persistence
The chosen port is persisted to .playwright-mcp/port.txt. Delete this file to force re-detection:
rm .playwright-mcp/port.txtLicense
MIT
