| description | Automates browser interactions for web testing, form filling, screenshots, and data extraction. Use when the user needs to navigate websites, interact with web pages, fill forms, take screenshots, test web applications, or extract information from web pages. |
| name | agent-browser |
| source | https://github.com/vercel-labs/agent-browser |
Browser Automation with agent-browser
Fast native Rust CLI for AI agent browser automation. Uses Chrome via CDP (Chrome DevTools Protocol) with a client-daemon architecture — the daemon persists between commands for fast subsequent operations.
Installation
npm install -g agent-browser
agent-browser install
brew install agent-browser
agent-browser install
cargo install agent-browser
agent-browser install
agent-browser upgrade
Quick Start
agent-browser open <url>
agent-browser snapshot -i
agent-browser click @e2
agent-browser fill @e3 "text"
agent-browser screenshot page.png
agent-browser close
Clicks fail early when another element covers the target's click point. Dismiss or interact with the covering element, then take a fresh snapshot before retrying.
Core Workflow
- Navigate:
agent-browser open <url>
- Snapshot:
agent-browser snapshot -i (returns elements with refs like @e1, @e2)
- Interact using refs from the snapshot
- Re-snapshot after navigation or significant DOM changes
Commands
Navigation
agent-browser open <url>
agent-browser open
agent-browser read [url]
agent-browser back
agent-browser forward
agent-browser reload
agent-browser close
agent-browser close --all
Snapshot (page analysis)
agent-browser snapshot
agent-browser snapshot -i
agent-browser snapshot -i --urls
agent-browser snapshot -c
agent-browser snapshot -d 3
agent-browser snapshot -s "#main"
agent-browser snapshot -i -c -d 5
Read Agent-Friendly Text
agent-browser read
agent-browser read https://example.com
agent-browser read https://example.com --outline
agent-browser read https://docs.example.com --llms index
agent-browser read https://docs.example.com --llms full
agent-browser read url --filter overview
agent-browser read url --require-md
Interactions (use @refs from snapshot)
agent-browser click @e1
agent-browser click @e1 --new-tab
agent-browser dblclick @e1
agent-browser focus @e1
agent-browser fill @e2 "text"
agent-browser type @e2 "text"
agent-browser press Enter
agent-browser press Control+a
agent-browser keydown Shift
agent-browser keyup Shift
agent-browser keyboard type "text"
agent-browser keyboard inserttext "text"
agent-browser hover @e1
agent-browser check @e1
agent-browser uncheck @e1
agent-browser select @e1 "value"
agent-browser scroll down 500
agent-browser scroll down --selector @e1
agent-browser scrollintoview @e1
agent-browser drag @e1 @e2
agent-browser upload @e1 file.pdf
Get Information
agent-browser get text @e1
agent-browser get html @e1
agent-browser get value @e1
agent-browser get attr @e1 href
agent-browser get title
agent-browser get url
agent-browser get cdp-url
agent-browser get count ".item"
agent-browser get box @e1
agent-browser get styles @e1
Check State
agent-browser is visible @e1
agent-browser is enabled @e1
agent-browser is checked @e1
Screenshots & PDF
agent-browser screenshot
agent-browser screenshot path.png
agent-browser screenshot --full
agent-browser screenshot --annotate
agent-browser screenshot --screenshot-dir ./shots
agent-browser screenshot --screenshot-format jpeg --screenshot-quality 80
agent-browser pdf output.pdf
Annotated Screenshots
agent-browser screenshot --annotate ./page.png
agent-browser click @e2
Batch Execution
agent-browser batch "open https://example.com" "snapshot -i" "screenshot"
agent-browser batch --bail "open https://example.com" "click @e1" "screenshot"
echo '[["open","https://example.com"],["snapshot","-i"],["screenshot"]]' | agent-browser batch --json
Clipboard
agent-browser clipboard read
agent-browser clipboard write "Hello, World!"
agent-browser clipboard copy
agent-browser clipboard paste
Video Recording
agent-browser record start ./demo.webm
agent-browser click @e1
agent-browser record stop
agent-browser record restart ./take2.webm
Wait
agent-browser wait @e1
agent-browser wait 2000
agent-browser wait --text "Success"
agent-browser wait --url "**/dashboard"
agent-browser wait --load networkidle
agent-browser wait --fn "window.ready"
agent-browser wait "#spinner" --state hidden
Mouse Control
agent-browser mouse move 100 200
agent-browser mouse down left
agent-browser mouse up left
agent-browser mouse wheel 100
Semantic Locators (alternative to refs)
agent-browser find role button click --name "Submit"
agent-browser find text "Sign In" click
agent-browser find label "Email" fill "user@test.com"
agent-browser find placeholder "Search" fill "query"
agent-browser find alt "Logo" click
agent-browser find first ".item" click
agent-browser find nth 2 "a" text
agent-browser find last ".item" click
Diff
agent-browser diff snapshot
agent-browser diff snapshot --baseline before.txt
Browser Settings
agent-browser set viewport 1920 1080 [scale]
agent-browser set device "iPhone 14"
agent-browser set geo 37.7749 -122.4194
agent-browser set offline on
agent-browser set headers '{"X-Key":"v"}'
agent-browser set credentials user pass
agent-browser set media dark
Cookies & Storage
agent-browser cookies
agent-browser cookies set name value
agent-browser cookies set --curl <file>
agent-browser cookies clear
agent-browser storage local
agent-browser storage local key
agent-browser storage local set k v
agent-browser storage local clear
agent-browser storage session
Network
agent-browser network route <url>
agent-browser network route <url> --abort
agent-browser network route <url> --body '{}'
agent-browser network route '*' --abort --resource-type script
agent-browser network unroute [url]
agent-browser network requests
agent-browser network requests --filter api
agent-browser network requests --type xhr,fetch
agent-browser network requests --method POST
agent-browser network requests --status 2xx
agent-browser network request <requestId>
agent-browser network har start
agent-browser network har stop [output.har]
Tabs & Windows
agent-browser tab
agent-browser tab new [url]
agent-browser tab new --label docs [url]
agent-browser tab t1
agent-browser tab docs
agent-browser tab close [t1|label]
agent-browser window new
Tab ids are stable strings: t1, t2, t3. Never reused within a session. You can also assign labels:
agent-browser tab new --label docs https://docs.example.com
agent-browser tab docs
agent-browser tab close docs
Frames
agent-browser frame "#iframe"
agent-browser frame main
Dialogs
agent-browser dialog accept [text]
agent-browser dialog dismiss
agent-browser dialog status
By default, alert and beforeunload dialogs are auto-accepted. confirm and prompt require explicit handling. Use --no-auto-dialog to disable automatic handling.
JavaScript
agent-browser eval "document.title"
agent-browser eval -b "base64EncodedScript"
agent-browser eval --stdin
Init Scripts
agent-browser open --init-script <path>
agent-browser addinitscript <js>
agent-browser removeinitscript <identifier>
Streaming (Browser Preview)
agent-browser stream enable [--port <port>]
agent-browser stream status
agent-browser stream disable
Dashboard (Observability)
agent-browser dashboard start
agent-browser dashboard start --port 8080
agent-browser dashboard stop
Shows live viewport, activity feed, console output, session creation, and optional AI chat.
AI Chat
agent-browser chat "open google.com and search for cats"
agent-browser chat
agent-browser -q chat "summarize this page"
agent-browser -v chat "fill in the login form"
agent-browser --model openai/gpt-4o chat "take a screenshot"
Requires AI_GATEWAY_API_KEY environment variable.
Diff
agent-browser diff snapshot
agent-browser diff snapshot --baseline before.txt
Sessions (parallel browsers)
agent-browser --session test1 open site-a.com
agent-browser --session test2 open site-b.com
agent-browser session list
agent-browser session
Each session has its own browser instance, cookies, storage, navigation history, and auth state.
Authentication
Chrome Profile Reuse
agent-browser profiles
agent-browser --profile Default open https://gmail.com
agent-browser --profile "Work" open https://app.example.com
Persistent Profile
agent-browser --profile ~/.myapp-profile open myapp.com
Session Persistence
agent-browser --session-name twitter open twitter.com
Auth Vault (encrypted credentials)
echo "pass" | agent-browser auth save github --url https://github.com/login --username user --password-stdin
agent-browser auth login github
Import from Running Chrome
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" --remote-debugging-port=9222
agent-browser --auto-connect state save ./my-auth.json
agent-browser --state ./my-auth.json open https://app.example.com/dashboard
Security Features
agent-browser --content-boundaries open url
agent-browser --allowed-domains "example.com,*.example.com" open url
agent-browser --action-policy ./policy.json open url
agent-browser --confirm-actions eval,download open url
agent-browser --max-output 50000 open url
Cloud Providers
BROWSERLESS_API_KEY="token" agent-browser -p browserless open url
BROWSERBASE_API_KEY="key" agent-browser -p browserbase open url
BROWSER_USE_API_KEY="key" agent-browser -p browseruse open url
KERNEL_API_KEY="key" agent-browser -p kernel open url
agent-browser -p agentcore open url
agent-browser -p ios --device "iPhone 16 Pro" open url
MCP Server
agent-browser mcp
agent-browser mcp --tools all
agent-browser mcp --tools core,network,react
MCP profiles: core, network, state, debug, tabs, react, mobile, all
Example MCP client config:
{
"mcpServers": {
"agent-browser": {
"command": "agent-browser",
"args": ["mcp"]
}
}
}
Skills
agent-browser skills
agent-browser skills get <name>
agent-browser skills get --all
Setup & Diagnostics
agent-browser install
agent-browser install --with-deps
agent-browser upgrade
agent-browser doctor
agent-browser doctor --fix
JSON Output (for agents)
Add --json for machine-readable output:
agent-browser snapshot -i --json
agent-browser get text @e1 --json
agent-browser screenshot --json
Configuration
Create agent-browser.json for persistent defaults:
Locations (lowest to highest priority):
~/.agent-browser/config.json: user-level defaults
./agent-browser.json: project-level overrides
AGENT_BROWSER_* environment variables
- CLI flags override everything
{
"$schema": "https://agent-browser.dev/schema.json",
"headed": true,
"proxy": "http://localhost:8080",
"profile": "./browser-data",
"userAgent": "my-agent/1.0",
"hideScrollbars": false,
"ignoreHttpsErrors": true
}
Options
| Option | Description |
|---|
--session <name> | Isolated session |
--session-name <name> | Auto-save/restore session state |
--profile <name|path> | Chrome profile name or persistent directory |
--state <path> | Load storage state from JSON |
--headed | Show browser window |
--cdp <port|url> | Connect via CDP |
--auto-connect | Auto-discover running Chrome |
--proxy <url> | Proxy server |
--ignore-https-errors | Ignore cert errors |
--allow-file-access | Allow file:// URLs |
--json | JSON output |
--annotate | Annotated screenshots |
--config <path> | Custom config file |
-v, --verbose | Verbose output |
-q, --quiet | Quiet mode |
Environment Variables
| Variable | Description |
|---|
AGENT_BROWSER_SESSION | Session name |
AGENT_BROWSER_SESSION_NAME | Auto-save/restore session |
AGENT_BROWSER_PROFILE | Chrome profile |
AGENT_BROWSER_STATE | State file path |
AGENT_BROWSER_EXECUTABLE_PATH | Custom browser |
AGENT_BROWSER_PROXY | Proxy URL |
AGENT_BROWSER_HEADED | Show window |
AGENT_BROWSER_AUTO_CONNECT | Auto-discover Chrome |
AGENT_BROWSER_DEFAULT_TIMEOUT | Default timeout (ms, default: 25000) |
AGENT_BROWSER_IDLE_TIMEOUT_MS | Auto-shutdown daemon after idle |
AGENT_BROWSER_CONTENT_BOUNDARIES | Wrap output in boundaries |
AGENT_BROWSER_MAX_OUTPUT | Max output chars |
AGENT_BROWSER_ALLOWED_DOMAINS | Domain allowlist |
AGENT_BROWSER_ENCRYPTION_KEY | AES-256-GCM key for state encryption |
Example: Form submission
agent-browser open https://example.com/form
agent-browser snapshot -i
agent-browser fill @e1 "user@example.com"
agent-browser fill @e2 "password123"
agent-browser click @e3
agent-browser wait --load networkidle
agent-browser snapshot -i
Example: Authentication with saved state
agent-browser open https://app.example.com/login
agent-browser snapshot -i
agent-browser fill @e1 "username"
agent-browser fill @e2 "password"
agent-browser click @e3
agent-browser wait --url "**/dashboard"
agent-browser state save auth.json
agent-browser state load auth.json
agent-browser open https://app.example.com/dashboard
Example: Command chaining
agent-browser open example.com && agent-browser wait --load networkidle && agent-browser snapshot -i
agent-browser fill @e1 "user@example.com" && agent-browser fill @e2 "pass" && agent-browser click @e3
Selectors
Refs (Recommended for AI)
Refs provide deterministic element selection from snapshots. Use @e1, @e2, etc.
CSS Selectors
agent-browser click "#id"
agent-browser click ".class"
agent-browser click "div > button"
Text & XPath
agent-browser click "text=Submit"
agent-browser click "xpath=//button"
Platforms
| Platform | Binary |
|---|
| macOS ARM64 | Native Rust |
| macOS x64 | Native Rust |
| Linux ARM64 | Native Rust |
| Linux x64 | Native Rust |
| Windows x64 | Native Rust |
Architecture
- Rust CLI - Parses commands, communicates with daemon
- Rust Daemon - Pure Rust daemon using direct CDP, no Node.js required
- Browser Engine - Chrome (from Chrome for Testing) by default;
--engine lightpanda also supported
The daemon starts automatically on first command and persists between commands. Set AGENT_BROWSER_IDLE_TIMEOUT_MS for auto-shutdown after inactivity.
License
Apache-2.0