Get the FREE Ultimate OpenClaw Setup Guide →

mcp-raganything

API/MCP wrapper for RagAnything

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio kaiohz-mcp-raganything uv run --directory /absolute/path/to/mcp-raganything python -m src.main \
  --env MCP_TRANSPORT="stdio"

How to use

This MCP server exposes a Claude Desktop integrated MCP endpoint for querying a RAG-based knowledge base built on top of the RAG-Anything stack. It provides a REST API via FastAPI for indexing and querying content, plus an MCP tool named query_knowledge_base that Claude Desktop can call to search the RAG knowledge base. The LightRAG proxy is wired in to forward queries and perform knowledge graph operations through the LightRAG server. Typical usage involves indexing a corpus (via file/index or folder/index), then querying the knowledge base through the MCP interface, or directly via the LightRAG proxy endpoints. The Claude integration exposes a tool configuration named query_knowledge_base with parameters for query text, mode, top_k, and a flag to return only context. This enables you to run structured information retrieval from your indexed documents and retrieve relevant chunks for downstream LLM use.

How to install

Prerequisites:

  • Python 3.13+
  • Docker & Docker Compose (recommended for quick start)
  • An OpenRouter API Key
  • Claude Desktop (for MCP server integration) if you plan to use the Claude Desktop workflow

Installation steps:

  1. Clone the repository: git clone https://github.com/Kaiohz/mcp-raganything.git cd mcp-raganything

  2. Install dependencies and run locally (via uv):

    • Ensure you have uv installed (e.g., using uvx): pipx install uvx
    • Install project dependencies and set up environment files as described in the README:

      Copy example env files

      cp .env.example .env cp .env.lightrag.server.example .env.lightrag.server

      Edit .env and .env.lightrag.server to provide OPEN_ROUTER_API_KEY, LLM keys, etc.

  3. Start services for development (optional Docker-based quick start): docker-compose up -d

    Verify containers are up and healthy

  4. Run the MCP server locally (per Claude Desktop integration): uv run --directory /absolute/path/to/mcp-raganything python -m src.main

    This starts the MCP server with stdio transport for Claude Desktop

  5. Verify the MCP server is accessible (via Claude Desktop and REST API):

Notes:

  • If you use Docker Compose, ensure environment files (.env, .env.lightrag.server) are properly set before bringing up services.
  • The MCP server relies on a LightRAG server and a PostgreSQL backend with pgvector and Apache AGE; ensure those services are reachable as configured in the environment files.

Additional notes

Tips and common issues:

  • Ensure MCP_TRANSPORT is set consistently between Claude Desktop and the MCP server (stdio is typical for local development).
  • If you encounter empty results, adjust COSINE_THRESHOLD or top_k in your environment variables.
  • Restart the MCP server after changing high-level configuration (e.g., API keys, database connections).
  • When using Docker, 3 containers are expected: postgres, api (RAG-Anything FastAPI service), and lightrag-server. The portals are accessible at the ports shown in the README.
  • The provided Claude Desktop configuration uses an absolute path to the project directory; update accordingly for your environment.

Related MCP Servers

Sponsor this space

Reach thousands of developers