For the complete documentation index, see llms.txt. Markdown variants are available by appending .md to any URL or sending an Accept: text/markdown header. An agent skill is available at /.well-known/agent-skills/site-skill.md.
319
Sponsor

Browser

A browser-operating agent that interacts with live web pages using Playwright-based tools with accessibility-tree ref ids.

Output will stream here when you run the agent.

Summary

The Browser Agent completes tasks on the live web by driving a real Chromium browser. It uses Playwright-based tools with accessibility-tree ref ids for stable element targeting, web search as a fallback, and persists state to Turso (libSQL). Reach for it to automate flows, scrape interactive pages, or test UIs.

Installation

$ pnpm dlx shadcn@latest add @agentcn/mastra/browser-agent

Composition

├── config.ts          # Agent config with browser, model, and web_search tool
├── instructions.md    # Comprehensive browser operation instructions
└── memory.ts          # Memory with last 10 messages

Environment Variables

BROWSER_HEADLESS=      # Optional: Set to "false" for visible browser (default: true)
BROWSER_CDP_URL=       # Optional: CDP endpoint for remote browser
TURSO_DATABASE_URL=    # Required: Turso libSQL URL for storage
TURSO_AUTH_TOKEN=      # Optional: Turso auth token

How It Works

  1. Navigate - Call browser_goto with the target URL
  2. Snapshot - Call browser_snapshot to get the accessibility tree with ref ids
  3. Interact - Use ref ids from snapshot for browser_click, browser_type, etc.
  4. Re-snapshot - Take new snapshot after actions to see updated state
  5. Verify - Take final snapshot to confirm results before reporting
  6. Fallback - Use web_search for quick factual questions

Customization

  • Remote browser. Set BROWSER_CDP_URL to connect to a remote CDP endpoint like Bright Data Browser API.
  • Headless mode. Set BROWSER_HEADLESS=false for visible browser during development.
  • Swap models. Edit the model field in config.ts.
  • Adjust steps. Modify maxSteps in config.ts (default: 100).