Skip to main content
The BAP MCP server gives any MCP-compatible AI agent full browser control. It auto-starts a Playwright server and exposes browser tools over MCP stdio transport.

One-Command Setup

This starts standalone mode: auto-spawns a BAP Playwright server and bridges MCP tool calls to browser actions. No separate server process needed.

Client Configuration

Available Tools

The MCP server exposes 23 tools by default, grouped by category:
| Tool | Description | |------|-------------| | click | Click an element using semantic selectors | | type | Type text character by character | | fill | Fill a form field (clears existing content) | | press | Press keyboard keys (Enter, Tab, shortcuts) | | select | Select a dropdown option | | scroll | Scroll the page or a specific element | | hover | Hover over an element |
| Tool | Description | |------|-------------| | screenshot | Take a page screenshot | | accessibility | Full accessibility tree | | aria_snapshot | Token-efficient YAML snapshot (~80% fewer tokens) | | content | Page text content as text or markdown | | element | Query element properties (exists, visible, enabled) |
| Tool | Description | |------|-------------| | observe | AI-optimized observation with interactive elements and stable refs. Supports incremental and responseTier | | act | Execute a sequence of browser actions in one call. Supports fused postObserve | | extract | Extract structured data using schema and CSS heuristics |
| Tool | Description | |------|-------------| | pages | List all open pages/tabs | | activate_page | Switch to a different page/tab | | close_page | Close the current page/tab |

Slim Mode

Use --slim to expose only 5 essential tools, reducing tool definitions from ~4,200 to ~600 tokens:
The 5 slim tools: navigate, observe, act, extract, screenshot.
Slim mode is ideal for models with limited context windows or when you want to minimize token overhead from tool definitions.

CLI Options

Connected Mode

If you already have a BAP Playwright server running, connect to it directly:
This skips auto-start and connects to your existing server instance.

In-Process Mode

For zero-overhead MCP, use --in-process to bypass the WebSocket layer entirely:
This runs the Playwright server in the same process using DirectTransport.
In-process mode does not support server-push notifications (event streaming). Use standard mode if you need console error and network failure forwarding.

Event Streaming

Browser console errors and 4xx/5xx network responses are automatically forwarded to connected MCP clients as notifications/message log entries. No configuration needed.

Selector Formats

All tools that accept a selector parameter support these formats:

Programmatic Usage

Troubleshooting

On native Windows (not WSL), use the cmd /c wrapper:
Ensure Playwright browsers are installed: bash npx playwright install chromium
MCP defaults to headless: true. If you override to headless: false on a retina Mac, screenshots will be 2x DPI, doubling their size. BAP mitigates this with deviceScaleFactor: 1 and scale: "css" on screenshots.