Skip to main content
Glama
README.md
<h1 align="center">ralpcrawl</h1>

<p align="center">
  <b>Turn any website into clean, LLM-ready markdown or structured JSON — on your own machine.</b><br>
  Scrape · Crawl · Map · Search · Extract · Watch · llms.txt<br>
  One <code>npx</code> command. No API key, no Docker, no Redis, no Rust toolchain.
</p>

<p align="center">
  <a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue" alt="MIT"></a>
  <img src="https://img.shields.io/badge/node-%3E%3D20-339933" alt="Node 20+">
  <img src="https://img.shields.io/badge/Firecrawl%20API-v1%20%2B%20v2%20compatible-orange" alt="Firecrawl compatible">
  <img src="https://img.shields.io/badge/MCP-7%20tools-8A2BE2" alt="MCP">
</p>

```bash
npx -y github:Ralpberry-Labs/ralpcrawl https://docs.python.org/3/library/json.html
```

```markdown
# `json` — JSON encoder and decoder

**Source code:** [Lib/json/\_\_init\_\_.py](https://github.com/python/cpython/tree/3.15/Lib/json/__init__.py)

[JSON (JavaScript Object Notation)](https://json.org/), specified by RFC 7159 ...
```

---

## Why ralpcrawl

Agents need the web as clean text. Hosted scraping APIs are great until you hit the bill, the rate limit, or a page behind your VPN. ralpcrawl runs the whole pipeline locally and speaks the **Firecrawl API**, so existing code and SDKs point at it unchanged.

- **Drop-in Firecrawl API** — `ralpcrawl serve` answers `/v1/*` and `/v2/*`. Tested against the official `@mendable/firecrawl-js` SDK (scrape, map, crawl, batch scrape, search).
- **Everything local, including the "cloud-only" parts** — structured JSON extraction, summaries, screenshots, browser actions, change tracking and search all run on your machine with your own model (Claude, OpenAI, or a local Ollama / LM Studio / llama.cpp server).
- **JavaScript pages just work** — plain HTTP first (fast), automatic fallback to the Chrome already on your machine when a page is a JS app, blocks bots, or returns an empty shell.
- **Agent-native** — MCP server with 7 tools, one-command `init` for Claude Code, Claude Desktop, Cursor, Windsurf, Gemini CLI and Codex, plus a `web-research` skill that teaches agents the cheapest order to use them.
- **Fast** — a 12-page docs crawl finishes in about half a second on a laptop; scrapes are cached on disk with `maxAge`.

### Compared with Firecrawl

| | ralpcrawl | Firecrawl Local | Firecrawl Cloud |
|---|---|---|---|
| Install | `npx` (Node 20+) | `cargo install` (Rust + C compiler) | Hosted, API key |
| Markdown, HTML, links, metadata | ✅ | ✅ | ✅ |
| Crawl, map, batch scrape | ✅ | ✅ | ✅ |
| PDFs | ✅ | ✅ | ✅ |
| JS rendering | ✅ local Chrome, auto-detected | ✅ local Chrome | ✅ |
| Structured JSON extraction | ✅ bring your own LLM | — | ✅ |
| Summaries | ✅ bring your own LLM | — | ✅ |
| Screenshots | ✅ | — | ✅ |
| Browser actions (click, type, scroll, JS) | ✅ | — | ✅ |
| Change tracking with git-style diffs | ✅ local snapshots | — | ✅ |
| Web search | ✅ keyless (DuckDuckGo), SearXNG or Brave | via Cloud | ✅ |
| Multi-page extract (`site.com/*`) | ✅ | — | ✅ |
| llms.txt generator | ✅ | — | (deprecated) |
| RAG chunks with heading trails | ✅ | — | — |
| Token counts per page | ✅ | — | — |
| Works fully offline from any cloud | ✅ | optional | — |
| Firecrawl API on localhost | ✅ v1 + v2 | ✅ v2 | — |
| MCP server + agent installer | ✅ | ✅ | ✅ |

Firecrawl Cloud still wins on scale, proxies and hard anti-bot sites. ralpcrawl is for everything you'd rather run yourself.

---

## Install

