RAG-DuckDB MCP server

Provides document processing and retrieval-augmented generation capabilities using DuckDB as the vector database backend, featuring intelligent chunking strategies that adapt to file types, hybrid search combining semantic similarity with BM25 keyword search, and support for over 20 file formats including programming languages and documentation formats.
Back to servers
Setup instructions
Provider
niksh06
Release date
Jul 16, 2025
Language
Go
Stats
5 stars

This Python RAG Server with DuckDB provides a powerful document processing and retrieval-augmented generation solution. It offers both a web interface and JSON API for uploading documents, processing them into chunks with embeddings, and storing them in DuckDB for efficient semantic search.

Installation

Prerequisites

  • Docker installed and running on your machine

Build and Run with Docker

  1. Build the Docker image:

    For standard build (with GPU support):

    docker build -t rag-duckdb-server .
    

    For CPU-only build (recommended for local development):

    docker build --build-arg USE_CPU_ONLY=true -t rag-duckdb-server-cpu .
    
  2. Run the Docker container:

    Standard build:

    docker run -p 8000:8000 \
      -v "$(pwd)/uploads:/app/uploads" \
      -v "$(pwd)/data:/app/data" \
      --name rag-server \
      rag-duckdb-server
    

    CPU-only build:

    docker run -p 8000:8000 \
      -v "$(pwd)/uploads:/app/uploads" \
      -v "$(pwd)/data:/app/data" \
      --name rag-server-cpu \
      rag-duckdb-server-cpu
    

    Note: Windows PowerShell users should use ${pwd} instead of $(pwd).

  3. Access the application: Open your browser and navigate to http://localhost:8000

Usage

Basic Workflow

  1. Upload Files: Use the web interface to upload one or more supported files.

  2. Upload Directory: Alternatively, upload entire directories with file extension filtering.

  3. Process Files: Click "Start Processing" to:

    • Extract text content
    • Split text into context-aware chunks
    • Generate vector embeddings for each chunk
    • Save everything to the DuckDB database
    • Remove processed files from uploads folder
  4. Search Documents: Use the semantic search bar to find relevant content across all indexed chunks.

  5. Use API: Interact programmatically via the API endpoints.

Supported File Types

Text Documents

  • .txt - Plain text files
  • .md - Markdown files
  • .pdf - PDF documents

Programming Languages

  • .py - Python
  • .js, .ts, .jsx, .tsx - JavaScript/TypeScript
  • .java - Java
  • .c, .cpp, .cc, .cxx - C/C++
  • .cs - C#
  • And many others including Go, Rust, PHP, Ruby, Scala, Swift

Web Technologies

  • .html, .htm - HTML
  • .css, .scss, .sass - CSS and preprocessors

Data Formats

  • .json - JSON
  • .yaml, .yml - YAML
  • .xml - XML
  • .sql - SQL
  • .ini, .toml - Configuration files

API Endpoints

Web Interface

  • GET / - Main web interface
  • POST /upload-files/ - Upload individual files
  • POST /upload-directory/ - Upload directory with extension filtering
  • POST /process-files/ - Process uploaded files
  • POST /search/ - Search interface
  • POST /delete-file/ - Delete uploaded file

JSON API

  • POST /api/search - Programmatic search endpoint
  • GET /api/stats - Get collection statistics
  • GET /health - Health check endpoint

Search API Parameters

  • query (required): Search query string
  • top_k (optional, default: 5): Number of results to return (1-50)
  • search_type (optional, default: "hybrid"): "hybrid", "semantic", or "keyword"
  • use_reranker (optional, default: true): Enable/disable result reranking
  • expand_query (optional, default: false): Enable/disable query expansion

Troubleshooting

Common Issues

  1. Docker Build Fails: Try the CPU-only build:

    docker build --build-arg USE_CPU_ONLY=true -t rag-duckdb-server-cpu .
    
  2. Memory Issues: For large document collections:

    • Use the CPU-only build (smaller memory footprint)
    • Process files in smaller batches
    • Increase Docker memory limits
  3. Database Issues: If you encounter database errors, delete the data/ directory to start fresh.

Health Check

Monitor service status with:

curl http://localhost:8000/health

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 "rag-duckdb" '{"command":"python","args":["-m","rag_duckdb"]}'

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": {
        "rag-duckdb": {
            "command": "python",
            "args": [
                "-m",
                "rag_duckdb"
            ]
        }
    }
}

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": {
        "rag-duckdb": {
            "command": "python",
            "args": [
                "-m",
                "rag_duckdb"
            ]
        }
    }
}

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