How-to Guides

Step-by-step guides for the most common AGENT BROWSER tasks. Start with Basic Navigation if you are new.

Basic navigation and snapshots

Beginner
1

Open a URL

agent-browser open https://example.com

This launches Chrome and navigates to the URL. Chrome starts automatically on first use.

2

Take a snapshot

agent-browser snapshot

Returns a compact accessibility tree. Each element gets a ref like @e1, @e2 for deterministic targeting.

3

Interact using refs

agent-browser click @e3
agent-browser fill @e5 "hello@world.com"
agent-browser press Enter

Refs from the snapshot are stable within the same page load. Take a new snapshot after navigation.

4

Take a screenshot

agent-browser screenshot output.png

Saves the current viewport as a PNG. Full-page screenshots use --full flag.

5

Close the session

agent-browser close

Closes the active tab. Use --all to close all sessions.

Automating a login flow

Intermediate
1

Navigate to login page

agent-browser open https://app.example.com/login

Start with a fresh session for authentication flows.

2

Fill credentials

agent-browser snapshot
agent-browser fill @e2 "your@email.com"
agent-browser fill @e3 "yourpassword"

Always take a snapshot first so you have the correct refs for the current page.

3

Submit the form

agent-browser click @e4
# or
agent-browser press Enter

After clicking submit, wait for navigation before taking the next snapshot.

4

Save session for reuse

agent-browser open https://app.example.com/login --session myapp
# after login completes:
# session "myapp" now carries the auth cookies

Named sessions persist auth state across multiple agent runs.

Extracting data from pages

Intermediate
1

Read page as clean text

agent-browser read https://example.com/article

Fetches and returns agent-readable text without launching Chrome. Great for articles and docs pages.

2

Get specific element text

agent-browser snapshot
agent-browser get text @e7

Returns the text content of a specific element identified by its ref.

3

Get element attributes

agent-browser get attr @e2 href
agent-browser get attr @e5 data-id

Useful for extracting URLs, data attributes, and other metadata.

4

Run custom JavaScript

agent-browser eval "document.querySelectorAll('h2').length"
agent-browser eval "window.__NEXT_DATA__"

Evaluate arbitrary JS in the page context and get the result back.

Using the MCP server

Advanced
1

Start the MCP server

agent-browser mcp

Starts an MCP stdio server that exposes all browser commands as tools to any MCP-compatible agent.

2

Configure Claude Desktop

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

Add this to your Claude Desktop config at ~/Library/Application Support/Claude/claude_desktop_config.json

3

Configure Cursor

{
  "mcp": {
    "servers": {
      "agent-browser": {
        "command": "agent-browser",
        "args": ["mcp"]
      }
    }
  }
}

Add to your .cursor/mcp.json or Cursor settings.

Looking for the full command reference or configuration options?