Crawl4AI RAG MCP Server is a powerful implementation that integrates Model Context Protocol with Crawl4AI and Supabase to provide AI agents and coding assistants with advanced web crawling and RAG (Retrieval Augmented Generation) capabilities. This server allows you to scrape web content and leverage that knowledge for intelligent retrieval.
Before installation, ensure you have:
Clone the repository:
git clone https://github.com/coleam00/mcp-crawl4ai-rag.git
cd mcp-crawl4ai-rag
Build the Docker image:
docker build -t mcp/crawl4ai-rag --build-arg PORT=8051 .
Create a .env
file with your configuration settings (see Configuration section)
Clone the repository:
git clone https://github.com/coleam00/mcp-crawl4ai-rag.git
cd mcp-crawl4ai-rag
Install uv:
pip install uv
Create and activate a virtual environment:
uv venv
.venv\Scripts\activate
# on Mac/Linux: source .venv/bin/activate
Install dependencies:
uv pip install -e .
crawl4ai-setup
Create a .env
file with your configuration settings
Set up the Supabase database with pgvector extension:
crawled_pages.sql
Create a .env
file in the project root with the following variables:
# MCP Server Configuration
HOST=0.0.0.0
PORT=8051
TRANSPORT=sse
# OpenAI API Configuration
OPENAI_API_KEY=your_openai_api_key
# LLM for summaries and contextual embeddings
MODEL_CHOICE=gpt-4.1-nano
# RAG Strategies
USE_CONTEXTUAL_EMBEDDINGS=false
USE_HYBRID_SEARCH=false
USE_AGENTIC_RAG=false
USE_RERANKING=false
USE_KNOWLEDGE_GRAPH=false
# Supabase Configuration
SUPABASE_URL=your_supabase_project_url
SUPABASE_SERVICE_KEY=your_supabase_service_key
# Neo4j Configuration (required for knowledge graph functionality)
NEO4J_URI=bolt://localhost:7687
NEO4J_USER=neo4j
NEO4J_PASSWORD=your_neo4j_password
For general documentation RAG:
USE_CONTEXTUAL_EMBEDDINGS=false
USE_HYBRID_SEARCH=true
USE_AGENTIC_RAG=false
USE_RERANKING=true
For AI coding assistant with code examples:
USE_CONTEXTUAL_EMBEDDINGS=true
USE_HYBRID_SEARCH=true
USE_AGENTIC_RAG=true
USE_RERANKING=true
USE_KNOWLEDGE_GRAPH=false
For fast, basic RAG:
USE_CONTEXTUAL_EMBEDDINGS=false
USE_HYBRID_SEARCH=true
USE_AGENTIC_RAG=false
USE_RERANKING=false
USE_KNOWLEDGE_GRAPH=false
docker run --env-file .env -p 8051:8051 mcp/crawl4ai-rag
uv run src/crawl4ai_mcp.py
The server provides the following tools:
crawl_single_page: Crawl a single web page and store its content
crawl_single_page(url="https://example.com/docs/page")
smart_crawl_url: Intelligently crawl a website based on the URL type
smart_crawl_url(url="https://example.com/docs", max_pages=50)
get_available_sources: Get a list of all available sources in the database
get_available_sources()
perform_rag_query: Search for relevant content with optional source filtering
perform_rag_query(query="How do I install this library?", sources=["docs.example.com"])
USE_AGENTIC_RAG=true
)
search_code_examples(query="how to initialize the client")
USE_KNOWLEDGE_GRAPH=true
)parse_github_repository: Parse a GitHub repository into a Neo4j knowledge graph
parse_github_repository(repo_url="https://github.com/username/repo.git")
check_ai_script_hallucinations: Analyze Python scripts for AI hallucinations
check_ai_script_hallucinations(script_path="/path/to/script.py")
query_knowledge_graph: Explore the Neo4j knowledge graph
query_knowledge_graph(command="classes", repo_name="repo-name")
{
"mcpServers": {
"crawl4ai-rag": {
"transport": "sse",
"url": "http://localhost:8051/sse"
}
}
}
For Windsurf users, use serverUrl
instead of url
:
{
"mcpServers": {
"crawl4ai-rag": {
"transport": "sse",
"serverUrl": "http://localhost:8051/sse"
}
}
}
For Claude Code users:
claude mcp add-json crawl4ai-rag '{"type":"http","url":"http://localhost:8051/sse"}' --scope user
{
"mcpServers": {
"crawl4ai-rag": {
"command": "python",
"args": ["path/to/crawl4ai-mcp/src/crawl4ai_mcp.py"],
"env": {
"TRANSPORT": "stdio",
"OPENAI_API_KEY": "your_openai_api_key",
"SUPABASE_URL": "your_supabase_url",
"SUPABASE_SERVICE_KEY": "your_supabase_service_key",
"USE_KNOWLEDGE_GRAPH": "false",
"NEO4J_URI": "bolt://localhost:7687",
"NEO4J_USER": "neo4j",
"NEO4J_PASSWORD": "your_neo4j_password"
}
}
}
}
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "crawl4ai-rag" '{"transport":"sse","url":"http://localhost:8051/sse"}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"crawl4ai-rag": {
"transport": "sse",
"url": "http://localhost:8051/sse"
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"crawl4ai-rag": {
"transport": "sse",
"url": "http://localhost:8051/sse"
}
}
}
3. Restart Claude Desktop for the changes to take effect