BAP MCP Server
MCP (Model Context Protocol) server that gives any MCP-compatible AI agent full browser control. Translates MCP tool calls into BAP protocol commands, which drive a real browser via Playwright.Architecture
- AI agent sends tool calls via MCP (stdio transport)
- BAP MCP server translates them to BAP protocol
- BAP Playwright server controls the browser via Playwright
- Results flow back to the agent
Two Modes
Standalone Mode (default)
Auto-starts a BAP Playwright server as a child process. No separate server setup needed. Just
run the MCP server and it handles everything.
Connected Mode
Connects to an externally-managed BAP Playwright server via
--url. Use when you want to share
a single server across multiple MCP clients or manage the server lifecycle yourself.Standalone Mode
Connected Mode
Start a BAP server externally, then point the MCP server at it:Quick Start
Connect from your AI agent
The server communicates over stdio. Configure your MCP client to launch the command above.
Event Streaming
Browser console errors and 4xx/5xx network responses are automatically forwarded to connected MCP clients asnotifications/message log entries. No configuration needed — your agent is notified of errors as they happen.
CLI Options
Browser to use:
chrome, chromium, firefox, webkit, edge.Connect to an existing BAP server (skips auto-start). Example:
ws://localhost:9222.Port for the auto-started server (standalone mode only).
Run browser in headless mode (default).
Show the browser window.
Comma-separated list of allowed domains. Supports wildcards (e.g.,
*.example.com).Run the Playwright server in-process. See In-Process Mode.
Enable verbose logging to stderr.
Programmatic Usage
Troubleshooting
Connection closed on Windows
Connection closed on Windows
On native Windows (not WSL), use the
cmd /c wrapper in your MCP client config:Server not starting
Server not starting
Ensure Playwright browsers are installed:
bash npx playwright install chromium Local Chrome not found
Local Chrome not found
The MCP server tries your local Chrome first. If not found, it falls back to bundled Chromium with a warning. To use a specific browser, pass
--browser chromium or --browser firefox.