Skip to main content
BAP provides two complementary flags for working with sites that employ bot detection: --stealth to reduce the automation fingerprint, and --connect to attach to a running Chrome instance via CDP.

The Three Tiers

Default

BAP launches Chrome with Playwright defaults. Good for most sites and development workflows.

Stealth

Reduces common bot detection signals. Use when sites block or CAPTCHA standard automation browsers. bash bap --stealth goto https://example.com

Connect

Attaches to a Chrome instance you launched manually. The gold standard for avoiding detection — it is a real user browser.

--stealth Flag

The stealth flag tells the BAP server to launch the browser with additional anti-detection measures:
Stealth mode is passed through to the server’s browser/launch call and applies to the entire session.
Stealth mode reduces but does not eliminate detection. Sophisticated bot detection systems may still flag automated browsers. For maximum compatibility, use --connect.

--connect Flag (CDP Attach)

Connect to an existing Chrome instance via the Chrome DevTools Protocol. This is the most reliable way to avoid bot detection because BAP controls a browser you launched manually — with your real profile, extensions, and cookies.
1

Launch Chrome with remote debugging

2

Connect BAP to the running Chrome

BAP discovers the Chrome instance on the default port (9222) and attaches via chromium.connectOverCDP().
3

Interact normally

Borrowed Browser Lifecycle

When using CDP attach, BAP never closes the external browser:
  • On disconnect: BAP drops the reference. The browser continues running.
  • On bap close-all: BAP closes its own pages but leaves the browser process intact.
  • Playwright has no Browser.disconnect() method, so BAP simply nullifies the reference.
The browser process you launched manually will keep running after BAP disconnects. Close it yourself when done.

Combining with Sessions

Both flags work with named sessions:
Session persistence ensures the stealth or CDP-attached browser stays warm across commands.

When to Use Each Tier

Server-Level CDP

The MCP and TypeScript SDK can also use CDP attach via the cdpUrl parameter in browser/launch:
When using cdpUrl, the browser lifecycle is “borrowed” — BAP never closes the external browser on disconnect or shutdown.