MCP Server for Crawl4AI
Provides integration with Crawl4AI server which can be run as a Docker container for easy deployment.
Supports Firefox as one of the browser engines for web crawling and content extraction tasks.
Executes custom JavaScript code on web pages and returns the results, enabling advanced web scraping capabilities.
Extracts web content as markdown with various filtering options including raw, fit, bm25, and LLM-based filtering.
Runs on Node.js 18+ to provide web crawling and browser automation capabilities.
Integrates with OpenAI models for LLM-based content extraction and structured data generation.
Auto-detects and processes RSS feeds as part of the smart_crawl functionality.
Supports creation and management of persistent browser sessions to maintain state across multiple requests.
Handles SVG content during web crawling and includes it in extraction results when appropriate.
Parses XML sitemaps to extract URLs with support for regex filtering of specific URL patterns.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MCP Server for Crawl4AI get the main content from https://news.ycombinator.com as markdown"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MCP Server for Crawl4AI
Note: Tested with Crawl4AI version 0.7.4
TypeScript implementation of an MCP server for Crawl4AI. Provides tools for web crawling, content extraction, and browser automation.
Table of Contents
Related MCP server: mult-fetch-mcp-server
Prerequisites
Node.js 18+ and npm
A running Crawl4AI server
Quick Start
1. Start the Crawl4AI server (for example, local docker)
docker run -d -p 11235:11235 --name crawl4ai --shm-size=1g unclecode/crawl4ai:0.7.42. Add to your MCP client
This MCP server works with any MCP-compatible client (Claude Desktop, Claude Code, Cursor, LMStudio, etc.).
Using npx (Recommended)
{
"mcpServers": {
"crawl4ai": {
"command": "npx",
"args": ["mcp-crawl4ai-ts"],
"env": {
"CRAWL4AI_BASE_URL": "http://localhost:11235"
}
}
}
}Using local installation
{
"mcpServers": {
"crawl4ai": {
"command": "node",
"args": ["/path/to/mcp-crawl4ai-ts/dist/index.js"],
"env": {
"CRAWL4AI_BASE_URL": "http://localhost:11235"
}
}
}
}With all optional variables
{
"mcpServers": {
"crawl4ai": {
"command": "npx",
"args": ["mcp-crawl4ai-ts"],
"env": {
"CRAWL4AI_BASE_URL": "http://localhost:11235",
"CRAWL4AI_API_KEY": "your-api-key",
"SERVER_NAME": "custom-name",
"SERVER_VERSION": "1.0.0"
}
}
}
}Configuration
Environment Variables
# Required
CRAWL4AI_BASE_URL=http://localhost:11235
# Optional - Server Configuration
CRAWL4AI_API_KEY= # If your server requires auth
SERVER_NAME=crawl4ai-mcp # Custom name for the MCP server
SERVER_VERSION=1.0.0 # Custom versionClient-Specific Instructions
Claude Desktop
Add to ~/Library/Application Support/Claude/claude_desktop_config.json
Claude Code
claude mcp add crawl4ai -e CRAWL4AI_BASE_URL=http://localhost:11235 -- npx mcp-crawl4ai-tsOther MCP Clients
Consult your client's documentation for MCP server configuration. The key details:
Command:
npx mcp-crawl4ai-tsornode /path/to/dist/index.jsRequired env:
CRAWL4AI_BASE_URLOptional env:
CRAWL4AI_API_KEY,SERVER_NAME,SERVER_VERSION
Available Tools
1. get_markdown - Extract content as markdown with filtering
{
url: string, // Required: URL to extract markdown from
filter?: 'raw'|'fit'|'bm25'|'llm', // Filter type (default: 'fit')
query?: string, // Query for bm25/llm filters
cache?: string // Cache-bust parameter (default: '0')
}Extracts content as markdown with various filtering options. Use 'bm25' or 'llm' filters with a query for specific content extraction.
2. capture_screenshot - Capture webpage screenshot
{
url: string, // Required: URL to capture
screenshot_wait_for?: number // Seconds to wait before screenshot (default: 2)
}Returns base64-encoded PNG. Note: This is stateless - for screenshots after JS execution, use crawl with screenshot: true.
3. generate_pdf - Convert webpage to PDF
{
url: string // Required: URL to convert to PDF
}Returns base64-encoded PDF. Stateless tool - for PDFs after JS execution, use crawl with pdf: true.
4. execute_js - Execute JavaScript and get return values
{
url: string, // Required: URL to load
scripts: string | string[] // Required: JavaScript to execute
}Executes JavaScript and returns results. Each script can use 'return' to get values back. Stateless - for persistent JS execution use crawl with js_code.
5. batch_crawl - Crawl multiple URLs concurrently
{
urls: string[], // Required: List of URLs to crawl
max_concurrent?: number, // Parallel request limit (default: 5)
remove_images?: boolean, // Remove images from output (default: false)
bypass_cache?: boolean, // Bypass cache for all URLs (default: false)
configs?: Array<{ // Optional: Per-URL configurations (v3.0.0+)
url: string,
[key: string]: any // Any crawl parameters for this specific URL
}>
}Efficiently crawls multiple URLs in parallel. Each URL gets a fresh browser instance. With configs array, you can specify different parameters for each URL.
6. smart_crawl - Auto-detect and handle different content types
{
url: string, // Required: URL to crawl
max_depth?: number, // Maximum depth for recursive crawling (default: 2)
follow_links?: boolean, // Follow links in content (default: true)
bypass_cache?: boolean // Bypass cache (default: false)
}Intelligently detects content type (HTML/sitemap/RSS) and processes accordingly.
7. get_html - Get sanitized HTML for analysis
{
url: string // Required: URL to extract HTML from
}Returns preprocessed HTML optimized for structure analysis. Use for building schemas or analyzing patterns.
8. extract_links - Extract and categorize page links
{
url: string, // Required: URL to extract links from
categorize?: boolean // Group by type (default: true)
}Extracts all links and groups them by type: internal, external, social media, documents, images.
9. crawl_recursive - Deep crawl website following links
{
url: string, // Required: Starting URL
max_depth?: number, // Maximum depth to crawl (default: 3)
max_pages?: number, // Maximum pages to crawl (default: 50)
include_pattern?: string, // Regex pattern for URLs to include
exclude_pattern?: string // Regex pattern for URLs to exclude
}Crawls a website following internal links up to specified depth. Returns content from all discovered pages.
10. parse_sitemap - Extract URLs from XML sitemaps
{
url: string, // Required: Sitemap URL (e.g., /sitemap.xml)
filter_pattern?: string // Optional: Regex pattern to filter URLs
}Extracts all URLs from XML sitemaps. Supports regex filtering for specific URL patterns.
11. crawl - Advanced web crawling with full configuration
{
url: string, // URL to crawl
// Browser Configuration
browser_type?: 'chromium'|'firefox'|'webkit'|'undetected', // Browser engine (undetected = stealth mode)
viewport_width?: number, // Browser width (default: 1080)
viewport_height?: number, // Browser height (default: 600)
user_agent?: string, // Custom user agent
proxy_server?: string | { // Proxy URL (string or object format)
server: string,
username?: string,
password?: string
},
proxy_username?: string, // Proxy auth (if using string format)
proxy_password?: string, // Proxy password (if using string format)
cookies?: Array<{name, value, domain}>, // Pre-set cookies
headers?: Record<string,string>, // Custom headers
// Crawler Configuration
word_count_threshold?: number, // Min words per block (default: 200)
excluded_tags?: string[], // HTML tags to exclude
remove_overlay_elements?: boolean, // Remove popups/modals
js_code?: string | string[], // JavaScript to execute
wait_for?: string, // Wait condition (selector or JS)
wait_for_timeout?: number, // Wait timeout (default: 30000)
delay_before_scroll?: number, // Pre-scroll delay
scroll_delay?: number, // Between-scroll delay
process_iframes?: boolean, // Include iframe content
exclude_external_links?: boolean, // Remove external links
screenshot?: boolean, // Capture screenshot
pdf?: boolean, // Generate PDF
session_id?: string, // Reuse browser session (only works with crawl tool)
cache_mode?: 'ENABLED'|'BYPASS'|'DISABLED', // Cache control
// New in v3.0.0 (Crawl4AI 0.7.3/0.7.4)
css_selector?: string, // CSS selector to filter content
delay_before_return_html?: number, // Delay in seconds before returning HTML
include_links?: boolean, // Include extracted links in response
resolve_absolute_urls?: boolean, // Convert relative URLs to absolute
// LLM Extraction (REST API only supports 'llm' type)
extraction_type?: 'llm', // Only 'llm' extraction is supported via REST API
extraction_schema?: object, // Schema for structured extraction
extraction_instruction?: string, // Natural language extraction prompt
extraction_strategy?: { // Advanced extraction configuration
provider?: string,
api_key?: string,
model?: string,
[key: string]: any
},
table_extraction_strategy?: { // Table extraction configuration
enable_chunking?: boolean,
thresholds?: object,
[key: string]: any
},
markdown_generator_options?: { // Markdown generation options
include_links?: boolean,
preserve_formatting?: boolean,
[key: string]: any
},
timeout?: number, // Overall timeout (default: 60000)
verbose?: boolean // Detailed logging
}12. manage_session - Unified session management
{
action: 'create' | 'clear' | 'list', // Required: Action to perform
session_id?: string, // For 'create' and 'clear' actions
initial_url?: string, // For 'create' action: URL to load
browser_type?: 'chromium' | 'firefox' | 'webkit' | 'undetected' // For 'create' action
}Unified tool for managing browser sessions. Supports three actions:
create: Start a persistent browser session
clear: Remove a session from local tracking
list: Show all active sessions
Examples:
// Create a new session
{ action: 'create', session_id: 'my-session', initial_url: 'https://example.com' }
// Clear a session
{ action: 'clear', session_id: 'my-session' }
// List all sessions
{ action: 'list' }13. extract_with_llm - Extract structured data using AI
{
url: string, // URL to extract data from
query: string // Natural language extraction instructions
}Uses AI to extract structured data from webpages. Returns results immediately without any polling or job management. This is the recommended way to extract specific information since CSS/XPath extraction is not supported via the REST API.
Advanced Configuration
For detailed information about all available configuration options, extraction strategies, and advanced features, please refer to the official Crawl4AI documentation:
Changelog
See CHANGELOG.md for detailed version history and recent updates.
Development
Setup
# 1. Start the Crawl4AI server
docker run -d -p 11235:11235 --name crawl4ai --shm-size=1g unclecode/crawl4ai:latest
# 2. Install MCP server
git clone https://github.com/omgwtfwow/mcp-crawl4ai-ts.git
cd mcp-crawl4ai-ts
npm install
cp .env.example .env
# 3. Development commands
npm run dev # Development mode
npm test # Run tests
npm run lint # Check code quality
npm run build # Production build
# 4. Add to your MCP client (See "Using local installation")Running Integration Tests
Integration tests require a running Crawl4AI server. Configure your environment:
# Required for integration tests
export CRAWL4AI_BASE_URL=http://localhost:11235
export CRAWL4AI_API_KEY=your-api-key # If authentication is required
# Optional: For LLM extraction tests
export LLM_PROVIDER=openai/gpt-4o-mini
export LLM_API_TOKEN=your-llm-api-key
export LLM_BASE_URL=https://api.openai.com/v1 # If using custom endpoint
# Run integration tests (ALWAYS use the npm script; don't call `jest` directly)
npm run test:integration
# Run a single integration test file
npm run test:integration -- src/__tests__/integration/extract-links.integration.test.ts
> IMPORTANT: Do NOT run `npx jest` directly for integration tests. The npm script injects `NODE_OPTIONS=--experimental-vm-modules` which is required for ESM + ts-jest. Running Jest directly will produce `SyntaxError: Cannot use import statement outside a module` and hang.Integration tests cover:
Dynamic content and JavaScript execution
Session management and cookies
Content extraction (LLM-based only)
Media handling (screenshots, PDFs)
Performance and caching
Content filtering
Bot detection avoidance
Error handling
Integration Test Checklist
Docker container healthy:
docker ps --filter name=crawl4ai --format '{{.Names}} {{.Status}}'
curl -sf http://localhost:11235/health || echo "Health check failed"Env vars loaded (either exported or in
.env):CRAWL4AI_BASE_URL(required), optional:CRAWL4AI_API_KEY,LLM_PROVIDER,LLM_API_TOKEN,LLM_BASE_URL.Use
npm run test:integration(never rawjest).To target one file add it after
--(see example above).Expect total runtime ~2–3 minutes; longer or immediate hang usually means missing
NODE_OPTIONSor wrong Jest version.
Troubleshooting
Symptom | Likely Cause | Fix |
| Ran | Re-run with |
Hangs on first test (RUNS ...) | Missing experimental VM modules flag | Use npm script / ensure |
Network timeouts | Crawl4AI container not healthy / DNS blocked | Restart container: |
LLM tests skipped | Missing | Export required LLM vars |
New Jest major upgrade breaks tests | Version mismatch with | Keep Jest 29.x unless |
Version Compatibility Note
Current stack: jest@29.x + ts-jest@29.x + ESM ("type": "module"). Updating Jest to 30+ requires upgrading ts-jest and revisiting jest.config.cjs. Keep versions aligned to avoid parse errors.
License
MIT
Available Tools
13 toolsbatch_crawlA
[STATELESS] Crawl multiple URLs concurrently for efficiency. Use when: processing URL lists, comparing multiple pages, or bulk data extraction. Faster than sequential crawling. Max 5 concurrent by default. Each URL gets a fresh browser. Cannot maintain state between URLs. For persistent operations use create_session + crawl.
Inputs: urls (required), max_concurrent, remove_images, bypass_cache.
capture_screenshotA
[STATELESS] Capture webpage screenshot. Returns base64-encoded PNG data. Creates new browser each time. Optionally saves screenshot to local directory. IMPORTANT: Chained calls (execute_js then capture_screenshot) will NOT work - the screenshot won't see JS changes! For JS changes + screenshot use create_session + crawl(session_id, js_code, screenshot:true) in ONE call.
Inputs: url (required), screenshot_wait_for, save_to_directory.
crawlA
[SUPPORTS SESSIONS] THE ONLY TOOL WITH BROWSER PERSISTENCE
RECOMMENDED PATTERNS: • Inspect first workflow:
get_html(url) → find selectors & verify elements exist
create_session() → "session-123"
crawl({url, session_id: "session-123", js_code: ["action 1"]})
crawl({url: "/page2", session_id: "session-123", js_code: ["action 2"]})
• Multi-step with state:
create_session() → "session-123"
crawl({url, session_id: "session-123"}) → inspect current state
crawl({url, session_id: "session-123", js_code: ["verified actions"]})
WITH session_id: Maintains browser state (cookies, localStorage, page) across calls WITHOUT session_id: Creates fresh browser each time (like other tools)
WHEN TO USE SESSIONS vs STATELESS: • Need state between calls? → create_session + crawl • Just extracting data? → Use stateless tools • Filling forms? → Inspect first, then use sessions • Taking screenshot after JS? → Must use crawl with session • Unsure if elements exist? → Always use get_html first
CRITICAL FOR js_code: RECOMMENDED: Always use screenshot: true when running js_code This avoids server serialization errors and gives visual confirmation
Inputs: url (required), session_id, browser_type, viewport_width, +44 more.
crawl_recursiveA
[STATELESS] Deep crawl a website following internal links. Use when: mapping entire sites, finding all pages, building comprehensive indexes. Control with max_depth (default 3) and max_pages (default 50). Note: May need JS execution for dynamic sites. Each page gets a fresh browser. For persistent operations use create_session + crawl.
Inputs: url (required), max_depth, max_pages, include_pattern, +1 more.
execute_jsA
[STATELESS] Execute JavaScript and get return values + page content. Creates new browser each time. Use for: extracting data, triggering dynamic content, checking page state. Scripts with "return" statements return actual values (strings, numbers, objects, arrays). Note: null returns as {"success": true}. Returns values but page state is lost. For persistent JS execution, use crawl with session_id.
Inputs: url (required), scripts (required).
extract_linksA
[STATELESS] Extract and categorize all page links. Use when: building sitemaps, analyzing site structure, finding broken links, or discovering resources. Groups by internal/external/social/documents. Creates new browser each time. For persistent operations use create_session + crawl.
Inputs: url (required), categorize.
extract_with_llmA
[STATELESS] Ask questions about webpage content using AI. Returns natural language answers. Crawls fresh each time. For dynamic content or sessions, use crawl with session_id first.
Inputs: url (required), query (required).
generate_pdfA
[STATELESS] Convert webpage to PDF. Returns base64-encoded PDF data. Creates new browser each time. Cannot capture form fills or JS changes. For persistent PDFs use create_session + crawl(session_id, pdf:true).
Inputs: url (required).
get_htmlA
[STATELESS] Get sanitized/processed HTML for inspection and automation planning. Use when: finding form fields/selectors, analyzing page structure before automation, building schemas. Returns cleaned HTML showing element names, IDs, and classes - perfect for identifying selectors for subsequent crawl operations. Commonly used before crawl to find selectors for automation. Creates new browser each time.
Inputs: url (required).
get_markdownA
[STATELESS] Extract content as markdown with filtering options. Supports: raw (full content), fit (optimized, default), bm25 (keyword search), llm (AI-powered extraction). Use bm25/llm with query for specific content. Creates new browser each time. For persistence use create_session + crawl.
Inputs: url (required), filter, query, cache.
manage_sessionA
[SESSION MANAGEMENT] Unified tool for managing browser sessions. Supports three actions:
• CREATE: Start a persistent browser session that maintains state across calls • CLEAR: Remove a session from local tracking • LIST: Show all active sessions with age and usage info
USAGE EXAMPLES:
Create session: {action: "create", session_id: "my-session", initial_url: "https://example.com"}
Clear session: {action: "clear", session_id: "my-session"}
List sessions: {action: "list"}
Browser sessions maintain ALL state (cookies, localStorage, page) across multiple crawl calls. Essential for: forms, login flows, multi-step processes, maintaining state across operations.
Inputs: action (required), session_id, initial_url, browser_type.
parse_sitemapA
[STATELESS] Extract URLs from XML sitemaps. Use when: discovering all site pages, planning crawl strategies, or checking sitemap validity. Supports regex filtering. Try sitemap.xml or robots.txt first. Creates new browser each time.
Inputs: url (required), filter_pattern.
smart_crawlA
[STATELESS] Auto-detect and handle different content types (HTML, sitemap, RSS, text). Use when: URL type is unknown, crawling feeds/sitemaps, or want automatic format handling. Adapts strategy based on content. Creates new browser each time. For persistent operations use create_session + crawl.
Inputs: url (required), max_depth, follow_links, bypass_cache.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 13 tools
There is significant overlap between tools, particularly between crawl, batch_crawl, crawl_recursive, and smart_crawl, which all handle URL crawling with different scopes or features. However, descriptions help clarify distinctions, such as crawl supporting sessions while others are stateless, and tools like extract_links or parse_sitemap have more unique purposes.
Most tools follow a consistent snake_case pattern with descriptive names (e.g., batch_crawl, capture_screenshot, extract_links), but manage_session uses a different structure with action parameters, and there are minor deviations like extract_with_llm using 'llm' instead of a full word. Overall, naming is mostly predictable and readable.
With 13 tools, the count is well-scoped for a web crawling and automation server, covering various aspects like data extraction, session management, and format handling. Each tool appears to serve a distinct function within the domain, avoiding bloat while providing comprehensive coverage.
The tool set provides complete coverage for web crawling and automation, including session management (create_session via manage_session), data extraction (get_html, get_markdown, extract_with_llm), crawling variants (batch, recursive, smart), and additional utilities like screenshot and PDF generation. No obvious gaps are present for the intended domain.
Maintenance
Related MCP Connectors
Web scraping, browser automation, screenshots and AI data extraction for AI agents via MCP.
Hosted Web Crawler MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
Official Browserless MCP server: browser automation, scraping, screenshots and PDFs for AI agents.
Web scraping, extraction and search for AI agents. Hosted MCP with workspace API keys.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceA TypeScript server that provides web search and content fetching capabilities through Claude CLI integration, allowing Claude Desktop and other MCP clients to access real-time web information.1MIT
- AlicenseAqualityBmaintenanceAn MCP server that enables AI assistants to fetch web content in multiple formats (HTML, JSON, text, Markdown) with intelligent content extraction, chunk management, and browser automation support.6165 npm15MIT
- AlicenseNot gradedqualityDmaintenanceMCP server that bridges Model Context Protocol with browser automation, offering 37 tools across three modes (Playwright, CDP, Chrome Extension) and an autonomous agent for web tasks.MIT
- AlicenseAqualityDmaintenanceMCP server that provides read_page, screenshot, and pdf tools using a real browser, enabling agents to fetch clean markdown, screenshots, and PDFs from any URL.552 npmMIT