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).
- 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.
- Node.js and npm
lsof(standard on macOS/Linux)
npx --yes playwright-browser-mcp@latestclaude 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"]
}
}
}Go to Cursor Settings > MCP > Add new global MCP server and paste:
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": ["--yes", "playwright-browser-mcp@latest"]
}
}
}codex mcp add playwright -- npx --yes playwright-browser-mcp@latestgemini 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"]
}
}
}| 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.
# 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:9222- 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.
The chosen port is persisted to .playwright-mcp/port.txt. Delete this file to force re-detection:
rm .playwright-mcp/port.txtMIT