Skip to main content

In-Process Mode

Run the BAP Playwright server in the same process as the MCP server, bypassing WebSocket entirely. Uses DirectTransport for zero-overhead communication.

Enable In-Process Mode

npx @browseragentprotocol/mcp --in-process
claude mcp add --transport stdio bap-browser -- npx -y @browseragentprotocol/mcp --in-process

How It Works

Default Mode (WebSocket)

MCP Server  --[WebSocket]--> BAP Playwright Server (child process)
The MCP server spawns a separate Playwright server process and communicates over WebSocket with JSON-RPC 2.0.

In-Process Mode (DirectTransport)

MCP Server + BAP Playwright Server (same process, DirectTransport)
The Playwright server runs in the same Node.js process. DirectTransport passes messages directly in memory — no serialization, no network, no child process.

Trade-offs

Advantages

  • Lower latency (no WebSocket overhead) - No child process management - Simpler deployment (single process) - Slightly lower memory usage

Limitations

  • Server-push notifications are not supported - No event streaming (console errors, network failures) - Cannot share the server with other clients - If the server crashes, the MCP server crashes too
In-process mode does not support server-push notifications. This means browser console errors and network failure events will not be forwarded to the MCP client. If you need event streaming, use the default WebSocket mode.

When to Use

ScenarioRecommended Mode
Latency-sensitive single-agent workflowsIn-process
Need event streaming (console/network errors)Default (WebSocket)
Sharing server across multiple MCP clientsDefault with --url
Simple deployment, single processIn-process
Long-running monitoring tasksDefault (WebSocket)

Combining with Other Flags

In-process mode works with other MCP flags:
npx @browseragentprotocol/mcp --in-process --slim --headless
npx @browseragentprotocol/mcp --in-process --browser firefox
The --url flag is incompatible with --in-process. You cannot connect to an external server in in-process mode — the whole point is running everything in one process.