Crawl4AI MCP server

Provides advanced web crawling and RAG capabilities through Crawl4AI with semantic search, knowledge graph integration, and hallucination detection for intelligent content analysis and automated documentation discovery.
Back to servers
Setup instructions
Provider
Cole Medin
Release date
Jul 15, 2025
Language
JavaScript
Stats
1 star

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.

Installation

Docker Installation (Recommended)

  1. Clone the repository:

    git clone https://github.com/coleam00/mcp-crawl4ai-rag.git
    cd mcp-crawl4ai-rag
    
  2. Build the Docker image:

    docker build -t mcp/crawl4ai-rag --build-arg PORT=8051 .
    
  3. Create a .env file with the required configuration (see Configuration section)

  4. Run the Docker container:

    docker run --env-file .env -p 8051:8051 mcp/crawl4ai-rag
    

Manual Installation

  1. Clone the repository:

    git clone https://github.com/coleam00/mcp-crawl4ai-rag.git
    cd mcp-crawl4ai-rag
    
  2. Install uv if you don't have it:

    pip install uv
    
  3. Create and activate a virtual environment:

    uv venv
    .venv\Scripts\activate
    # on Mac/Linux: source .venv/bin/activate
    
  4. Install dependencies:

    uv pip install -e .
    crawl4ai-setup
    
  5. Create a .env file with the required configuration

  6. Run the server:

    uv run src/crawl4ai_mcp.py
    

Database Setup

Before using the server, you need to set up Supabase with the pgvector extension:

  1. Create a Supabase project if you don't have one
  2. Go to the SQL Editor in your Supabase dashboard
  3. Create a new query and paste the contents of crawled_pages.sql
  4. Run the query to create the necessary tables and functions

Configuration

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

RAG Strategy Options

You can enable several advanced RAG strategies:

  1. Contextual Embeddings (USE_CONTEXTUAL_EMBEDDINGS=true): Enhances chunk embeddings with additional document context for better semantic understanding.

  2. Hybrid Search (USE_HYBRID_SEARCH=true): Combines vector search with keyword search for more comprehensive results.

  3. Agentic RAG (USE_AGENTIC_RAG=true): Enables specialized code example extraction and retrieval.

  4. Reranking (USE_RERANKING=true): Uses cross-encoder models to improve result relevance.

  5. Knowledge Graph (USE_KNOWLEDGE_GRAPH=true): Enables AI hallucination detection and repository code analysis with Neo4j.

Recommended Configurations

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

Knowledge Graph Setup (Optional)

To enable AI hallucination detection and repository analysis, you can set up Neo4j:

Using the Included Neo4j Docker Setup

  1. Build the Neo4j Docker image:

    cd neo4j/docker-neo4j
    ./build-docker-image.sh 5.9.0 community debian
    
  2. 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
    
  3. Update your .env file:

    NEO4J_URI=bolt://localhost:7687
    NEO4J_USER=neo4j
    NEO4J_PASSWORD=password
    USE_KNOWLEDGE_GRAPH=true
    

Integration with MCP Clients

SSE Configuration

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

Available Tools

The MCP server provides several powerful tools:

  1. crawl_single_page: Crawl a single web page
  2. smart_crawl_url: Intelligently crawl an entire website
  3. get_available_sources: List all available data sources
  4. perform_rag_query: Search for relevant content using RAG
  5. search_code_examples: Search for code examples (when USE_AGENTIC_RAG=true)
  6. parse_github_repository: Parse a GitHub repository into a knowledge graph (when USE_KNOWLEDGE_GRAPH=true)
  7. check_ai_script_hallucinations: Validate AI-generated code (when USE_KNOWLEDGE_GRAPH=true)
  8. query_knowledge_graph: Explore the knowledge graph (when USE_KNOWLEDGE_GRAPH=true)

How to install this MCP server

For Claude Code

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.

For Cursor

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.

Adding an MCP server to Cursor globally

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"
        }
    }
}

Adding an MCP server to a project

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.

How to use the MCP server

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.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.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

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later