Crawl4AI RAG MCP server

Integrates web crawling with RAG functionality to enable website content retrieval, storage in vector databases, and semantic searching over crawled data for enhanced knowledge access
Back to servers
Setup instructions
Provider
Cole Medin
Release date
May 04, 2025
Language
JavaScript
Stats
1.2K stars

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.

Prerequisites

Before installation, ensure you have:

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 your configuration settings (see Configuration section)

Direct Installation

  1. Clone the repository:

    git clone https://github.com/coleam00/mcp-crawl4ai-rag.git
    cd mcp-crawl4ai-rag
    
  2. Install uv:

    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 your configuration settings

Database Setup

Set up the Supabase database with pgvector extension:

  1. Go to the SQL Editor in your Supabase dashboard
  2. Create a new query and paste the contents of crawled_pages.sql
  3. Run the query to create the necessary tables and functions

Configuration

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

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

Running the Server

Using Docker

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

Using Python

uv run src/crawl4ai_mcp.py

Using the MCP Server

The server provides the following tools:

Core Tools

  1. crawl_single_page: Crawl a single web page and store its content

    crawl_single_page(url="https://example.com/docs/page")
    
  2. smart_crawl_url: Intelligently crawl a website based on the URL type

    smart_crawl_url(url="https://example.com/docs", max_pages=50)
    
  3. get_available_sources: Get a list of all available sources in the database

    get_available_sources()
    
  4. 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"])
    

Conditional Tools

  1. search_code_examples: Search for code examples (requires USE_AGENTIC_RAG=true)
    search_code_examples(query="how to initialize the client")
    

Knowledge Graph Tools (requires USE_KNOWLEDGE_GRAPH=true)

  1. parse_github_repository: Parse a GitHub repository into a Neo4j knowledge graph

    parse_github_repository(repo_url="https://github.com/username/repo.git")
    
  2. check_ai_script_hallucinations: Analyze Python scripts for AI hallucinations

    check_ai_script_hallucinations(script_path="/path/to/script.py")
    
  3. query_knowledge_graph: Explore the Neo4j knowledge graph

    query_knowledge_graph(command="classes", repo_name="repo-name")
    

Integration with MCP Clients

SSE Configuration

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

Stdio Configuration

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

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-rag" '{"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-rag": {
            "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-rag": {
            "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