Design Principles
JSON-RPC 2.0
Every request and response follows the JSON-RPC 2.0 specification. Clients send
{ jsonrpc: "2.0", method, params, id } and receive { jsonrpc: "2.0", result, id } or { jsonrpc: "2.0", error, id }.WebSocket Transport
Persistent bidirectional connection. The server can push notifications (console errors, network failures, dialog events) without polling.
Semantic Selectors
10 selector types (role, text, label, testId, ref, css, xpath, placeholder, semantic, coordinates) let agents target elements by meaning, not DOM structure.
Fusion Operations
6 optimizations that batch multiple operations into single requests, cutting roundtrips by up to 55% in complex workflows.
Architecture
BAP uses a two-process architecture that separates the protocol layer from the browser automation engine:- Session persistence — the browser survives client restarts
- Multi-client access — CLI and MCP can control the same browser simultaneously
- Shared state — observations, element refs, and cookies persist across interfaces
Connection Lifecycle
1
Open WebSocket
Client connects to
ws://localhost:9222 (default endpoint).2
Initialize
Client sends
initialize with client capabilities and optional sessionId. Server responds
with server capabilities and protocol version.3
Confirm Ready
Client sends
notifications/initialized notification (no response expected).4
Operate
Client sends method requests (
browser/launch, page/navigate, agent/act, etc.). Server
responds to each request and may push notifications for events.5
Shutdown
Client sends
shutdown or simply disconnects. If the client provided a sessionId, the server
parks the browser state for later reconnection.Session Persistence
Clients can include asessionId in the initialize request. When a client with a session ID disconnects, the server parks the browser state (pages, contexts, cookies) in a dormant store instead of destroying it.
Reconnecting with the same sessionId restores the full session. Dormant sessions expire after dormantSessionTtl (default: 300 seconds).
Protocol Versioning
BAP follows semantic versioning:
All fields added in minor versions are optional. Old clients and servers ignore unknown fields — zero breaking changes for additive updates.
Method Categories
BAP defines 55 methods organized into 13 categories:
See Methods for the full reference.