The Crawl4AI RAG MCP Server is a powerful tool that integrates web crawling and RAG (Retrieval-Augmented Generation) capabilities for AI agents and coding assistants. It lets you scrape web content and use that knowledge anywhere through semantic search, with advanced RAG strategies for improved retrieval quality.
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 the required configuration (see Configuration section)
Run the Docker container:
docker run --env-file .env -p 8051:8051 mcp/crawl4ai-rag
Clone the repository:
git clone https://github.com/coleam00/mcp-crawl4ai-rag.git
cd mcp-crawl4ai-rag
Install uv if you don't have it:
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 the required configuration
Run the server:
uv run src/crawl4ai_mcp.py
Before using the server, you need to set up Supabase with the pgvector extension:
crawled_pages.sql
Create a .env
file with the following variables:
# MCP Server Configuration
HOST=0.0.0.0
PORT=8051
TRANSPORT=sse
# OpenAI API Configuration (for embeddings)
OPENAI_API_KEY=your_openai_api_key
# OpenRouter API Configuration (for LLM chat completions)
OPENROUTER_API_KEY=your_openrouter_api_key
# LLM for summaries and contextual embeddings
MODEL_CHOICE=openai/gpt-4.1-nano
# RAG Strategies
USE_CONTEXTUAL_EMBEDDINGS=false
USE_HYBRID_SEARCH=true
USE_AGENTIC_RAG=false
USE_RERANKING=true
USE_KNOWLEDGE_GRAPH=false
# Supabase Configuration
SUPABASE_URL=your_supabase_project_url
SUPABASE_SERVICE_KEY=your_supabase_service_key
# Neo4j Configuration (optional)
NEO4J_URI=bolt://localhost:7687
NEO4J_USER=neo4j
NEO4J_PASSWORD=password
You can enable several advanced RAG strategies:
Contextual Embeddings (USE_CONTEXTUAL_EMBEDDINGS=true
): Enhances chunk embeddings with additional document context for better semantic understanding.
Hybrid Search (USE_HYBRID_SEARCH=true
): Combines vector search with keyword search for more comprehensive results.
Agentic RAG (USE_AGENTIC_RAG=true
): Enables specialized code example extraction and retrieval.
Reranking (USE_RERANKING=true
): Uses cross-encoder models to improve result relevance.
Knowledge Graph (USE_KNOWLEDGE_GRAPH=true
): Enables AI hallucination detection and repository code analysis with Neo4j.
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
To enable AI hallucination detection and repository analysis, you can set up Neo4j:
Build the Neo4j Docker image:
cd neo4j/docker-neo4j
./build-docker-image.sh 5.9.0 community debian
Run Neo4j container:
docker run -d --name neo4j-container -p 7474:7474 -p 7687:7687 -v neo4j-data:/data -v neo4j-logs:/logs -e NEO4J_AUTH=neo4j/password neo4jtest:11027
Update your .env file:
NEO4J_URI=bolt://localhost:7687
NEO4J_USER=neo4j
NEO4J_PASSWORD=password
USE_KNOWLEDGE_GRAPH=true
Use this configuration to connect to the server:
{
"mcpServers": {
"crawl4ai-rag": {
"transport": "sse",
"url": "http://localhost:8051/sse"
}
}
}
For Claude Code users:
claude mcp add-json crawl4ai-rag '{"type":"sse","url":"http://localhost:8051/sse"}' --scope user
The MCP server provides several powerful tools:
crawl_single_page
: Crawl a single web pagesmart_crawl_url
: Intelligently crawl an entire websiteget_available_sources
: List all available data sourcesperform_rag_query
: Search for relevant content using RAGsearch_code_examples
: Search for code examples (when USE_AGENTIC_RAG=true
)parse_github_repository
: Parse a GitHub repository into a knowledge graph (when USE_KNOWLEDGE_GRAPH=true
)check_ai_script_hallucinations
: Validate AI-generated code (when USE_KNOWLEDGE_GRAPH=true
)query_knowledge_graph
: Explore the knowledge graph (when USE_KNOWLEDGE_GRAPH=true
)To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "crawl4ai" '{"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": {
"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": {
"transport": "sse",
"url": "http://localhost:8051/sse"
}
}
}
3. Restart Claude Desktop for the changes to take effect