Commands
Core
Unknown commands exit with status 1, including when you request command help.
When the top-level Chrome/CDP eval result is a value JSON cannot represent, plain output prints its exact JavaScript token, including NaN, Infinity, -Infinity, -0, BigInt literals, and undefined. With --json, data.result stays null and sibling data.unserializable contains the token. MCP text prints the token, and structured responses expose it at structuredContent.response.data.unserializable.
For fill and type, put options before the optional -- marker. Text after the marker is literal, including values that look like flags. For example, agent-browser fill "#search" -- --json fills with --json, and agent-browser --json type "#search" --clear --delay 10 -- --clear clears the field, then types --clear. MCP agent_browser_fill and agent_browser_type pass typed text values literally, so they do not need the marker.
select works on a native <select> and on a custom ARIA combobox or listbox, such as Radix or Headless UI. On a custom widget it opens the widget, then clicks the role=option whose name or value matches. A value with no match is an error that lists the available options, a matched option marked aria-disabled is an error instead of a click, and an option already selected in a multi-select listbox is left alone.
Browser responses automatically announce WebMCP tools on first discovery and when the catalog changes. Summaries contain only names, brief descriptions, origins, and frame IDs. Choose a relevant tool, then fetch its full schema with agent-browser webmcp list <tool> --frame <frame-id> --json before invoking it. Schemas and annotations are never included proactively. Unchanged catalogs and pages without tools add no context. JSON exposes updates as data.webmcp; CLI and MCP text include the same bounded summary. See WebMCP for update semantics and security.
Clicks fail before dispatch when another element covers the target's click point. The error names the covering element, for example covered by <div#consent-banner>. Dismiss or interact with that element, take a fresh snapshot, then retry the original action. Click and dblclick fail, instead of reporting success, when the element is hidden, disabled, or outside the viewport. click --new-tab opens the link's URL directly, so these checks do not apply to it.
Headless Chromium screenshots hide native scrollbars for consistent image output. Pass --hide-scrollbars false when launching to keep native scrollbars visible.
Get info
get cdp-url reports the CDP WebSocket URL of a browser that is already running. It requires a running browser and never launches one. A batch containing only get cdp-url commands also skips browser launch. A mixed batch can launch a browser for its other commands.
Read agent-friendly text
read fetches a URL without launching Chrome. Omit the URL to read the rendered DOM of the active tab in the current browser session, including browser auth state and client-side updates. Explicit URL reads send Accept: text/markdown by default, try the same URL with .md appended when the first response is not markdown, walk ancestor paths toward / to find the nearest llms.txt for a matching docs link, print markdown or plain text when available, and fall back to readable text extracted from HTML. --llms and --require-md with no URL use the active tab URL because they depend on HTTP resources. read does not read llms-full.txt unless you ask for it.
Options: --raw prints the response body without HTML extraction, --require-md fails unless the server returns Content-Type: text/markdown, --outline prints a compact heading outline for one page, --llms index prints a compact nearest-ancestor llms.txt link list, --llms full reads the nearest-ancestor llms-full.txt, --filter <text> narrows page sections, llms links/sections, or outline headings, and --timeout <ms> changes the request timeout. Global safeguards such as --allowed-domains, --content-boundaries, and --max-output also apply to read fetches and output.
Check state
Find elements
Semantic locators with actions (click, fill, check, hover, text):
Options:
--name <name>: filter role by accessible name--exact: exact, case-sensitive match. Forroleit applies to the accessible name, whose default is a case-insensitive substring.
Examples:
Wait
For selector waits, --state accepts visible, hidden, attached, or detached and cannot be combined with URL, load, function, text, download, or millisecond wait modes. The global auth-state --state <path> remains available before wait, as it does before other commands.
After a page change, prefer a selector, text, URL, or JavaScript condition that represents the state you need. Use networkidle only when the page is known to become quiet, because SSE, WebSockets, polling, and long-polling can keep it from resolving.
A load-state wait runs for its whole timeout budget, taken from --timeout or AGENT_BROWSER_DEFAULT_TIMEOUT, and returns an error when it expires.
Downloads
wait --download returns the oldest download not yet claimed by an earlier wait, including one that finished before the command ran, so it can follow the command that triggered it. With [path], the file is moved there; without it, the output is where the browser saved it. Saving to a local path only applies to a browser agent-browser launched: over --cdp, --auto-connect, or a provider, the saved file is named by the remote endpoint, so download and wait --download [path] are rejected.
Use --download-path <dir> (or AGENT_BROWSER_DOWNLOAD_PATH env) to set a default download directory. Without it, downloads go to a temporary directory that is deleted when the browser closes.
See Files & Clipboard for upload, download, local file, screenshot, PDF, and clipboard workflows.
Mouse
The wheel scrolls at the current tracked pointer, which starts at 0,0. Failed wheel dispatches leave the tracked pointer unchanged.
Mouse coordinates and wheel deltas accept finite decimal values; invalid supplied values are rejected. For mouse wheel, omitted dy and dx default to 100 and 0, respectively, and explicit 0 values are preserved.
To scroll elsewhere, move the pointer first:
Use --human with click, drag, or mouse move for curved, eased movement from the current cursor position. For mouse move, --duration sets the target total milliseconds including browser response time, --steps sets the number of events, and --seed makes the path reproducible. A slow browser can still extend the requested duration.
Clipboard
See Files & Clipboard for clipboard, upload, download, local file, screenshot, and PDF workflows.
Settings
Viewport scales and geolocation coordinates must be finite numbers.
Use --color-scheme for persistent dark/light mode across all commands:
Cookies & storage
Reads accept at most one key, sets require one key and one value, and clears take no operands. A bare key is shorthand for a one-key read.
Cookie operations are get (the default), set, and clear; unknown operations return an error. Cookie attributes use kebab-case flags such as --http-only and --same-site. The legacy --httpOnly and --sameSite spellings remain accepted. When setting one cookie, unknown flags and extra arguments return an error.
Network
If HAR export fails, recording and captured requests remain available. Fix the destination and retry network har stop.
See Network for pre-navigation routing, request filters, HAR export, and SSR/no-JavaScript debugging.
Tabs & frames
Stable tab ids and labels
Tab ids are stable strings of the form t1, t2, t3. They're never reused within a session, so t2 keeps pointing at the same tab even as other tabs are opened or closed. The t prefix mirrors the @e1 element-ref convention and is not interchangeable with positional integers — agent-browser tab 2 errors with a teaching message; use t2.
You can also assign a memorable label (docs, app, admin) at tab-creation time and use it anywhere an id is accepted:
Labels are never auto-generated and never rewritten on navigation — an agent that names a tab docs keeps that name until the tab is closed. Labels are unique within a session; creating a second tab with an existing label errors.
A label starts with a letter and contains only letters, digits, -, or _, and cannot use the reserved t<N> or T<N> tab-id form. Rejected labels preserve the current tab's refs and selected frame.
Tabs opened through tab new or click --new-tab inherit the session's setup before their first document loads: user agent, set headers, set credentials, origin-scoped --headers, init scripts, route rules, and emulation overrides (color scheme, timezone, locale, geolocation, offline). Turning offline mode off or setting headers to {} restores the default setup for future tabs.
tab list --json also reports each tab's CDP targetId, and target ids are accepted anywhere a tab ref is accepted (tab <targetId>, tab close <targetId>). Unlike t<N> ids, which are per-daemon counters, target ids stay stable across daemon restarts. Each session is bound to its active tab by target id and returns to it after a daemon restart; with --pin-tab the binding is strict and a closed bound tab produces a tab_gone error instead of a silent fallback. JSON errors include code: "tab_gone", data.targetId, and optional sanitized data.lastUrl. Batch output carries the recovery object under result. See CDP Mode for the multi-session workflow.
Refs (@e1, etc.) are scoped to the tab that was active when the snapshot ran, so switch tabs first, then snapshot and interact:
Discarded tab revival
Browsers discard background tabs to save memory, leaving a tab with no renderer to drive. Switching to a discarded tab reactivates it, which reloads the page and resets its unsaved state; the switch result adds "revived": true so the reload is visible rather than silent. A tab whose page is paused by a JavaScript dialog is alive rather than discarded: the switch leaves it untouched and adds "dialogBlocked": true. Resolve the dialog with dialog accept or dialog dismiss and the tab keeps its state. Closing the active tab onto a discarded successor revives it the same way and reports "activeTabRevived": true.
Snapshot deltas
snapshot --delta returns full, unchanged, or incremental updates per tab and option set. URL changes or large deltas return full state; --full resets the baseline. Apply a delta’s changes to ref metadata and treeChange to the previous tree: split on newlines, replace deleteCount lines at zero-based startLine with lines, then rejoin. Apply both to baseRevision before advancing to revision.
Iframe support
Iframes are detected automatically during snapshots. Iframe nodes are resolved and their content is inlined beneath the iframe element in the snapshot output. Refs assigned to elements inside iframes carry frame context, so click, fill, and other interactions work without manually switching frames.
The frame command accepts element refs (@e3), CSS selectors ("#my-iframe"), or frame name/URL.
Dialogs
By default, alert and beforeunload dialogs are automatically accepted so they never block the agent. confirm and prompt dialogs still require explicit handling. Use --no-auto-dialog (or AGENT_BROWSER_NO_AUTO_DIALOG=1) to disable automatic handling.
When a JavaScript dialog (alert, confirm, prompt) is pending, all command responses include a warning field with the dialog type and message.
Streaming
Streaming is enabled automatically for all sessions. Use these commands to check status, re-enable on a specific port, or disable streaming.
Streaming is separate from file-based recordings. Use Video Recording when you need a saved WebM or MP4 artifact.
Debug
Recording requires ffmpeg on PATH. See Debugging for console, error, dialog, trace, highlight, and DevTools workflows. See Video Recording for recording requirements and record workflows, and Profiler for performance profiles.
Auth vault
Save options:
--url <url>: login page URL (required)--username <user>: username (required)--password <pass>: password (required unless--password-stdin)--password-stdin: read password from stdin (recommended to avoid shell history exposure)--username-selector <sel>: custom CSS selector for username field--password-selector <sel>: custom CSS selector for password field--submit-selector <sel>: custom CSS selector for submit button
auth login filters matching controls by their layout size, computed visibility and opacity, and disabled/readonly state, including custom CSS selectors. If a selected credential field is replaced or redirects focus before entry, the command fails without submitting.
auth login navigates with load and then waits for the username/password/submit selectors to appear before interacting. This improves reliability on SPA login pages where fields render after initial page load.
Use --no-navigate after an in-page click, challenge clearance, consent dismissal, or other stateful setup that must survive credential entry:
The flag suppresses only the initial auth-login navigation. It requires an existing active top-level HTTP(S) page and compares that page with the effective credential URL by scheme, host, and effective port. Paths, queries, and fragments may differ. Waiting, filling, clicking submit, and any submit-triggered navigation are unchanged. A command-level --url overrides profile or provider URL metadata and acts as the expected-origin constraint rather than a navigation destination.
Plugin login options:
--credential-provider <plugin>: resolve credentials from a configured plugin--item <ref>: provider-specific vault item reference--url <url>: login URL override--no-navigate: use the active top-level page after validating it against the effective credential origin--username-selector <sel>: selector override for this login--password-selector <sel>: selector override for this login--submit-selector <sel>: selector override for this login
Credential provider plugins run out-of-process over the agent-browser.plugin.v1 stdio JSON protocol. They return credentials to the daemon for a single login and agent-browser does not save those credentials locally.
Other plugin capabilities use the same protocol:
browser.provider: use the plugin with--provider <name>to return a CDP WebSocket URLlaunch.mutate: append local launch args, extensions, or init scripts before Chrome startscommand.run: run arbitrary namespaced requests throughagent-browser plugin run
plugin run is for command.run and custom capabilities. Core capabilities and protocol request types use their dedicated command paths.
Confirmation
When --confirm-actions is set, certain action categories return a confirmation_required response instead of executing immediately. Use confirm or deny to approve or reject the action.
Pending confirmations auto-deny after 60 seconds.
State management
Sessions
Session names accept Unicode letters and numbers, hyphens, and underscores only. For example, café-東京_7 is valid, while my session is rejected because it contains a space.
Chrome profiles
Dashboard
Loopback dashboard origins are accepted by default without an access token. For a reverse-proxied or forwarded URL, pass its exact browser origin with --allowed-origins or set AGENT_BROWSER_DASHBOARD_ALLOWED_ORIGINS. Every configured origin must be a valid exact HTTPS origin. Ports must be integers from 1 to 65535. Unknown options, missing values, invalid ports, and malformed origins fail without starting the server. The command prints private tokenized access URLs only for external origins; open the matching URL once to establish the browser session and do not share it. Open the normal http://localhost:<port> URL for local access. The browser stays on the dashboard origin; per-session tabs, status, and stream traffic are proxied internally, so session ports do not need to be exposed. Stop the running dashboard before changing the port or allowed origins.
Doctor
Diagnose your install, auto-clean stale daemon files, and optionally repair common problems.
Exit code is 0 if all checks pass (warnings are fine), 1 if any fail. See the Installation page for the full check catalog.
Chat
Use natural language to control the browser via AI. The chat command translates instructions into agent-browser commands, executes them, and streams the AI response. Requires AI_GATEWAY_API_KEY to be set.
Chat-specific options:
Navigation
Pre-navigation setup
Some flows need routes, cookies, or init scripts configured before the first navigation (SSR debug, auth on protected origins, etc.). open without a URL launches the browser but stays on about:blank, leaving room to stage state. batch makes it one CLI invocation:
React / Web Vitals
React commands require --enable react-devtools at launch (installs the React DevTools hook before any page JS runs). vitals and pushstate work on any site.
react tree prints the component tree when one is available. If the response contains only a header, no tree was collected. Confirm the page uses React and that a React root has mounted.
Works on any React app (Next.js, Remix, Vite+React, CRA, TanStack Start, React Native Web, etc.). vitals and pushstate are framework-agnostic.
See React & Web Vitals for full command details and examples.
Accessibility audits
Run an embedded axe-core audit against the current page or navigate to a URL first. The vendored engine works without a CDN request and runs under strict page CSP. It runs private partial audits across the page's frame tree and merges serialized results without page messaging, so page-provided window.axe values remain intact and iframe violations retain their frame selector paths. Accessibility audits require a CDP browser and are not available with Safari or iOS WebDriver sessions.
The default output lists violations and incomplete checks with impact, rule ID, fix guidance, and failing-node paths. JSON output preserves axe's target selector path arrays, including nested arrays for shadow DOM boundaries and multiple entries for frame boundaries.
Init scripts
See Init Scripts & Extensions for launch-time scripts, script removal, built-in React DevTools, and extensions.
Global options
In a batch, --relaunch relaunches the browser once: the first command that can launch a browser carries it. Commands that never launch one, such as read, and commands denied by policy or waiting for confirmation pass it on to the next command.
See Configuration for config files and environment variables. See Proxy for proxy server, bypass, and credential settings.
Batch execution
Execute multiple commands in a single invocation. Commands can be passed as quoted arguments or piped as JSON via stdin.
| Option | Description |
|---|---|
--bail | Stop on first error (default: continue all commands) |
--json | Output results as a JSON array |
--omit-command | With --json, replace each command array with a stable zero-based index field |
Put global flags such as --init-script and --enable on the outer batch invocation. Keep command-specific options and literal command arguments inside each item.
With --json --omit-command, rows use a stable zero-based index field on success, failure, or --bail; default JSON output keeps the command field. This only removes command arrays and does not make output safe for secrets. Errors and response data are unchanged: type echoes typed text, and get value/eval may return input values. The MCP agent_browser_batch tool accepts omitCommand: true.
MCP server
Starts a Model Context Protocol server over stdio. MCP clients launch this command as a subprocess and exchange newline-delimited JSON-RPC on stdin and stdout. The server defaults to MCP protocol 2025-11-25 and accepts older supported client protocol versions during initialization. A tool call with an argument its schema does not declare fails with an invalid-params error that names the unknown keys and lists the tool's own arguments.
mcp call runs one MCP tool without a stdio session and prints its tools/call result as JSON, with the agent-browser version in _meta.agentBrowserVersion. Pass the tool arguments as a JSON object, or - to read them from stdin. Every tool is available unless --tools limits the call to profiles. The exit code is 0 on success, 1 when the tool reports an error, and 2 for an unknown tool or invalid arguments. Use it from runtimes that cannot keep a stdio session open between tool calls, such as serverless agents. Access settings such as AGENT_BROWSER_ALLOWED_DOMAINS come from the environment, as with the server.
For tool calls that run the CLI, structuredContent.response contains parsed CLI JSON. stdout is included only when the output cannot be parsed as JSON; exitCode and stderr are always included.
In a Vercel Sandbox, startAgentBrowserMcp runs the server over the sandbox command's stdin. See Next.js + Vercel.
The default tools profile is core, which keeps MCP context small for everyday browser automation. Use --tools all for the full typed CLI parity surface, or combine profiles with commas, such as --tools core,network,react.
Profiles:
core- Default. Navigation, snapshots, interaction, waits, reads, screenshots, JavaScript eval, close, tab basics, and profile discoverynetwork- Network routes, request inspection, HAR, headers, credentials, offlinestate- Cookies, storage, auth, saved state, sessions, profiles, skillsdebug- Console/errors, tracing, profiling, recording, accessibility audits, clipboard, plugins, doctor, dashboard, install, upgrade, chat, diff, batch, confirm/denytabs- Back/forward/reload, tabs, windows, frames, dialogsreact- React tree/inspect/renders/suspense, vitals, pushstatemobile- Viewport/device/geolocation/media, touch, swipe, mouse, keyboardall- Every MCP tool, including the full typed CLI parity surface
Example MCP client config:
With --tools all, the server exposes typed tools across the CLI command surface, including navigation, snapshots, input, waits, screenshots/PDF, get/is/find, mouse, network, storage, cookies, tabs, windows, frames, dialogs, tracing, recording, accessibility audits, clipboard, auth, state, iOS, diff, React, vitals, sessions, skills, plugins, doctor, dashboard, install, upgrade, chat, eval, and close.
Common tools include:
agent_browser_tools_profilesagent_browser_openagent_browser_snapshotagent_browser_clickagent_browser_fillagent_browser_typeagent_browser_pressagent_browser_wait_for_selectoragent_browser_screenshotagent_browser_get_urlagent_browser_evalagent_browser_close
Each tool has typed fields such as url, selector, text, and key, so MCP clients show meaningful approval prompts instead of raw command arrays. Tool discovery is paginated and includes read-only/open-world annotations so modern MCP clients can load the large typed surface incrementally.
Every tool also accepts the shared arguments session, restore, allowedDomains, extraArgs, timeoutMs, namespace, restoreSave, restoreCheckUrl, restoreCheckText, restoreCheckFn, caCert, useSystemCa, clearCaCert, idleTimeout, and relaunch. A tool's schema lists only the ones that usually matter for it: session on every tool, restore and relaunch on open and tab_new, allowedDomains and extraArgs on open, tab_new, and read, and timeoutMs on tools that navigate, wait, or run scripts. The server's initialize instructions describe all of them. allowedDomains maps to --allowed-domains, activates the same WebRTC containment and launch-mode restrictions, and is rejected when the server already sets allowed domains. idleTimeout maps to --idle-timeout, accepts values such as 30s, 5m, 1h, or raw milliseconds, and accepts 0 to disable idle shutdown. relaunch: true maps to --relaunch. extraArgs carries per-command options and display or emulation flags such as --engine; it cannot set --config or global flags that change network, file, policy, or host access. Set host-wide options in the MCP server's environment or selected config.
By default, tool invocations use the same config discovery and environment variables as the CLI. Use session in the tool arguments, or set AGENT_BROWSER_SESSION, to isolate browser state.
Pass --config <trusted-path> to agent-browser mcp or agent-browser mcp call to select one trusted config file. MCP tool child processes load only that file, replacing default user/project discovery. Put any required safety policy in it. Environment variables and accepted per-tool CLI arguments keep their normal precedence.
Command chaining
Chain commands with && in a single shell invocation. The browser persists via a background daemon, so chaining works naturally and is more efficient than separate calls:
Use && when you don't need to read intermediate output. Run commands separately when you need to parse output first (e.g., snapshot to discover refs, then interact with those refs).
Local files
Open local files (PDFs, HTML) using file:// URLs:
The --allow-file-access flag enables JavaScript to access other local files. Chromium only.
See Files & Clipboard for local files, uploads, downloads, screenshots, PDFs, and clipboard workflows.