CLI Reference
Agent Commands (Recommended)
The agent subcommand manages session state automatically — it persists the active session, auto-restarts on disconnect, generates command IDs, and retries failed commands.
| Command | Description |
|---|---|
agent start [options] | Start or connect to a Chrome session |
agent status | Show current session status |
agent navigate <url> | Navigate to a page |
agent click [selector] [--text <t>] | Click an element (by selector or text) |
agent type <selector> <text> | Type into an element |
agent press <key> | Press a key on the active element |
agent wait [selector] [options] | Wait for element, text, URL or load |
agent hover [selector] [--text <t>] | Hover an element |
agent select <selector> <value> | Select an option |
agent toggle <selector> | Toggle a checkbox or radio |
agent scroll [options] | Scroll the page or an element |
agent back, agent forward, agent refresh | Browser navigation actions |
agent dialog [options] | Handle JavaScript dialogs |
agent cookies | Dismiss cookie banners |
agent eval <expression> | Evaluate JavaScript, print the value |
agent tabs | List tabs |
agent tab <id> | Switch to a tab (id or unique prefix) |
agent tab-new [url] | Open a tab and switch to it |
agent tab-close <id> | Close a tab |
agent restart, agent terminate | Recover or terminate the session |
agent content [options] | Get page content |
agent elements [options] | Discover interactive elements |
agent screenshot [options] | Save a screenshot to a file |
agent memory-search <intent> | Search task memory |
agent stop | Stop the session |
agent cleanup | Remove old session data |
agent start Options
| Option | Description |
|---|---|
--cdp-url <url> | Connect to a running Chrome (e.g. http://127.0.0.1:9222) instead of launching a new one. Your Chrome stays open when the session stops. |
--user-profile <path> | Launch Chrome with a real profile. Use default for your system Chrome profile, or pass an absolute path. Requires Chrome to be closed first — Chrome locks its profile directory. |
--headless | Run Chrome in headless mode (no visible window). Useful for CI/server environments. |
--user-agent <string> | Override the browser user-agent string sent with every request. |
Navigate
agentic-browser agent navigate https://example.comInteract
# Click
agentic-browser agent click "#login-btn"
# Click with fallback selectors (tried if primary fails)
agentic-browser agent click "#login-btn" --fallback 'button[aria-label="Login"]'
# Type into an input
agentic-browser agent type 'input[name=q]' "search query"
# Press a key
agentic-browser agent press Enter
# Click by visible text (substring; add --exact for an exact match)
agentic-browser agent click --text "Sign in"
# Act inside a cross-origin iframe (selectors from `elements` -> crossOriginFrames)
agentic-browser agent click --text "Accept all" --frame "#sp_message_iframe_123"
agentic-browser agent type --frame "iframe#checkout" "#card" "4242 4242 4242 4242"
agentic-browser agent click "#sp_message_iframe_123 >>> text=Accept all"
# Wait for an element, text, URL (substring, * glob or /regex/) or page load
agentic-browser agent wait "#results" --timeout 5000
agentic-browser agent wait --text "Results"
agentic-browser agent wait --url "*/search?*" --load
# Evaluate JavaScript (promises are awaited, result is JSON)
agentic-browser agent eval "document.title"
agentic-browser agent eval "location.href" --frame "#sp_message_iframe_123"
# Hover an element
agentic-browser agent hover "#profile-menu"
# Select an option
agentic-browser agent select 'select[name=country]' DE
# Toggle a checkbox
agentic-browser agent toggle "#terms"
# Scroll
agentic-browser agent scroll --y 600
agentic-browser agent scroll --selector "#results" --y 300
# Browser navigation
agentic-browser agent back
agentic-browser agent forward
agentic-browser agent refresh
# Handle JavaScript dialogs
agentic-browser agent dialog # accept
agentic-browser agent dialog --dismiss # dismiss
agentic-browser agent dialog --value "my answer" # respond to prompt
# Dismiss cookie banners (also cross-origin consent iframes; `detail` explains failures)
agentic-browser agent cookiesagent status, agent navigate and interaction commands include the current page url.
Tabs
agentic-browser agent tabs # [{ id, url, title, active }]
agentic-browser agent tab-new https://example.org # open, switch, navigate
agentic-browser agent tab 42FC # switch (id or unique prefix)
agentic-browser agent tab-close 42FC # the last tab cannot be closedGet Content
# Low-token overview (default mode)
agentic-browser agent content --mode summary
# Page title
agentic-browser agent content --mode title
# Readable text
agentic-browser agent content --mode text
# Raw HTML of a specific element
agentic-browser agent content --mode html --selector mainScreenshot
# PNG of the viewport to an explicit path
agentic-browser agent screenshot --out ./page.png
# Full-page JPEG under ~/.agentic-browser/screenshots/
agentic-browser agent screenshot --format jpeg --quality 70 --full-pagePrints { ok, action, sessionId, path, mimeType, bytes }. Image data never goes to stdout.
Discover Elements
# All interactive elements
agentic-browser agent elements
# Filter by role
agentic-browser agent elements --roles button,link,input
# Limit results and scope to a container
agentic-browser agent elements --limit 20 --selector "#main-content"
# Only visible elements (default: true)
agentic-browser agent elements --visible-only
# Filter by link href or by text/label (case-insensitive substrings)
agentic-browser agent elements --href /news/ --text "gta"
# Elements inside a cross-origin iframe
agentic-browser agent elements --frame "#sp_message_iframe_123"Cross-origin iframes the page cannot read are listed under crossOriginFrames with a selector you can pass to --frame.
Search Memory
agentic-browser agent memory-search "login:github.com" --domain github.com --limit 5Cleanup
# Preview what would be deleted
agentic-browser agent cleanup --dry-run --max-age-days 7
# Actually clean up
agentic-browser agent cleanup --max-age-days 7Low-Level Commands
For direct control without session state management. You manage session IDs and command IDs yourself.
Session Lifecycle
# Start (fresh Chrome)
agentic-browser session:start
# Start (connect to existing Chrome)
agentic-browser session:start --cdp-url http://127.0.0.1:9222
# Start (use your real Chrome profile)
agentic-browser session:start --user-profile default
# Start (headless, with custom user-agent)
agentic-browser session:start --headless --user-agent "MyBot/1.0"
# Status
agentic-browser session:status <sessionId>
# Restart
agentic-browser session:restart <sessionId>
# Stop
agentic-browser session:stop <sessionId>
# Rotate auth token
agentic-browser session:auth <sessionId>
# Cleanup old sessions
agentic-browser session:cleanup --max-age-days 7Commands
agentic-browser command:run <sessionId> <commandId> <type> <payloadJson>
# Examples
agentic-browser command:run $SID cmd-1 navigate '{"url":"https://example.com"}'
agentic-browser command:run $SID cmd-2 interact '{"action":"click","selector":"#btn"}'Page Content
agentic-browser page:content <sessionId> --mode summary
agentic-browser page:content <sessionId> --mode title
agentic-browser page:content <sessionId> --mode html --selector mainMemory
agentic-browser memory:search "navigate:example.com" --domain example.com --limit 5
agentic-browser memory:inspect <insightId>
agentic-browser memory:verify <insightId>
agentic-browser memory:statsOutput Format
All commands print exactly one JSON line to stdout. Use exit code 0 for success, 1 for failure.
{
"ok": true,
"action": "navigate",
"commandId": "cmd-1",
"sessionId": "abc-123",
"type": "navigate",
"payload": { "url": "https://example.com" },
"submittedAt": "2025-01-01T00:00:00.000Z",
"completedAt": "2025-01-01T00:00:01.000Z",
"resultStatus": "success",
"resultMessage": "Navigated to https://example.com"
}Infrastructure Commands
Setup
Configure agentic-browser as an MCP server for your AI tool:
# Interactive — detects Claude Code, Cursor, and prompts you to choose
agentic-browser setupThe command finds supported AI tools in your project, then writes the MCP server entry into the appropriate config file (.mcp.json, .cursor/mcp.json).
MCP Server
Start the MCP server directly (used by AI tools, not typically called manually):
agentic-browser mcpRuns the stdio-based MCP server. This is what AI tools invoke when you configure the MCP integration via setup or manual config.
Recommended Workflow
agent start— launch Chrome (or--cdp-url <url>to connect,--headlessfor CI,--user-agentto override UA)agent navigate— go to target pageagent elements— discover what's clickableagent click,agent type,agent select, and related typed commands — use discovered selectorsagent content— read page content to verifyagent memory-search— on repeat visits, reuse known selectorsagent stop— terminate when done