BrowseGrab MCP Server

Local setup required. This server has to be cloned and prepared on your machine before you register it in Claude Code.
1

Set the server up locally

Run this once to clone and prepare the server before adding it to Claude Code.

Run in terminal
pip install browsegrab[mcp]
2

Register it in Claude Code

After the local setup is done, run this command to point Claude Code at the built server.

Run in terminal
claude mcp add browsegrab -- node "<FULL_PATH_TO_BROWSEGRAB>/dist/index.js"

Replace <FULL_PATH_TO_BROWSEGRAB>/dist/index.js with the actual folder you prepared in step 1.

README.md

Token-efficient browser agent for local LLMs

browsegrab

Token-efficient browser agent for local LLMs — Playwright + accessibility tree + MarkGrab, MCP native.

browsegrab is a lightweight browser automation library designed for local LLMs (8B-35B parameters). It combines Playwright's accessibility tree with MarkGrab's HTML-to-markdown conversion to achieve 5-8x fewer tokens per step compared to alternatives like browser-use.

Features

  • Token-efficient: ~500-1,500 tokens/step (vs 4,000-10,000 for browser-use)
  • Local LLM first: Optimized for vLLM, Ollama, and OpenAI-compatible endpoints
  • MCP native: Built-in MCP server with 8 browser automation tools
  • MarkGrab integration: HTML → clean markdown for content extraction
  • Accessibility tree + ref system: Stable element references (e1, e2, ...) without vision models
  • Success pattern caching: Zero LLM calls on repeated workflows
  • 5-stage JSON parser: Robust action parsing for local LLM outputs
  • Minimal dependencies: Only playwright + httpx in core

Installation

pip install browsegrab
playwright install chromium

With optional features:

pip install browsegrab[mcp]      # MCP server support
pip install browsegrab[content]  # MarkGrab content extraction
pip install browsegrab[cli]      # CLI with rich output
pip install browsegrab[all]      # Everything

Quick Start

Python API

from browsegrab import BrowseSession

async with BrowseSession() as session:
    # Navigate and get accessibility tree snapshot
    await session.navigate("https://example.com")
    snap = await session.snapshot()
    print(snap.tree_text)
    # - heading "Example Domain" [level=1]
    # - link "Learn more": [ref=e1]

    # Click using ref ID
    result = await session.click("e1")
    print(result.url)  # https://www.iana.org/help/example-domains

    # Type into search box
    await session.navigate("https://en.wikipedia.org")
    snap = await session.snapshot()
    await session.type("e4", "Python programming", submit=True)

    # Extract compressed content (AX tree + markdown)
    content = await session.extract_content()

CLI

# Accessibility tree snapshot
browsegrab snapshot https://example.com

# JSON output
browsegrab snapshot https://example.com -f json

# Extract content (AX tree + markdown)
browsegrab extract https://en.wikipedia.org/wiki/Python

# Agentic browse (requires LLM endpoint)
browsegrab browse https://example.com "Find the about page"

MCP Server

browsegrab-mcp  # Start MCP server (stdio)

Claude Desktop / Cursor / VS Code config:

{
  "mcpServers": {
    "browsegrab": {
      "command": "browsegrab-mcp"
    }
  }
}

8 MCP tools: browser_navigate, browser_click, browser_type, browser_snapshot, browser_scroll, browser_extract_content, browser_go_back, browser_wait

How It Works

browsegrab separates structure (accessibility tree) from content (MarkGrab markdown), sending only what the LLM needs:

Raw HTML
├── Structure: Accessibility tree → interactive elements → [ref=eN]
│   → ~200-500 tokens
└── Content: MarkGrab → clean markdown (on-demand)
    → ~300-800 tokens

Combined: ~500-1,300 tokens per step

Token efficiency (measured)

Page Interactive elements Tokens browser-use equivalent
example.com 1 ~60 ~500+
Wikipedia article 452 ~1,254 ~10,000+

Architecture

browsegrab/
├── config.py                 # Dataclass configs (env var loading)
├── result.py                 # Result types (ActionResult, BrowseResult, ...)
├── session.py                # BrowseSession orchestrator
├── browser/
│   ├── manager.py            # Playwright lifecycle (async context manager)
│   ├── snapshot.py           # Accessibility tree + ref system
│   ├── selectors.py          # 4-strategy selector resolver
│   └── actions.py            # navigate, click, type, scroll, go_back, wait
├── dom/
│   ├── ref_map.py            # ref ID ↔ element bidirectional mapping
│   └── compress.py           # AX tree + MarkGrab → compressed context
├── llm/
│   ├── base.py               # LLMProvider ABC
│   ├── provider.py           # vLLM, Ollama, OpenAI-compatible
│   ├── prompt.py             # System prompts (~400 tokens)
│   └── parse.py              # 5-stage JSON fallback parser
├── agent/
│   ├── history.py            # Sliding window history compression
│   ├── cache.py              # Domain-based success pattern cache
│   └── loop_guard.py         # Duplicate action detection
├── __main__.py               # CLI (click)
└── mcp_server.py             # FastMCP server (8 tools)

Configuration

All settings via environment variables (BROWSEGRAB_* prefix):

# Browser
BROWSEGRAB_BROWSER_HEADLESS=true
BROWSEGRAB_BROWSER_TIMEOUT_MS=30000

# LLM (for agentic browse)
BROWSEGRAB_LLM_PROVIDER=vllm

Tools (8)

browser_navigateNavigate the browser to a specific URL.
browser_clickClick an element using its reference ID.
browser_typeType text into an input element.
browser_snapshotGet an accessibility tree snapshot of the current page.
browser_scrollScroll the current page.
browser_extract_contentExtract compressed content including accessibility tree and markdown.
browser_go_backNavigate back to the previous page.
browser_waitWait for a specified duration or condition.

Environment Variables

BROWSEGRAB_BROWSER_HEADLESSSet browser to run in headless mode
BROWSEGRAB_BROWSER_TIMEOUT_MSSet the browser timeout in milliseconds
BROWSEGRAB_LLM_PROVIDERSpecify the LLM provider for agentic browsing

Configuration

claude_desktop_config.json
{"mcpServers": {"browsegrab": {"command": "browsegrab-mcp"}}}

Try it

Navigate to https://example.com and extract the main content as markdown.
Go to the Wikipedia page for Python programming and find the section about its history.
Search for the latest news on a specific topic and click the first relevant link.
Fill out the search form on the current page with 'MCP server documentation' and submit it.

Frequently Asked Questions

What are the key features of BrowseGrab?

Token-efficient browsing using accessibility trees. HTML to clean markdown conversion via MarkGrab. Stable element reference system for reliable interaction. Success pattern caching to reduce LLM calls. Optimized for local LLMs like vLLM and Ollama.

What can I use BrowseGrab for?

Automating data extraction from complex websites with minimal token usage. Building local-first AI agents that can interact with web interfaces. Testing web applications by simulating user navigation and input. Summarizing long-form web content into clean markdown for LLM processing.

How do I install BrowseGrab?

Install BrowseGrab by running: pip install browsegrab[mcp]

What MCP clients work with BrowseGrab?

BrowseGrab works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Turn this server into reusable context

Keep BrowseGrab docs, env vars, and workflow notes in Conare so your agent carries them across sessions.

Need the old visual installer? Open Conare IDE.
Open Conare