> ## Documentation Index
> Fetch the complete documentation index at: https://piyushvyas.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# In-Process Mode

> Run the Playwright server in the same process as the MCP server for zero-overhead communication.

# 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

```bash theme={null}
npx @browseragentprotocol/mcp --in-process
```

<CodeGroup>
  ```bash Claude Code theme={null}
  claude mcp add --transport stdio bap-browser -- npx -y @browseragentprotocol/mcp --in-process
  ```

  ```json Claude Desktop theme={null}
  {
    "mcpServers": {
      "bap-browser": {
        "command": "npx",
        "args": ["-y", "@browseragentprotocol/mcp", "--in-process"]
      }
    }
  }
  ```
</CodeGroup>

## 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

<CardGroup cols={2}>
  <Card title="Advantages" icon="bolt">
    * Lower latency (no WebSocket overhead) - No child process management - Simpler deployment
      (single process) - Slightly lower memory usage
  </Card>

  <Card title="Limitations" icon="triangle-exclamation">
    * 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
  </Card>
</CardGroup>

<Warning>
  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.
</Warning>

## When to Use

| Scenario                                      | Recommended Mode     |
| --------------------------------------------- | -------------------- |
| Latency-sensitive single-agent workflows      | In-process           |
| Need event streaming (console/network errors) | Default (WebSocket)  |
| Sharing server across multiple MCP clients    | Default with `--url` |
| Simple deployment, single process             | In-process           |
| Long-running monitoring tasks                 | Default (WebSocket)  |

## Combining with Other Flags

In-process mode works with other MCP flags:

```bash theme={null}
npx @browseragentprotocol/mcp --in-process --slim --headless
npx @browseragentprotocol/mcp --in-process --browser firefox
```

<Note>
  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.
</Note>
