How 0xmassi/webclaw works
Purpose and workspace
Webclaw is a Rust workspace that converts web URLs into clean Markdown, text, JSON, HTML, and LLM-ready context. It supports local-first scraping/crawling plus hosted fallbacks for protected or JavaScript-rendered sites. Workspace composition and shared dependency boundaries are defined in Cargo.toml; deployment is container-ready via Dockerfile and docker-compose.yml.
Entry points and delivery surfaces
Three Rust binaries expose the same underlying capabilities:
• CLI for one-shot scraping, crawling, mapping, batch work, branding, diffing, and LLM operations: crates/webclaw-cli/src/main.rs, crates/webclaw-cli/src/bench.rs.
• REST server with versioned operational routes: crates/webclaw-server/src/main.rs, crates/webclaw-server/src/routes/mod.rs.
• MCP stdio/server integration for agent clients: crates/webclaw-mcp/src/main.rs, crates/webclaw-mcp/src/server.rs, crates/webclaw-mcp/src/tools.rs.
A Node-based bootstrapper configures MCP clients: packages/create-webclaw/index.mjs.
Fetch, access, and crawl layer
webclaw-fetch owns network I/O and is the boundary between untrusted URLs/the web and pure extraction. Its fetch pipeline selects HTTP clients, browser/cloud paths, proxy/TLS behavior, and returns documents for downstream processing: crates/webclaw-fetch/src/fetcher.rs, crates/webclaw-fetch/src/client.rs, crates/webclaw-fetch/src/document.rs.
Crawling follows discovered links under crawl policy; mapping discovers URLs without full extraction. URL-security logic is a material SSRF/trust boundary: crates/webclaw-fetch/src/crawler.rs, crates/webclaw-fetch/src/map.rs, crates/webclaw-fetch/src/url_security.rs.
Extraction and normalized content
webclaw-core is the network-independent transformation engine. It parses and filters HTML, identifies main content/noise, extracts metadata and structured data, and emits normalized output types. Core orchestration and public API reside in crates/webclaw-core/src/lib.rs, crates/webclaw-core/src/extractor.rs, crates/webclaw-core/src/types.rs.
Format production and enrichment are separated into Markdown/LLM output, metadata, links/images, and structured-data stages: crates/webclaw-core/src/markdown.rs, crates/webclaw-core/src/llm/mod.rs, crates/webclaw-core/src/structured_data.rs. Specialized page handling exists for Reddit and YouTube: crates/webclaw-core/src/reddit.rs, crates/webclaw-core/src/youtube.rs.
Site-specific and document paths
The fetch crate dispatches domain/content-specific extractors before or alongside generic extraction, covering commerce, GitHub, social, package registries, and publication sites: crates/webclaw-fetch/src/extractors/mod.rs, crates/webclaw-fetch/src/extractors/ecommerce_product.rs, crates/webclaw-fetch/src/extractors/github_repo.rs.
PDF extraction is isolated behind a dedicated crate, preserving a document-type boundary: crates/webclaw-pdf/src/lib.rs, crates/webclaw-pdf/src/error.rs.
LLM-backed transformations
webclaw-llm implements structured extraction, cleaning, summarization, and chained LLM workflows over fetched/core-normalized content: crates/webclaw-llm/src/lib.rs, crates/webclaw-llm/src/chain.rs, crates/webclaw-llm/src/extract.rs.
Provider adapters isolate external model APIs and local runtime integration: crates/webclaw-llm/src/provider.rs, crates/webclaw-llm/src/providers/openai.rs, crates/webclaw-llm/src/providers/ollama.rs. Supported external services include OpenAI-compatible endpoints, Anthropic, Gemini, and Ollama.
Server control plane and infrastructure
The self-hosted server maps HTTP requests to scrape/crawl/map/batch/LLM/brand/diff operations, with shared application state and authentication boundaries: crates/webclaw-server/src/routes/scrape.rs, crates/webclaw-server/src/routes/crawl.rs, crates/webclaw-server/src/state.rs, crates/webclaw-server/src/auth.rs.
Hosted Webclaw is an optional external service, selected with API credentials for cloud rendering, protected-site access, search, research, and asynchronous workflows. Proxy infrastructure is configurable as a single endpoint or pool and integrated in crates/webclaw-fetch/src/proxy.rs; browser/cloud retrieval paths are in crates/webclaw-fetch/src/browser.rs and crates/webclaw-fetch/src/cloud.rs.
Main entry points: fetcher.rs Fetch pipeline · chain.rs LLM workflows · mod.rs Operational routes · server.rs MCP server
Components 19
Delivery surfaces
- CLI · One-shot and batch content operations.
crates/webclaw-cli/src/main.rs - REST server · Versioned self-hosted operational API.
crates/webclaw-server/src/main.rs - MCP server · Stdio integration for agent clients.
crates/webclaw-mcp/src/server.rs - MCP bootstrapper · Configures MCP clients.
packages/create-webclaw/index.mjs - Operational routes · Scrape, crawl, map, batch, LLM, brand, and diff endpoints.
crates/webclaw-server/src/routes/mod.rs - Auth and app state · Shared state and authentication boundary.
crates/webclaw-server/src/auth.rs
Content pipeline
- Fetch pipeline · Network boundary that selects retrieval paths and returns documents.
crates/webclaw-fetch/src/fetcher.rs - Crawl and map · Follows permitted links or discovers URLs without full extraction.
crates/webclaw-fetch/src/crawler.rs - URL security · Validates URL trust before network access.
crates/webclaw-fetch/src/url_security.rs - Site extractors · Domain-specific handlers run beside generic extraction.
crates/webclaw-fetch/src/extractors/mod.rs - Core extraction · Network-independent HTML parsing, filtering, and normalization.
crates/webclaw-core/src/extractor.rs - Content formats · Produces Markdown, LLM context, metadata, links, and structured data.
crates/webclaw-core/src/markdown.rs - PDF extraction · Dedicated document-type extraction boundary.
crates/webclaw-pdf/src/lib.rs - LLM workflows · Structured extraction, cleaning, summaries, and chains.
crates/webclaw-llm/src/chain.rs
External access
- Model providers · Adapters for hosted APIs and local Ollama.
crates/webclaw-llm/src/provider.rs - Target websites
- Hosted access · Optional rendering, protected-site, search, and async fallback.
crates/webclaw-fetch/src/cloud.rs - Proxy and browser · Configurable proxy and browser-based retrieval.
crates/webclaw-fetch/src/browser.rs - Model APIs · OpenAI-compatible, Anthropic, Gemini, and Ollama endpoints.
Connections 23
- MCP bootstrapper → MCP server: configures clients for
- CLI → Fetch pipeline: invokes
- CLI → LLM workflows: invokes
- REST server → Operational routes: serves
- Operational routes → Auth and app state: uses
- Operational routes → Fetch pipeline: dispatches
- Operational routes → LLM workflows: dispatches
- MCP server → Fetch pipeline: invokes
- MCP server → LLM workflows: invokes
- Crawl and map → URL security: validates discovered URLs
- Crawl and map → Fetch pipeline: fetches permitted URLs
- Fetch pipeline → URL security: checks targets
- Fetch pipeline → Target websites: retrieves
- Fetch pipeline → Proxy and browser: selects
- Fetch pipeline → Hosted access: falls back to
- Fetch pipeline → Site extractors: dispatches specialized content
- Fetch pipeline → Core extraction: passes documents to
- Fetch pipeline → PDF extraction: routes PDFs to
- Site extractors → Core extraction: enriches generic extraction
- Core extraction → Content formats: normalizes into
- Content formats → LLM workflows: supplies context to
- LLM workflows → Model providers: uses
- Model providers → Model APIs: calls