Skip to main content
The BrowserToolkit gives agents full browser automation via Playwright CDP mode. It drives Chrome directly through the Chrome DevTools Protocol — native async, role-based element refs (e1, e2, e3), AI-friendly errors, and self-healing connections.

Installation

Quick Start

The toolkit exposes 55 tools that the agent can call to navigate, read, interact with, and extract data from web pages.

Connection Modes

BrowserToolkit supports three connection modes, selected by the BrowserConfig you pass in.

Fresh Chrome (Default)

Launches a new ephemeral Chrome instance. Cookies and storage are discarded when the toolkit shuts down.

Persistent Profile

Launch Chrome with a persistent user data directory. Cookies, localStorage, and logged-in sessions survive between runs.

CDP Attach

Attach to an already-running Chrome instance via its remote debugging port. No new browser window is opened — the agent controls your existing browser.

BrowserConfig Reference

str
WebSocket or HTTP URL of an existing Chrome CDP endpoint. When set, no new browser is launched.
bool
default:"false"
Run Chrome without a visible window.
str
Path to a Chrome user data directory for session persistence.
bool
default:"true"
Enable anti-detection flags (--disable-blink-features=AutomationControlled).
bool
default:"false"
Disable Chrome sandbox. Required in Docker/CI environments.
str
Proxy server in "host:port" or "user:pass@host:port" format.
str
Override the browser’s User-Agent string.
str
default:"en-US"
Browser locale code, e.g. "en-US", "fr", "zh-CN".
str
Browser timezone override, e.g. "America/New_York".
int
default:"1280"
Browser viewport width in pixels.
int
default:"720"
Browser viewport height in pixels.
float
default:"30.0"
Default per-operation timeout in seconds.
str
Path to Chrome/Brave/Edge binary. Auto-detected if not set.
tuple[str, ...]
Additional Chrome CLI flags.

Element Refs — The Key Innovation

Agents interact with semantic element refs instead of brittle CSS selectors. After calling browser_snapshot(), every interactive element gets a ref like e1, e2, e3:
Then the agent uses refs for all interactions:
CSS selectors still work everywhere — browser_click("button.submit") is also valid. The ref system auto-detects which you’re using.

Tools Reference

All 55 tools are grouped by category below. Every tool name is prefixed with browser_.

Page State (7 tools)

Perception (2 tools)

Interaction (15 tools)

Scrolling (3 tools)

Waiting (4 tools)

DOM Manipulation (2 tools)

Forms & Checkboxes (3 tools)

Cookies (3 tools)

Storage (2 tools)

Tabs (4 tools)

Output (1 tool)

Dialogs (1 tool)

Browser State (1 tool)

Diagnostics (3 tools)

Usage with Agent

The toolkit follows the AsyncLifecycleToolkit protocol. Use async with for automatic startup and shutdown:
Use browser_snapshot before interacting with a page. It returns an accessibility-tree view with role-based refs (e1, e2, e3) for every interactive element, which is more useful than browser_get_source for understanding page structure.

Combining with Other Toolkits

BrowserToolkit can be used alongside other toolkits:

Testing

Inject a mock browser to test without launching Chrome: