webrain # WebRain **A portable, LLM-driven browser-automation & web-scraping MCP server — one binary, three engines, any OS.** WebRain exposes 19 intent-based tools over the **Model Context Protocol**. Install it on any system, point any LLM client (GitHub Copilot, Claude, Codex, Cursor, …) at it, and the model decides everything — search, crawl, scrape, navigate, interact — from a plain-language prompt. No hardcoded intent detection, no daemon, no Node.js. [![Latest Release](https://badgen.net/github/release/prokopis3/webrain?icon=github)](https://github.com/prokopis3/webrain/releases) [![License: MIT](https://img.shields.io/badge/license-MIT-blue?style=flat-square)](LICENSE) [![Platforms](https://img.shields.io/badge/platforms-Linux%20%7C%20macOS%20%7C%20Windows-blue?style=flat-square)](https://github.com/prokopis3/webrain/releases) [![Last Commit](https://badgen.net/github/last-commit/prokopis3/webrain/main?icon=github)](https://github.com/prokopis3/webrain/commits/main) [![GitHub Stars](https://badgen.net/github/stars/prokopis3/webrain?icon=github)](https://github.com/prokopis3/webrain/stargazers) [![Rust](https://img.shields.io/badge/rust-1.100+-orange.svg)](Cargo.toml) **Benchmarks:** **50 pages in 10.5 s** on a local stealth engine · **11.7 s** on local Chrome · full structured payload (~10.5 KB/page) — [see the numbers](#benchmarks).
--- ## Why webrain? Web automation shouldn't mean wiring up a driver, a browser download, and your own tool wrappers before an LLM can touch a page. Webrain collapses that into **one binary + one install command** and speaks MCP, so any LLM client drives it directly. | | **webrain** | Raw Playwright / Puppeteer | |---|---|---| | **Setup** | one binary + `webrain install` | runtime + driver + browser download + your own wrappers | | **Browsers** | Chrome + lightpanda + obscura through one CDP backend | one engine, usually Chromium | | **LLM-ready** | MCP server, 19 tools, built-in decision guide | you hand-roll tool functions | | **Anti-bot** | challenge detection + persistent profile + native login | manual | | **Extraction** | autoschema → JSON / regex / table / spider / batch | you write selectors | | **Runs on** | any OS, any LLM client, or plain CLI | tied to your stack | ## What you can do with it - **Scrape at scale** — `webrain_batch` runs one op across many URLs in parallel tabs; `webrain_crawl` handles spider / sitemap / infinite-scroll / URL-validation, both with auto-throttle and checkpoint-resume. - **Structured data without hand-written selectors** — `webrain_extract` mode `autoschema` proposes the repeated container, then `schema` / `regex` / `table` / `jsonld` read it. All zero-LLM. - **Stealth login** — real-Chrome profiles with an encrypted local credential vault (AES-256-GCM + optional TOTP), plus cookie transfer across engines. - **Get past challenges** — every `webrain_navigate` reports a `challenge` field; protected sites are attempted with real Chrome + a persistent profile + native login, and whether a gate clears depends on the site. Native CAPTCHA/vision v2 (drag, `eval_in_frame`, vision ask) — no Python sidecar. - **See the page** — `webrain_observe` (state / a11y / semantic tree) plus vision tiles (screenshot → vector store) for tables and charts. - **Structured search** — `webrain_serp` returns typed JSON (`position`/`title`/`url`/`domain`/`snippet`), deduped and paginated, across provider tiers: free HTTP engines → Brave API key → browser render → serpapi. - **Read anything** — `webrain_pdf` (extract + render), JSON-LD, media, plus `webrain_scrape` for static pages over plain HTTP with no browser process at all. - **Talk to it, and watch it work** — `webrain chat` drives all of the above from your own model key; `chat --serve` puts that turn in a page with tool cards you can re-run, model-written follow-up chips, conversation totals, and replies that can be laid out as cards or tables instead of prose. See [Chat](#chat). --- ## Prerequisites - **OS**: Windows, macOS, or Linux (x86_64 / arm64). - **A browser engine** — run `webrain install` once (downloads Chrome for Testing). Obscura and Lightpanda are optional extra engines. - **Linux**: system libraries for Chrome — see [installation](docs/installation.mdx#linux-dependencies). - **Docker** — only to run the obscura / lightpanda engines in containers. - **An MCP-capable client** (VS Code + Copilot, Claude, Codex, Cursor, …) — optional; the CLI works standalone. - **For `webrain chat`** — the Copilot runtime first (`webrain install copilot`), then a model key. See [Chat](#chat). ## Installation > Install model mirrors [vercel-labs/agent-browser](https://github.com/vercel-labs/agent-browser): a native binary plus an `install` command that downloads engines into a cache dir. ### Global Installation (recommended) One command installs `webrain` on your PATH: **Linux / macOS:** ```bash curl -fsSL https://raw.githubusercontent.com/prokopis3/webrain/main/scripts/install.sh | bash ``` **Windows (PowerShell):** ```powershell irm https://raw.githubusercontent.com/prokopis3/webrain/main/scripts/install.ps1 | iex ``` Then download a browser engine once — `webrain install` — and follow [Run it](#run-it). **Installing with an AI agent?** Point it at . That page is written to be executed: commands, the `webrain doctor` check and its exit codes, the client config, and the first tool call. indexes the rest of the docs. ### Other install paths Homebrew, Scoop, `cargo install`, a manual binary download, and a from-source build are all covered in [docs/installation.mdx](docs/installation.mdx), together with the Linux system libraries Chrome needs. ### From Source ```bash git clone https://github.com/prokopis3/webrain cd webrain cargo build --release --bin webrain --features pdfium # what the release builds ./target/release/webrain install # Download Chrome (first time only) ./target/release/webrain mcp --http 9223 ``` `--features pdfium` enables `pdf_render` (it binds the system pdfium at runtime, so `webrain install pdfium` still supplies the library). Add `,chat` for [`webrain chat`](docs/guides/chat.mdx) — that pulls a ~135 MB Copilot runtime and needs OS OpenSSL 3 on Linux, so it is opt-in; needs Rust 1.100+. **Not available on a static musl target**: `copilot-sdk` 2.0.1 refuses a vendored OpenSSL and requires `OPENSSL_STATIC=0`, so a static-pie binary cannot carry it — the musl builds ship every tool except chat. ### Updating Upgrade to the latest version: ```bash webrain upgrade ``` Detects your installation method (Homebrew, Scoop, or a manual install) and updates automatically — `brew upgrade webrain`, `scoop update webrain`, or self-updates the binary in place. If installed via cargo: ```bash cargo install --git https://github.com/prokopis3/webrain webrain-cli --force ``` Re-download engines after an update (cache dir stays, versions are additive): ```bash webrain install webrain install --engine obscura ``` ### OS Compatibility Every engine, per OS: | Engine | Windows | macOS | Linux | |---|---|---|---| | **Chrome for Testing** (`webrain install`) | ✅ | ✅ | ✅ | | **Obscura** (`webrain install --engine obscura`) | ✅ x86_64 | ✅ x86_64 / arm64 | ✅ x86_64 / arm64 | | **Lightpanda** (`webrain lightpanda`, binary needed) | ⚠️ (needs a Windows build on PATH) | ✅ | ✅ | | **Docker** (`docker/Dockerfile`) | via Docker Desktop | via Docker Desktop | ✅ | Binary discovery is automatic on every OS: env override → PATH → `~/.lightpanda`, `~/.obscura`, `~/.local/bin` → the webrain engine cache. ## Run it ```bash webrain install # 1. one browser engine (Chrome for Testing) webrain doctor # 2. verify: engines, CDP ports, vault, MCP webrain mcp # 3. MCP over stdio (VS Code, Claude, Cursor, …) webrain mcp --http 9223 # …or HTTP on http://127.0.0.1:9223/mcp ```