```bash
# run once
npx -y github:Ralpberry-Labs/ralpcrawl <url>

# or install the `ralpcrawl` command
npm install -g github:Ralpberry-Labs/ralpcrawl
```

Optional extras:

- **Chrome / Chromium / Edge / Brave** for JavaScript pages, screenshots and actions. Found automatically; override with `RALPCRAWL_CHROME=/path/to/chrome`.
- **An LLM** for `json`, `summary` and `extract` (see [LLMs](#llms)).

Check your setup:

```bash
ralpcrawl doctor
```

---

## CLI

### Scrape

```bash
ralpcrawl https://example.com                         # markdown to stdout (same as `ralpcrawl scrape`)
ralpcrawl scrape https://example.com --json           # full document: markdown + metadata
ralpcrawl scrape <url> -f markdown,links,images       # pick formats
ralpcrawl scrape <url> --full-content                 # keep nav/header/footer
ralpcrawl scrape <url> --include-tags "main,table"    # only these selectors
ralpcrawl scrape <url> -s page.png --full-page        # screenshot
ralpcrawl scrape <url> --chunks --chunk-tokens 400    # RAG chunks
ralpcrawl scrape <url> --max-age 3600000              # reuse a cached copy up to 1h old
ralpcrawl scrape <url> -H "Cookie: session=abc"       # custom headers
ralpcrawl scrape https://arxiv.org/pdf/1706.03762     # PDFs become markdown too
```

Browser actions run before the page is read:

```bash
ralpcrawl scrape https://news.example.com --actions '[
  {"type": "click", "selector": "button.load-more"},
  {"type": "wait", "milliseconds": 1500},
  {"type": "scroll", "direction": "down", "amount": 3},
  {"type": "executeJavascript", "script": "return document.querySelectorAll(\"article\").length"}
]'
```

Action types: `wait`, `click`, `write`, `press`, `scroll`, `screenshot`, `scrape`, `executeJavascript` (same shapes as Firecrawl).

### Structured data

```bash
# schema shorthand: {"field": "type"}, "type[]" for arrays, [{...}] for arrays of objects
ralpcrawl scrape https://example.com/pricing \
  --schema '{"plans": [{"name": "string", "monthly_price": "number", "features": "string[]"}]}'

# or a prompt alone
ralpcrawl scrape https://example.com/team -p "List every person and their role"

# across many pages: /* expands to the most relevant pages under that path
ralpcrawl extract "https://docs.example.com/*" -p "What are the API rate limits per plan?"
```

Full JSON Schema files work too: `--schema ./schema.json`.

### Map

```bash
ralpcrawl map https://docs.firecrawl.dev                  # every URL (sitemaps + links)
ralpcrawl map https://docs.firecrawl.dev -s crawl -l 5    # ranked by relevance
ralpcrawl map <url> --sitemap only --json                 # sitemap URLs with titles
```

### Crawl

```bash
ralpcrawl crawl https://docs.python.org/3/tutorial/ -l 50          # → ./crawl-docs.python.org/**/*.md
ralpcrawl crawl <url> -i "/blog/**" -x "/blog/tag/**" -d 3
ralpcrawl crawl <url> --as jsonl -o out/                           # one JSON doc per line
ralpcrawl crawl <url> --entire-domain --subdomains -c 10 --delay 250
```

Each markdown file gets YAML front matter (`url`, `title`, `description`, `scraped_at`). The crawler respects `robots.txt` (including `Crawl-delay`), de-duplicates canonical URLs (tracking params, `www.`, trailing slashes, `index.html`), skips binary assets, and by default stays under the start URL's folder — exactly like Firecrawl.

### Batch

```bash
ralpcrawl batch https://a.com https://b.com > pages.jsonl
ralpcrawl batch --file urls.txt -o pages/
```

### Search

```bash
ralpcrawl search "best rust web frameworks 2026" -l 5
ralpcrawl search "site:docs.python.org asyncio timeout" --scrape     # include each result's markdown
ralpcrawl search "openai devday" --tbs w                            # past week
```

Backends: DuckDuckGo (default, no key), `RALPCRAWL_SEARXNG_URL` (self-hosted SearXNG), or `BRAVE_API_KEY`.

### Watch for changes

```bash
ralpcrawl watch https://example.com/pricing                 # first run saves a snapshot
ralpcrawl watch https://example.com/pricing                 # later runs print a coloured diff
ralpcrawl watch https://example.com/status --every 15 --include-tags "#incidents"
```

### llms.txt

```bash
ralpcrawl llmstxt https://docs.example.com -l 100 -o ./public   # writes llms.txt + llms-full.txt
```

---

## Firecrawl-compatible API

```bash
ralpcrawl serve                    # http://127.0.0.1:3002
ralpcrawl serve --api-key s3cret   # require Authorization: Bearer s3cret
```

Point any Firecrawl SDK at it:

```js
import Firecrawl from "@mendable/firecrawl-js";

const app = new Firecrawl({ apiKey: "local", apiUrl: "http://127.0.0.1:3002" });
const doc = await app.scrape("https://docs.python.org/3/", { formats: ["markdown", "links"] });
const site = await app.crawl("https://docs.python.org/3/tutorial/", { limit: 20 });
```

```python
from firecrawl import Firecrawl

app = Firecrawl(api_key="local", api_url="http://127.0.0.1:3002")
print(app.scrape("https://example.com").markdown)
```

| Endpoint | v1 | v2 |
|---|---|---|
| `POST /scrape` | ✅ | ✅ |
| `POST /batch/scrape`, `GET /batch/scrape/:id`, `DELETE` | ✅ | ✅ |
| `POST /crawl`, `GET /crawl/:id`, `GET /crawl/:id/errors`, `DELETE`, `GET /crawl/active` | ✅ | ✅ |
| `POST /map` | ✅ (strings) | ✅ (objects with titles) |
| `POST /search` | ✅ | ✅ (`data.web`) |
| `POST /extract`, `GET /extract/:id` | ✅ | ✅ |
| `POST /llmstxt`, `GET /llmstxt/:id` | ✅ | ✅ |

**Security defaults:** binds to `127.0.0.1`; refuses to fetch loopback, private and link-local addresses (SSRF guard, checked on every redirect hop and every browser navigation) unless you pass `--allow-private`; API key comparison is constant-time; request bodies are capped at 5 MB.

Docker:

```bash
docker build -t ralpcrawl .
docker run -p 3002:3002 -e RALPCRAWL_API_KEY=s3cret ralpcrawl
```

---

## MCP server (Claude, Cursor, Codex, …)

One command registers ralpcrawl with every AI tool it finds (Claude Code, Claude Desktop, Cursor, Windsurf, Gemini CLI, Codex). It backs up each config first:

```bash
ralpcrawl init            # or: ralpcrawl init --dry-run
```

Or add it by hand:

```json
{
  "mcpServers": {
    "ralpcrawl": { "command": "npx", "args": ["-y", "github:Ralpberry-Labs/ralpcrawl", "mcp"] }
  }
}
```

Claude Code plugin (MCP server + `web-research` skill):

```
/plugin marketplace add Ralpberry-Labs/ralpcrawl
/plugin install ralpcrawl@ralpcrawl
```

| Tool | What it does |
|---|---|
| `ralpcrawl_scrape` | One URL → markdown / links / JSON / change diff, with actions |
| `ralpcrawl_map` | All URLs on a site, optionally ranked by a search term |
| `ralpcrawl_crawl` | Breadth-first crawl with path filters |
| `ralpcrawl_batch_scrape` | Many URLs in parallel |
| `ralpcrawl_search` | Keyless web search, optionally scraping results |
| `ralpcrawl_extract` | Structured JSON or a cited answer across pages |
| `ralpcrawl_llmstxt` | llms.txt for any site |

Outputs are clipped to `RALPCRAWL_MCP_MAX_CHARS` (default 80,000) so a huge page can't blow an agent's context.

### The `web-research` skill

[`skills/web-research/SKILL.md`](skills/web-research/SKILL.md) teaches agents a cost ladder — scrape a known URL → map + scrape → search + scrape → extract → small crawl — plus recipes and red flags (e.g. "about to crawl 50+ pages? map instead"). Drop it into any skills folder.

---

## Library

```ts
import { scrape, crawlStream, map, search, extract, chunkMarkdown } from "ralpcrawl";

const doc = await scrape("https://example.com", { formats: ["markdown", "links"] });
console.log(doc.markdown, doc.metadata.title, doc.metadata.tokens);

for await (const ev of crawlStream("https://docs.example.com", { limit: 100, includePaths: ["/guides/**"] })) {
  if (ev.type === "page") console.log(ev.doc.metadata.url);
}

const pricing = await scrape("https://example.com/pricing", {
  formats: [{ type: "json", schema: { plans: [{ name: "string", price: "string" }] } }],
});
```

Every document has `metadata` with `title`, `description`, `language`, Open Graph fields, `canonical`, `favicon`, `author`, published/modified times, parsed `jsonLd`, `statusCode`, `contentType`, `engine` (`http` / `browser` / `cache`), `wordCount`, `tokens` and `readingTimeMinutes`.

---

## LLMs

`json`, `summary` and `extract` use whichever model you configure. Nothing is sent anywhere unless you set one of these:

| Provider | Environment |
|---|---|
| Anthropic | `ANTHROPIC_API_KEY` (default model `claude-haiku-5-5`) |
| OpenAI | `OPENAI_API_KEY` (default model `gpt-4.1-mini`) |
| Ollama | `RALPCRAWL_LLM_BASE_URL=http://localhost:11434/v1` `RALPCRAWL_LLM_MODEL=qwen3:8b` |
| LM Studio / llama.cpp / vLLM | `RALPCRAWL_LLM_BASE_URL=http://localhost:1234/v1` `RALPCRAWL_LLM_MODEL=...` |
| OpenRouter, Groq, Together, … | `RALPCRAWL_LLM_BASE_URL` + `RALPCRAWL_LLM_API_KEY` + `RALPCRAWL_LLM_MODEL` |

Anthropic extraction uses forced tool use and OpenAI-compatible servers use `json_schema` response format, with automatic fallback to JSON mode for local servers that don't support schemas. If no model is configured, scrapes still succeed and include a `warning`.

---

## Environment variables

| Variable | Purpose |
|---|---|
| `RALPCRAWL_CHROME` | Path to Chrome/Chromium |
| `RALPCRAWL_CACHE_DIR` | Cache + change-tracking snapshots (default `~/.cache/ralpcrawl`) |
| `RALPCRAWL_API_KEY` | Bearer token for `serve` |
| `RALPCRAWL_LLM_PROVIDER` | Force `anthropic` or `openai` |
| `RALPCRAWL_LLM_BASE_URL`, `RALPCRAWL_LLM_API_KEY`, `RALPCRAWL_LLM_MODEL` | Any OpenAI-compatible model |
| `RALPCRAWL_LLM_MAX_CHARS` | Max page characters sent to the model (default 120,000) |
| `RALPCRAWL_SEARXNG_URL`, `BRAVE_API_KEY` | Search backends |
| `RALPCRAWL_MCP_MAX_CHARS` | Max characters per MCP tool result |

---

## How it works

```
URL ─► HTTP fetch (redirects, SSRF guard, charset, 50 MB cap)
          │  empty shell / JS app / 403 / 429?
          ├──────────────► headless Chrome (ads blocked, actions, screenshot)
          ▼
   PDF ─► unpdf text ─┐
   HTML ─► strip scripts, boilerplate, cookie banners
          ─► <main>/<article> if it holds the content, else Readability, else cleaned body
          ─► absolute URLs, lazy images, base64 removal
          ─► Turndown + GFM tables + fenced code with languages
          ▼
   markdown ─► chunks · tokens · change diff (Myers) · LLM json/summary
```

## Development

```bash
npm install
npm run check     # typecheck + 34 tests (local fixture site, mock LLM, real Chrome when present)
npm run dev -- scrape https://example.com
npm run build
```

## Responsible use

Respect `robots.txt` (on by default), site terms and rate limits. Use `--delay` for small sites. Don't scrape content behind logins you don't own, or personal data you have no right to process.

## License

MIT © Ralpberry Labs