MCP server for Crawl4AI - Universal web crawling and data extraction for AI agents
4.5K
MCP (Model Context Protocol) server for Crawl4AI - Universal web crawling and data extraction for AI agents.
Integrate powerful web scraping capabilities into Claude, ChatGPT, and any MCP-compatible AI assistant.
β¨ Docker is the preferred way to run Crawl4AI MCP Server - everything is pre-installed and ready to go!
# SSE mode (for web interfaces) - DEFAULT
docker run --rm -p 3001:9001 \
-e CRAWL4AI_ENDPOINT="https://your-crawl4ai-server.com" \
-e CRAWL4AI_BEARER_TOKEN="your-optional-token" \
stgmt/crawl4ai-mcp:latest crawl4ai-mcp --sse
# HTTP mode (for REST API)
docker run --rm -p 3000:3000 \
-e CRAWL4AI_ENDPOINT="https://your-crawl4ai-server.com" \
-e CRAWL4AI_BEARER_TOKEN="your-optional-token" \
stgmt/crawl4ai-mcp:latest crawl4ai-mcp --http --port 3000
# STDIO mode (for Claude Desktop)
docker run --rm -it \
-e CRAWL4AI_ENDPOINT="https://your-crawl4ai-server.com" \
-e CRAWL4AI_BEARER_TOKEN="your-optional-token" \
stgmt/crawl4ai-mcp:latest crawl4ai-mcp --stdio
# Clone and build
git clone https://github.com/stgmt/crawl4ai-mcp.git
cd crawl4ai-mcp
docker build -t crawl4ai-mcp:local .
# Run SSE mode
docker run --rm -p 3001:9001 \
-e CRAWL4AI_ENDPOINT="https://your-crawl4ai-server.com" \
-e CRAWL4AI_BEARER_TOKEN="your-optional-token" \
crawl4ai-mcp:local crawl4ai-mcp --sse
Add to your claude_desktop_config.json:
{
"mcpServers": {
"crawl4ai": {
"command": "docker",
"args": [
"run", "--rm", "-i",
"-e", "CRAWL4AI_ENDPOINT=https://your-crawl4ai-server.com",
"-e", "CRAWL4AI_BEARER_TOKEN=your-optional-token",
"stgmt/crawl4ai-mcp:latest",
"crawl4ai-mcp", "--stdio"
]
}
}
}
# Install globally
npm install -g crawl4ai-mcp-sse-stdio
# Run in different modes (set CRAWL4AI_ENDPOINT first)
export CRAWL4AI_ENDPOINT="https://your-crawl4ai-server.com"
npx crawl4ai-mcp --stdio
npx crawl4ai-mcp --sse --port 3001
npx crawl4ai-mcp --http --port 3000
# Install from PyPI
pip install crawl4ai-mcp
<<<<<<< HEAD
# Set required endpoint and run
export CRAWL4AI_ENDPOINT="https://your-crawl4ai-server.com"
crawl4ai-mcp --stdio
=======
# Run with command line arguments (recommended)
crawl4ai-mcp --stdio --endpoint https://your-crawl4ai-server.com
crawl4ai-mcp --http --port 3000 --endpoint https://your-crawl4ai-server.com
crawl4ai-mcp --sse --port 3001 --endpoint https://your-crawl4ai-server.com
# With optional bearer token
crawl4ai-mcp --stdio --endpoint https://your-crawl4ai-server.com --bearer-token your-token
npm install -g crawl4ai-mcp-sse-stdio
# Run with command line arguments (recommended)
npx crawl4ai-mcp --stdio --endpoint https://your-crawl4ai-server.com
npx crawl4ai-mcp --http --port 3000 --endpoint https://your-crawl4ai-server.com
npx crawl4ai-mcp --sse --port 3001 --endpoint https://your-crawl4ai-server.com
# With optional bearer token
npx crawl4ai-mcp --stdio --endpoint https://your-crawl4ai-server.com --bearer-token your-token
git clone https://github.com/stgmt/crawl4ai-mcp.git
cd crawl4ai-mcp
pip install -e .
Add to your claude_desktop_config.json:
{
"mcpServers": {
"crawl4ai": {
"command": "crawl4ai-mcp",
"args": ["--stdio"],
"env": {
"CRAWL4AI_ENDPOINT": "https://your-crawl4ai-server.com",
"CRAWL4AI_BEARER_TOKEN": "your-optional-token"
}
}
}
}
crawl - Full Web CrawlingExtract complete content from any webpage.
{
"name": "crawl",
"arguments": {
"url": "https://example.com",
"wait_for": "css:.content",
"timeout": 30000
}
}
md - Markdown ExtractionGet clean markdown content from webpages.
{
"name": "md",
"arguments": {
"url": "https://docs.example.com",
"clean": true
}
}
html - Raw HTMLRetrieve raw HTML content.
{
"name": "html",
"arguments": {
"url": "https://example.com"
}
}
screenshot - Visual CaptureTake screenshots of webpages.
{
"name": "screenshot",
"arguments": {
"url": "https://example.com",
"full_page": true
}
}
pdf - PDF GenerationConvert webpages to PDF.
{
"name": "pdf",
"arguments": {
"url": "https://example.com",
"format": "A4"
}
}
execute_js - JavaScript ExecutionExecute JavaScript on webpages.
{
"name": "execute_js",
"arguments": {
"url": "https://example.com",
"script": "document.title"
}
}
The crawl4ai-mcp server supports multiple transport modes and provides comprehensive web crawling capabilities through the Model Context Protocol.
# HTTP mode (recommended for testing)
crawl4ai-mcp --http --port 3000 --endpoint https://your-crawl4ai-server.com
# SSE mode (Server-Sent Events)
crawl4ai-mcp --sse --port 3001 --endpoint https://your-crawl4ai-server.com
# STDIO mode (for MCP clients)
crawl4ai-mcp --stdio --endpoint https://your-crawl4ai-server.com
# With optional bearer token
crawl4ai-mcp --http --port 3000 --endpoint https://your-crawl4ai-server.com --bearer-token your-token
# Using custom Crawl4AI endpoint with bearer token
crawl4ai-mcp --http --port 3000 \
--crawl4ai-endpoint "https://your-server.com" \
--bearer-token "your-token"
See the Python Integrationβ section for detailed code examples.
# REQUIRED: Crawl4AI endpoint URL
export CRAWL4AI_ENDPOINT="https://your-crawl4ai-server.com"
# OPTIONAL: Bearer authentication token
export CRAWL4AI_BEARER_TOKEN="your-api-token"
Parameter Requirements:
CRAWL4AI_ENDPOINT - Required - The URL of your Crawl4AI server instanceCRAWL4AI_BEARER_TOKEN - Optional - Bearer token for authenticated API accesscrawl4ai-mcp --help
Options:
--stdio Run in STDIO mode for MCP clients
--sse Run in SSE mode for web interfaces (default)
--http Run in HTTP mode
--endpoint ENDPOINT Crawl4AI API endpoint URL (REQUIRED)
--bearer-token TOKEN Bearer authentication token (OPTIONAL)
--version, -v Show version
Here's how to integrate the MCP server with your Python application using HTTP mode with bearer token authentication:
import asyncio
import aiohttp
import json
async def test_crawl4ai_mcp():
"""
Example: Using Crawl4AI MCP server via HTTP with bearer token
"""
# Server configuration
server_url = "http://localhost:3000"
bearer_token = "your-api-token" # Optional
headers = {
"Content-Type": "application/json"
}
# Add bearer token if available
if bearer_token:
headers["Authorization"] = f"Bearer {bearer_token}"
async with aiohttp.ClientSession() as session:
# 1. List available tools
async with session.post(
f"{server_url}/tools/list",
headers=headers
) as response:
tools = await response.json()
print("Available tools:", [tool['name'] for tool in tools['tools']])
# 2. Extract markdown from a webpage
tool_request = {
"name": "md",
"arguments": {
"url": "https://example.com",
"clean": True
}
}
async with session.post(
f"{server_url}/tools/call",
headers=headers,
json=tool_request
) as response:
result = await response.json()
print("Markdown content:", result['content'][:200] + "...")
# 3. Take a screenshot
screenshot_request = {
"name": "screenshot",
"arguments": {
"url": "https://example.com",
"full_page": True
}
}
async with session.post(
f"{server_url}/tools/call",
headers=headers,
json=screenshot_request
) as response:
result = await response.json()
print("Screenshot saved:", result.get('path', 'Screenshot data returned'))
# 4. Execute JavaScript on a page
js_request = {
"name": "execute_js",
"arguments": {
"url": "https://example.com",
"script": "document.title"
}
}
async with session.post(
f"{server_url}/tools/call",
headers=headers,
json=js_request
) as response:
result = await response.json()
print("Page title:", result['content'])
# Run the example
if __name__ == "__main__":
# First, start the MCP server in HTTP mode:
# docker run -p 3000:3000 \
# -e CRAWL4AI_ENDPOINT="https://your-crawl4ai-server.com" \
# -e CRAWL4AI_BEARER_TOKEN="your-api-token" \
# stgmt/crawl4ai-mcp:latest crawl4ai-mcp --http --port 3000
asyncio.run(test_crawl4ai_mcp())
pip install aiohttp # For HTTP client
We welcome contributions! See CONTRIBUTING.mdβ for guidelines.
MIT License - see LICENSEβ file for details.
Made with β€οΈ for the AI community
Content type
Image
Digest
sha256:e04f2c542β¦
Size
440.3 MB
Last updated
about 1 year ago
docker pull stgmt/crawl4ai-mcp