Four steps in order: webrain install downloads one engine, webrain doctor checks engines, CDP ports, the vault and MCP, webrain mcp serves the 19 tools over stdio or HTTP, and your agent calls one

Register that server in your client (see *Marketplace / IDE Plugins* below), then just ask: **“scrape every product title and price from ”**. Prefer the CLI? `webrain launch` gives you headed Chrome with a persistent profile, and every MCP tool has a command twin — see [Commands](#commands). ### Selecting elements The MCP tools drive elements by **index**, not by CSS selector: `webrain_navigate` / `webrain_observe` return the interactive elements (`a, button, input, select, textarea, [role=button]`) and `webrain_interact` takes that index — `{"action": "click", "index": 3}`. The CLI uses the same 1-indexed refs: ```bash webrain launch # guest-mode Chrome (no profile state) webrain fetch https://example.com # prints the page text + interactive elements webrain click 3 # click element #3 webrain type 5 "text" # type into element #5 webrain eval 'document.querySelector("#email").value' ``` ## Commands ```bash webrain [] --help # any command, any depth (install watch, vault rm) webrain mcp [--http ] # MCP server (stdio, or HTTP on a port) webrain doctor # diagnose the install (engines, MCP, CDP, vault) webrain install [--engine chrome|obscura] [--stealth] # download a browser engine webrain upgrade # update the binary + the chat page / # Copilot runtime already installed webrain launch [url] # stealth Chrome, persistent profile webrain login [url] # interactive login into a profile webrain vault set|list|user|rm # encrypted credential vault (AES-256-GCM + TOTP) webrain cookies / setcookies # export / import cookies webrain fetch # attach to CDP_URL and fetch webrain screenshot # full-page screenshot (always full page) webrain spider [--depth N --pages N --respect-robots] # crawl webrain click / type / eval # drive the CDP_URL backend webrain tool '' [--url U] # ANY of the 19 MCP tools, no model needed webrain read [--browser|--outline|--filter T] # a page as markdown (HTTP; --browser for a host that refuses it) webrain pdf [--json] # PDF text as markdown (no browser) webrain obscura / lightpanda [--port N] # spawn a CDP server webrain watch [--vision] # transcript + frames (no browser) webrain install watch|whisper [--model NAME] # ffmpeg + yt-dlp + whisper (STT) webrain install vision [--model ID] [--model-update] # llama-server + a local vision model webrain uninstall vision --model ID | --all # remove installed vision models webrain serp "" [--engine …] [--limit N] # structured JSON search (7 engines + auto) webrain diff [--max N] [--json] # what changed between two pages (exit 1 if so) webrain chat "" [--provider P] [--search] # one agent turn on your own model key ``` The 19-tool MCP surface is discovered dynamically — `webrain_guide` lists it for the LLM (see [MCP Tools](#mcp-tools)) — and `webrain tool` runs any one of them from a shell, so an extraction or a network log needs no model and no key. ## Chat `webrain chat` is the built-in agent: one Copilot turn on **your own model key**, with this binary's own MCP tools attached, so the turn can actually navigate, extract and screenshot. `chat --serve` puts the same turn in a browser page — threads, a turn ledger, dictation and image attachments. Install it in three steps. The Copilot runtime is **not** embedded in the release binary, so chat does not start without the first: ```bash webrain install copilot # 1. the Copilot runtime chat drives (~135 MB, SHA-256 verified) webrain install chat-ui # 2. the page `chat --serve` serves (digest-verified) webrain install # 3. a browser engine, so the tools can drive a real page export OPENROUTER_API_KEY=… # or any of the 16 provider rows webrain chat "what does news.ycombinator.com say today?" webrain chat --serve # browser UI on http://127.0.0.1:8787/ ``` - **Keys**: 16 BYOK providers, one key is enough — `--provider` / `--model` pick the row, `--key-from VAR` and `--base-url` cover anything else, and `WEBRAIN_CHAT_API_KEY` works for any row. `webrain help env` lists the ambient names. - **Tools need approval**: reads and navigation run; writes and clicks need `--yes` (the `--serve` page asks instead). - `COPILOT_CLI_PATH` points chat at a Copilot CLI you already have. Chat keeps its own `COPILOT_HOME` and never reads `~/.copilot`. - From source it is opt-in: `cargo build --release --features chat` (Rust 1.100+; Linux needs OS OpenSSL 3, which is why the static musl builds leave chat out; `chat-bundled` embeds the runtime). Every release binary carries it except the two `*-linux-*-musl` ones. ### After an upgrade The runtime and the page live **outside** the binary, so a new version will not run the old ones. `webrain upgrade` refreshes both in the same run, and only the ones already on disk: ``` webrain: 0.20.0 -> v0.21.0 chat UI already installed: …/browsers/chat-ui # no-op: this build's page Downloading Copilot runtime 1.0.120 (copilot-win32-x64.zip)... # pin moved ``` Each `install` runs as the **new** binary — it is the only one that knows the page digests and the Copilot pin — so an unchanged page or runtime costs a digest check and nothing else. Homebrew and Scoop installs chain the same two commands onto their own update. `--force` re-downloads both. Skip `upgrade` (a `cargo install … --force`, or switching between a release binary and a checkout) and the two steps are still separate: ```bash webrain install chat-ui # the new page; an old one fails its digest check webrain install copilot # keyed on this build's pin, so no --force ``` `install chat-ui` replaces a page from another version on its own — it verifies the unpacked files against this build's digests, so an old page is refused, never served. `install copilot` now keys on the pin compiled into this build: a runtime from another version is replaced instead of reported as "already installed", and the old one is deleted once the new one verifies. `--force` is only for re-downloading the *same* pin (a truncated archive, say). ### What the page does that a terminal does not ![A turn in webrain chat: the prompt, the answer streaming in, the turn footer and three follow-up chips](docs/images/chat-turn.gif) *One turn, recorded: the prompt, the answer arriving, the closing `… · 0 steps · 6.2s` line and the three follow-up chips the model wrote.* ![An html-mode answer: a dashboard of cards, stats, pills and a progress bar](docs/images/chat-html-answer.png) *The same page in `html` mode, where an answer can be a dashboard rather than prose.* - **The reply can be laid out, not just written.** Settings → Chat switches rendering between `markdown` and a sanitised **HTML5 fragment**. In `html` mode the model is told which shapes the page styles — a short answer is a paragraph, comparable items are `div.grid > section.card`, a number worth reading is `div.stat`, a comparison is a table — so "design it" is not something you have to ask for; ask a comparison question and it comes back as cards. `