Skip to content
agentic-browser

Getting Started

Prerequisites

  • Node.js 22+
  • Chrome installed (auto-discovered, or set AGENTIC_BROWSER_CHROME_EXECUTABLE_PATH)

Install

npm install agentic-browser -g

Quick Start: CLI

Start a browser session, navigate to a page, discover elements, and read content:

# 1. Start Chrome
agentic-browser agent start
 
# 2. Navigate
agentic-browser agent navigate https://example.com
 
# 3. Discover what's on the page
agentic-browser agent elements
 
# 4. Click something using a discovered selector
agentic-browser agent click 'a[href="/more"]'
 
# 5. Read page content
agentic-browser agent content --mode summary
 
# 6. Done
agentic-browser agent stop

Every command prints exactly one JSON line to stdout.

Use your existing Chrome

Want your logged-in sessions and cookies? On Chrome 144+, open chrome://inspect/#remote-debugging, enable remote debugging, and connect with agentic-browser agent start --cdp-url http://127.0.0.1:9222. Chrome asks you to allow the connection once; a background relay keeps that approved connection for later commands and exits after 10 idle minutes.

On older Chrome, launch it with remote debugging and a dedicated profile, then connect:

# 1. Quit Chrome, then relaunch with debugging enabled
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222 --user-data-dir="$HOME/.chrome-agent"
# (Linux: google-chrome --remote-debugging-port=9222 --user-data-dir="$HOME/.chrome-agent")
 
# 2. Connect agentic-browser to it
agentic-browser agent start --cdp-url http://127.0.0.1:9222

Since Chrome 136, --remote-debugging-port is ignored for the default profile, so --user-data-dir is required. Log in once in that window; the profile keeps the sessions. agentic-browser opens its own tab, and stopping the agent closes only that tab, not your Chrome.

Alternatively, launch a new Chrome with your default profile (requires quitting Chrome first):

agentic-browser agent start --user-profile default

Quick Start: MCP Server

If your AI tool supports MCP, configure the stdio server instead of using CLI commands.

Automatic Setup

npx agentic-browser setup

Detects Claude Code, Cursor, and writes the config for you.

Manual: Claude Code

Add to .mcp.json in your project root:

{
  "mcpServers": {
    "agentic-browser": {
      "command": "npx",
      "args": ["agentic-browser", "mcp"]
    }
  }
}

Manual: Cursor

Add to .cursor/mcp.json:

{
  "mcpServers": {
    "agentic-browser": {
      "command": "npx",
      "args": ["agentic-browser", "mcp"]
    }
  }
}

Once configured, you'll see 9 browser tools available in your assistant: browser_start_session, browser_navigate, browser_interact, browser_get_content, browser_get_elements, browser_search_memory, browser_dismiss_cookies, browser_screenshot, browser_stop_session.

Quick Start: Programmatic API

import { createAgenticBrowserCore } from "agentic-browser";
 
const core = createAgenticBrowserCore();
const session = await core.startSession();
 
// Navigate
await core.runCommand({
  sessionId: session.sessionId,
  type: "navigate",
  payload: { url: "https://example.com" },
});
 
// Discover elements
const elements = await core.getInteractiveElements({
  sessionId: session.sessionId,
  visibleOnly: true,
  limit: 30,
});
 
console.log(elements.elements.map((e) => `${e.role}: ${e.text} → ${e.selector}`));
 
// Clean up
await core.stopSession(session.sessionId);

Environment Variables

VariableDefaultDescription
AGENTIC_BROWSER_DIR~/.agentic-browserBase directory for sessions, memory, events
AGENTIC_BROWSER_CHROME_EXECUTABLE_PATH(auto-discover)Explicit path to Chrome executable
AGENTIC_BROWSER_CHROME_PATH(legacy alias)Backward-compatible alias for Chrome executable path
AGENTIC_BROWSER_CDP_URLConnect to an already-running Chrome (e.g. http://127.0.0.1:9222)
AGENTIC_BROWSER_USER_PROFILEUse real Chrome profile (default, true, or an absolute path)
AGENTIC_BROWSER_HEADLESSRun Chrome in headless mode (true or 1)
AGENTIC_BROWSER_USER_AGENTOverride the browser user-agent string
AGENTIC_BROWSER_ALLOW_FILE_URLSAllow navigating to file: URLs (true or 1); off by default
AGENTIC_BROWSER_RELAY(on)0/false disables the CDP relay for chrome://inspect mode
AGENTIC_BROWSER_RELAY_IDLE_MS600000Relay exits after this many ms without clients; 0 = never

Anti-Detection

Chrome is launched with stealth flags (--disable-blink-features=AutomationControlled, --disable-infobars, --excludeSwitches=enable-automation) and runtime patches that remove navigator.webdriver, fake plugins and languages, patch chrome.runtime, clean Function.prototype.toString, and patch Permissions.query. The HeadlessChrome token is also automatically stripped from the user-agent string. No configuration is needed — stealth is always on.

Next Steps