crawlforge-mcp
CLAUDE.md2 starsChanged 3 months agoMITView on GitHub
Behavioral guidelines to reduce common LLM coding mistakes. Merge with project-specific instructions as needed. Tradeoff: These guidelines bias toward caution over speed. For trivial tasks, use judgment. 1. Think Before Coding Don't assume. Don't hide confusion. Surface tradeoffs. Before implementing: State your assumptions explicitly. If uncertain, ask. If multiple interpretations exist, present them - don't pick silently. If a simpler approach exists, say so. Push back when warranted. If something is unclear, stop. Name what's confusing. Ask. 2. Simplicity First…
- Reads credentials
- Installs packages
In this repository12 other files it gives its agents.
- agent-creatorSkill
- api-documenterSkill
- deployment-managerSkill
- mcp-implementationSkill
- next-phaseSkill
- performance-monitorSkill
- project-managerSkill
- security-auditorSkill
- teammate-toolSkill
- teammate-workflowSkill
- testing-validationSkill
- docsSkill
The file
Show its rules and text
We split this CLAUDE.md into the rules it gives an agent
29 rules. About 0 are common, 16 are distinctive, and 13 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈16
Distinctive · estimate
This author's own choices. Worth a look.
13
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Distinctive: line 10
Don't assume. Don't hide confusion.
- Distinctive: line 15
If multiple interpretations exist, present them - don't pick silently.
- Distinctive: line 16
If a simpler approach exists, say so.
- Distinctive: line 17
If something is unclear, stop.
- Distinctive: line 22
No features beyond what was asked.
- Distinctive: line 23
No abstractions for single-use code.
- Distinctive: line 25
No error handling for impossible scenarios.
- Distinctive: line 26
If you write 200 lines and it could be 50, rewrite it.
- Distinctive: line 27
Ask yourself: "Would a senior engineer say this is overcomplicated?" If yes, simplify.
- Distinctive: line 32
When editing existing code:
- Distinctive: line 34
Don't "improve" adjacent code, comments, or formatting.
- Distinctive: line 35
Don't refactor things that aren't broken.
- Distinctive: line 37
If you notice unrelated dead code, mention it - don't delete it.
- Distinctive: line 38
When your changes create orphans:
- Very specific: line 40
Remove imports/variables/functions that YOUR changes made unused.
- Distinctive: line 41
Don't remove pre-existing dead code unless asked.
- Very specific: line 126
All diagnostic output (Winston logs + status banners) goes to stderr.
- Very specific: line 128
Use --expose-gc flag for memory profiling: node --expose-gc server.js
- Very specific: line 129
Check cache/ directory for cached responses
- Very specific: line 196
Tool Registration: All tools registered via server.registerTool(), wrapped with withAuth() for credit tracking
- Very specific: line 272
When adding a new tool to server.js:
- Very specific: line 274
Import the tool class from src/tools/
- Very specific: line 277
Ensure tool implements execute(params) method
- Very specific: line 278
Add to cleanup array in gracefulShutdown if it has destroy() or cleanup() methods
- Distinctive: line 279
Update tool count in console log at server startup
- Very specific: line 303
Run npm audit locally to check dependencies.
- Very specific: line 338
When a phase completes, update docs/PRODUCTION_READINESS.md
- Very specific: line 340
Put all documentation md files into the docs/ folder
- Very specific: line 341
Every time you finish a phase run the test suites (npm run test:unit and npm test) and fix all failures before pushing
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Behavioral guidelines to reduce common LLM coding mistakes. Merge with project-specific instructions as needed.
Tradeoff: These guidelines bias toward caution over speed. For trivial tasks, use judgment.
- Think Before Coding Don't assume. Don't hide confusion. Surface tradeoffs.
Before implementing:
State your assumptions explicitly. If uncertain, ask. If multiple interpretations exist, present them - don't pick silently. If a simpler approach exists, say so. Push back when warranted. If something is unclear, stop. Name what's confusing. Ask.
- Simplicity First Minimum code that solves the problem. Nothing speculative.
No features beyond what was asked. No abstractions for single-use code. No "flexibility" or "configurability" that wasn't requested. No error handling for impossible scenarios. If you write 200 lines and it could be 50, rewrite it. Ask yourself: "Would a senior engineer say this is overcomplicated?" If yes, simplify.
- Surgical Changes Touch only what you must. Clean up only your own mess.
When editing existing code:
Don't "improve" adjacent code, comments, or formatting. Don't refactor things that aren't broken. Match existing style, even if you'd do it differently. If you notice unrelated dead code, mention it - don't delete it. When your changes create orphans:
Remove imports/variables/functions that YOUR changes made unused. Don't remove pre-existing dead code unless asked. The test: Every changed line should trace directly to the user's request.
- Goal-Driven Execution Define success criteria. Loop until verified.
Transform tasks into verifiable goals:
"Add validation" → "Write tests for invalid inputs, then make them pass" "Fix the bug" → "Write a test that reproduces it, then make it pass" "Refactor X" → "Ensure tests pass before and after" For multi-step tasks, state a brief plan:
- [Step] → verify: [check]
- [Step] → verify: [check]
- [Step] → verify: [check] Strong success criteria let you loop independently. Weak criteria ("make it work") require constant clarification.
These guidelines are working if: fewer unnecessary changes in diffs, fewer rewrites due to overcomplication, and clarifying questions come before implementation rather than after mistakes.
Project Overview
CrawlForge MCP Server - A professional MCP (Model Context Protocol) server providing 31 web scraping, crawling, and content processing tools (6 inline + 25 advanced).
Current Version: 5.6.6
Development Commands
# Install dependencies
npm install
# Setup (required for first run - users only)
npm run setup
# Or provide API key via environment:
export CRAWLFORGE_API_KEY="your_api_key_here"
# Run the server (production)
npm start
# HTTP transport mode
npm run start:http
# Development mode with verbose logging
npm run dev
# Test MCP protocol compliance
npm test
# Unit tests (400+ tests across tests/unit/, no live network)
npm run test:unit
# Phase D regressions live in tests/unit/phaseD-regressions.test.js (agent hard stops, unified scrape, map_site ranking)
# Run a single test file: node --test tests/unit/phaseD-regressions.test.js
# Note: the script includes --test-force-exit — importing StealthBrowserManager
# (d2-reliability.test.js) leaves a Playwright handle that otherwise hangs the
# runner at exit after all tests pass. When running a single file manually, put
# --test-force-exit BEFORE the file path (after it, the flag is silently ignored).
# Integration tests
npm run test:integration
# Functional tests
node test-tools.js # Test all tools
node test-real-world.js # Test real-world usage scenarios
# MCP Protocol tests
node tests/integration/mcp-protocol-compliance.test.js
# CLI (v4.1.0+, requires global install or npx)
crawlforge --help # Show all subcommands
crawlforge init # API-key detection + skill install + idempotent MCP-stanza merge (v4.6.0)
crawlforge init --all --yes # Merge MCP config into Claude Code / Desktop / Cursor non-interactively
crawlforge scrape https://example.com
crawlforge batch --urls urls.txt --format markdown
crawlforge install-skills --target claude-code
# See docs/cli-guide.md for full reference
# Docker
npm run docker:build # Build Docker image
npm run docker:dev # Run development container
npm run docker:prod # Run production containerDebugging Tips
- All diagnostic output (Winston logs + status banners) goes to stderr; stdout is reserved for the MCP JSON-RPC stream and CLI
--jsonoutput (enforced in v4.2.4) - Set
NODE_ENV=developmentfor verbose logging - Use
--expose-gcflag for memory profiling:node --expose-gc server.js - Check
cache/directory for cached responses - Review
logs/directory for application logs - Memory monitoring auto-enabled in development mode (logs every 60s if >200MB)
High-Level Architecture
Core Infrastructure (src/core/)
- AuthManager: Authentication, credit tracking, and usage reporting
- PerformanceManager: Centralized performance monitoring and optimization
- JobManager: Asynchronous job tracking and management for batch operations
- WebhookDispatcher: Event notification system for job completion callbacks
- ActionExecutor: Browser automation engine (Playwright-based)
- ResearchOrchestrator: Multi-stage research with query expansion and synthesis
- AgentOrchestrator: Powers the
agenttool — NL prompt → autonomous PLAN→GATHER→ACT→DECIDE→SHAPE loop with three orchestrator-enforced hard stops (maxSteps≤10, maxUrls≤20, wall-clock) never delegated to the LLM; degraded no-LLM-key path (D2, v4.6.0) - StealthBrowserManager: Stealth mode scraping with anti-detection; Camoufox (Firefox) engine added in v4.0.0. Engine selection goes through the one resolver
resolveStealthEngine(requested)→{engine, fallbackWarning};'auto'(the default forscrape.escalate_engineandstealth_mode.enginesince the 2026-09 stealth review Phase 2) prefers Camoufox and falls back to Chromium with a caller-visible warning when its binary is absent.'playwright'is the tool layer's public name for Chromium. Camoufox personas are pinned to the installed binary's Firefox major so the UA'srv:andFirefox/tokens agree — seedocs/STEALTH_REVIEW_2026-09.md - LocalizationManager: Multi-language content and localization
- ChangeTracker: Content change tracking over time
- SnapshotManager: Website snapshots and version history
- ResourceRegistry: MCP Resources (crawlforge:// URI scheme, 5 resource types) — D1.1, v3.6.0
- PromptRegistry (
src/prompts/): 5 workflow prompts — D1.2, v3.6.0 - SamplingClient: MCP Sampling with Ollama-API fallback chain — D1.3, v3.6.0
- ElicitationHelper: MCP Elicitation for user confirmation on expensive operations — D1.4, v3.6.0
- endpointGuard: Allow-list guard for server's own backend calls — v3.0.18
Tool Layer (src/tools/)
Tools are organized in subdirectories by category:
advanced/- BatchScrapeTool, ScrapeWithActionsTool, BrowserSessionToolagent/- agent (AgentOrchestrator-driven autonomous tool, v4.6.0)basic/- fetchUrl, extractText, extractLinks, extractMetadata, scrapeStructuredscrape/- unifiedScrape (single-fetch multi-formatscrapetool, v4.6.0)crawl/- crawlDeep, mapSiteextract/- analyzeContent, extractContent, extractStructured, extractWithLlm, listOllamaModels, processDocument, summarizeContentresearch/- deepResearchresult/- readResult (read_result: search/slice/lines/json_path over a stored over-threshold result byresult_handle, v5.8.0)search/- searchWeb (proxied through CrawlForge.dev API), serpRank (real Google organic rank via DataForSEO; adapter insearch/adapters/dataforseoSearch.js), redditSearch (Reddit posts/comments/threads via Arctic Shift + PullPush community archives — reddit.com blocks scrapers)templates/- ScrapeTemplateTool (10 pre-built site templates, v4.0.0)tracking/- trackChangesllmstxt/- generateLLMsTxt
Available MCP Tools (31 total)
Basic Tools (server.js inline, 6): fetch_url, extract_text, extract_links, extract_metadata, extract_embedded_state, scrape_structured
Advanced Tools (25): search_web, serp_rank, reddit_search, crawl_deep, map_site, extract_content, process_document, summarize_content, analyze_content, extract_structured, extract_with_llm, list_ollama_models, batch_scrape, get_batch_results, scrape_with_actions, deep_research, track_changes, generate_llms_txt, stealth_mode, localization, scrape_template, scrape, agent, read_result, browser_session
serp_rank (DataForSEO):
serp_rank— reports where a target domain ranks in Google's REAL organic results for a keyword (the SERP position Google Custom Search /search_webcannot give). Backed by the DataForSEO Google Organic SERP API (Live Advanced,POST /v3/serp/google/organic/live/advanced, HTTP Basic auth). Credentials viaDATAFORSEO_LOGIN/DATAFORSEO_PASSWORD, billed to the user's own DataForSEO account (~US$0.002 per 10 results ofdepth, so $0.004 at the defaultdepth:20and $0.02 atdepth:100), separate from CrawlForge credits. When unconfigured it returns{ configured:false }and charges 0 credits; when configured, Cost: 5. Never fabricates a rank.
reddit_search (community archives, v5.1.0):
reddit_search— searches Reddit posts/comments or reads a full comment thread. reddit.com 403-blocks ALL direct access (fetch, browser-UA, stealth — IP/TLS-reputation based), so this never touches reddit.com; it queries the Arctic Shift archive (arctic-shift.photon-reddit.com, near-real-time, comment trees) and PullPush (api.pullpush.io, Pushshift-compatible). Routing: Arctic Shift's keyword search REQUIRES a subreddit/author scope (verified live: HTTP 400 without one), so a scoped search queries it directly, while an unscoped keyword search for posts discovers them with a site-restricted web search and then reads those posts from the archive by ID (source:"web_discovery"). PullPush stopped serving automated clients in August 2026 (429 "does not provide free scraping resources for agents" on every UA; Cloudflare 403 from some IPs) and is no longer tried automatically anywhere —source:"pullpush"still reaches it. An unscoped COMMENT search has no backend and returns a scope-required error. Modes:posts(default),comments,thread(post + nested comment tree bylink_id). Free, no Reddit credentials. Cost: 5 — a Reddit-wide search spends the same web searchsearch_webdoes.REDDIT_SEARCH_TIMEOUT_MSoverrides the 30s default.
v4.6.0 additions (Phase D):
scrape— single fetch + one cheerio load dispatching aformatsarray (markdown/html/rawHtml/text/links/metadata/screenshot/json-schema) +onlyMainContent; partial-success via per-formatwarnings[]. Cost: 2.agent— NL prompt → autonomous research/extract, no URLs required (see AgentOrchestrator above). Cost: 8.map_sitegained an optionalsearch=param that ranks discovered URLs (ranked_urls:[{url,score}]); default output unchanged.
MCP Server Entry Point
The main server implementation is in server.js which:
- Secure Creator Mode: Loads
.envearly, validates secret via SHA256 hash comparison - Authentication Flow: AuthManager for API key validation and credit tracking
- Tool Registration: All tools registered via
server.registerTool(), wrapped withwithAuth()for credit tracking - Transport: stdio transport for MCP protocol communication
- Graceful Shutdown: Cleans up browser instances, job managers, and other resources
Tool Credit System
Each tool wrapped with withAuth(toolName, handler):
- Checks credits before execution (skipped in creator mode)
- Reports usage with credit deduction on success
- Charges half credits on error
- Creator mode: Unlimited access for package maintainer
Key Configuration
Critical environment variables defined in src/constants/config.js:
CRAWLFORGE_API_KEY=your_api_key_here
MAX_WORKERS=10
QUEUE_CONCURRENCY=10
CACHE_TTL=3600000
RATE_LIMIT_REQUESTS_PER_SECOND=10
MAX_CRAWL_DEPTH=5
MAX_PAGES_PER_CRAWL=100
RESPECT_ROBOTS_TXT=true
ROBOTS_CACHE_TTL_MS=3600000 # how long a parsed robots.txt stays good for
CRAWLFORGE_BLOCKED_HOSTS= # comma-separated; extends the permanent opt-out blocklist
CRAWLFORGE_STEALTH_ENGINE= # which engine `auto` resolves to on THIS deployment:
# chromium|playwright pins it to Chromium; unset or anything
# else keeps the default preference for Camoufox. A caller
# naming an engine always wins. There is no correct global
# value — which engine clears a wall depends on the exit IP
# (residential favours Camoufox, the hosted datacenter IP
# favours Chromium, measured twice).
CRAWLFORGE_STEALTH_PROXIES= # comma-separated proxy URLs used by the escalation stage,
# stealth_mode, browser_session, scrape_with_actions and the
# deep_research fallback when the caller passes none (a proxy
# passed on the call wins). CrawlForge supplies no proxies, and
# a datacenter one does not defeat these detectors. Distinct
# from the PROXY_ROTATION_* family, which belongs to
# localization. The agent's automatic stealth retry
# (stealth review Phase 3) reads it too.
CRAWLFORGE_IMPIT= # `off` skips escalation's impit step (a Chrome TLS handshake with
# the honest UA, tried before the browser; stealth review Phase 7).
# Exit-IP dependent like the engine: it cleared indeed.com from a
# residential IP and nothing from the hosted datacenter IP, so
# render.yaml sets it off there. Measure with scripts/impit-probe.mjs.
CRAWLFORGE_CLEARANCE_JAR= # `off` disables the clearance jar (stealth review Phase 4):
# cf_clearance/__cf_bm/datadome cookies a stealth render earned
# are replayed to the next stealth context with the same engine,
# UA and proxy. Persisted at ~/.crawlforge/stealth-clearance.json.Camoufox is an optional dependency and its transitive language-tags@2.1.0 requires Node ≥22. npm silently drops an optional subtree that fails an engine check, so on Node 20 it is simply absent — 'auto' then resolves to Chromium and says so in fallbackWarning. engines.node stays at >=20.16.0 deliberately; bumping it is breaking and is a release decision.
Web Bot Auth (optional, off by default — requests go out unsigned when unset):
CRAWLFORGE_SIGNING_KEY= # Ed25519 PKCS#8 PEM, or base64 of it. SECRET — never commit.
WEB_BOT_AUTH_DIRECTORY= # https://www.crawlforge.dev — advertised in Signature-AgentGenerate the pair with node scripts/generate-signing-key.mjs; publish the public half
before setting the private one. Procedure and compromise response: docs/policy/KEY_ROTATION.md.
OPENAI_API_KEY / ANTHROPIC_API_KEY are optional. They only affect deep_research: when set, it produces a fully synthesized report internally; when unset, it returns raw evidence for the calling LLM (e.g. Claude Code) to synthesize.
Configuration Files
~/.crawlforge/config.json- User authentication and API key storage.env- Environment variables for developmentsrc/constants/config.js- Central configuration with defaults and validation
Adding New Tools
When adding a new tool to server.js:
- Import the tool class from
src/tools/ - Instantiate the tool (with config if needed)
- Register with
server.registerTool(name, { description, inputSchema }, withAuth(name, handler)) - Ensure tool implements
execute(params)method - Add to cleanup array in gracefulShutdown if it has
destroy()orcleanup()methods - Update tool count in console log at server startup
Sandboxing & Approvals
Key mechanisms for security-conscious future sessions:
- SSRF (
src/utils/ssrfGuard.jsenforcingsrc/utils/ssrfProtection.js): As of v4.8.0 SSRF is actually enforced on the live scraping fetch path (previouslyssrfProtection.jswas unwired).ssrfGuardinjects an undici dispatcher whose connect-timelookupvalidates every connection — initial request and each redirect hop — and pins the validated IP (closing the DNS-rebinding TOCTOU window). Stage 1 (default) blocks loopback, link-local/cloud-metadata (169.254.169.254), and 0.0.0.0;SSRF_STRICT=trueadds full RFC1918/ULA/etc. enforcement. Kill switchSSRF_PROTECTION_ENABLED=false;ALLOWED_DOMAINSallowlist bypass. Wired into every read-scrape site (_fetch.js,_fetchAndParse.js,batchScrape/worker.js,mapSite.js,BFSCrawler.js, extract/template/session/research/llms-txt/robots/sitemap/track-changes fetches) viassrfGuard()/safeFetch(). http/https only; dangerous ports + path-traversal still rejected byssrfProtection.js. - endpointGuard (
src/core/endpointGuard.js): Hard allow-list of{crawlforge.dev, www.crawlforge.dev, api.crawlforge.dev}for the server's own backend calls; HTTPS required; fail-closed. Localhost only in creator mode (v3.0.18). - Action allowlist (
src/core/ActionExecutor.js):scrape_with_actionsaccepts only 7 action types:wait,click,type,press,scroll,screenshot,executeJavaScript.executeJavaScriptthrows unlessALLOW_JAVASCRIPT_EXECUTION=trueis set at deploy time (off by default). - Elicitation (
src/core/ElicitationHelper.js): User confirmation requested fordeep_research(>50 URLs),batch_scrape(sync, >25 URLs),crawl_deep(projected >500 pages),extract_structured(schema has >3 required fields, no LLM configured), and credit-low situations. Fail-open if client does not support elicitation. - Browser sandboxing: Standard pool retains OS sandbox. Stealth Chromium uses
--no-sandbox(deliberate fingerprint-spoofing trade-off);--disable-web-securitywas removed from it in Phase 1 of the 2026-09 stealth review — a page reads it in one line — but the non-stealth render browser (BrowserProcessor) still carries both flags. Camoufox (Firefox, v4.0.0) is the alternative — seedocs/stealth-engines.md.
See docs/sandboxing-and-approvals.md for the full reference.
Security
Security testing and CI/CD pipeline details are in:
docs/sandboxing-and-approvals.md— Canonical sandboxing & approvals referencedocs/security-audit-report.md— Full security audit.github/workflows/ci.yml— CI pipeline with security checks.github/workflows/security.yml— Daily scheduled security scanningdocs/SECURITY.md— Security policy and procedures
Run npm audit locally to check dependencies.
Implementation Patterns
Tool Structure
export class ToolName {
constructor(config) { this.config = config; }
async execute(params) {
return { success: true, data: {...} };
}
async destroy() { /* cleanup resources */ }
}Error Handling Pattern
try {
const result = await tool.execute(params);
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
} catch (error) {
return {
content: [{ type: "text", text: `Operation failed: ${error.message}` }],
isError: true,
};
}Project Management Rules
- Delegate to a sub agent only for a genuinely independent, parallelizable track — not for work finishable in a few tool calls, and never to verify your own output (Claude 5 models over-delegate when told to parallelize)
- When a phase completes, update
docs/PRODUCTION_READINESS.md - Whenever a phase is completed, push all changes to GitHub
- Put all documentation md files into the
docs/folder - Every time you finish a phase run the test suites (
npm run test:unitandnpm test) and fix all failures before pushing
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

