Skip to main content
Glama
q6066697

rag-mcp-server

by q6066697

rag-mcp-server

An MCP server that wraps the production RAG pipeline (rag-eval-service) into the standard Model Context Protocol for agents — hybrid search (dense embeddings + BM25 + RRF) becomes a tool that any MCP client can call: Claude Desktop, Claude Code, or your own agent.

Architecture

Client (Claude Desktop / Claude Code / любой MCP-клиент)
    |
    v  MCP over stdio (JSON-RPC)
FastMCP server  (rag_mcp_server/server.py)
    |
    +--> search_documents(query, top_k)
    +--> get_document(doc_id)
    +--> rerank_results(query, doc_ids)
    |
    v
Hybrid retrieval  (rag_mcp_server/core/retrieval.py)
    |
    +---> Dense retriever  --- OpenAI text-embedding-3-small ---> Qdrant (cosine, 1536d)
    |                                                                 |
    +---> Sparse retriever -- BM25 (rank-bm25 / BM25Okapi) ----------+
    |                                                                 |
    |                                 +-------------------------------+
    |                                 v
    |                        Reciprocal Rank Fusion (k=60)
    |                                 |
    +---------------------------------v
                              Top-k документов --> клиент (LLM формирует ответ)

Qdrant by default runs in embedded mode (a file on disk, no separate process) — the server is self-contained and requires no external infrastructure for a demo. If desired, you can switch to a full Qdrant server via docker-compose.yml (see below).

Related MCP server: RAG In A Box MCP Server

What this is and why

This is an MCP wrapper, not a reinvention of the retrieval logic: the hybrid search (dense + BM25 + RRF) is ported from rag-eval-service almost unchanged. What this wrapper adds:

  • Protocol instead of HTTP API — the tools are visible to any MCP client (Claude Desktop, Claude Code) without writing a custom HTTP client and without the need to keep the service always up behind REST.

  • Self-contained demo mode — embedded Qdrant instead of a Docker container, so then git clone → working tool takes the minimum number of steps.

  • doc_id/title schema and document-level result aggregation (rather than chunk-level) — for the needs of an LLM client that calls search_documentsget_document instead of working with raw chunks.

  • Docstring contracts written for the LLM consumer of the tool (see rag_mcp_server/server.py), not for a human reading the API documentation.

How to run locally

Requirements: Python 3.10+ and an OpenAI API key (for embeddings).

git clone https://github.com/q6066697/rag-mcp-server.git
cd rag-mcp-server

python3 -m venv .venv
source .venv/bin/activate        # Windows: .venv\Scripts\activate
pip install -r requirements.txt  # или: pip install -e ".[dev]"

cp .env.example .env
# впишите свой OPENAI_API_KEY в .env

Build the index (one-time; reads data/, embeds chunks through OpenAI and loads them into embedded Qdrant):

python -m rag_mcp_server.core.indexing

(Optional) real Qdrant instead of embedded mode:

docker-compose up -d
# затем в .env: QDRANT_MODE=server

Start the server (stdio transport):

python -m rag_mcp_server.server

Check via MCP Inspector (the built-in inspector from mcp[cli]; opens a web UI for calling tools manually):

mcp dev rag_mcp_server/server.py

Tests (require no live Qdrant/OpenAI — vector search and cross-encoder are mocked):

pytest

How to connect in Claude Desktop / Claude Code

Add it to claude_desktop_config.json (Claude Desktop: Settings → Developer → Edit Config; Claude Code: .mcp.json in the project or claude mcp add):

{
  "mcpServers": {
    "rag-mcp-server": {
      "command": "/absolute/path/to/rag-mcp-server/.venv/bin/python",
      "args": ["-m", "rag_mcp_server.server"],
      "cwd": "/absolute/path/to/rag-mcp-server",
      "env": {
        "OPENAI_API_KEY": "sk-..."
      }
    }
  }
}

After restarting the client, the search_documents, get_document, and rerank_results tools should appear in the list of available tools.

Examples of calling the tools

search_documents

search_documents(query="что такое Reciprocal Rank Fusion", top_k=3)
[
  {
    "doc_id": "reciprocal-rank-fusion.md",
    "title": "Reciprocal Rank Fusion",
    "snippet": "RRF сливает несколько ранжированных списков без нормализации сырых score — документ на позиции r получает вклад 1/(k+r)…",
    "score": 0.0328
  },
  {
    "doc_id": "hybrid-search.md",
    "title": "Hybrid Search",
    "snippet": "Гибридный поиск комбинирует dense-эмбеддинги и BM25, чтобы ловить и семантическое сходство, и точные термины…",
    "score": 0.0301
  }
]

get_document

get_document(doc_id="reciprocal-rank-fusion.md")
"# Reciprocal Rank Fusion (RRF)\n\nRRF — метод слияния нескольких ранжированных списков результатов…"

rerank_results

rerank_results(
    query="как оценивать качество ретривера",
    doc_ids=["eval-retrieval-metrics.md", "reranking.md", "hybrid-search.md"]
)
[
  {
    "doc_id": "eval-retrieval-metrics.md",
    "title": "Evaluating Retrieval Quality",
    "snippet": "Метрики retrieval — hit@k, recall@k, MRR, nDCG@k — измеряют, находит ли поиск релевантные документы…",
    "score": 4.81
  },
  {
    "doc_id": "reranking.md",
    "title": "Reranking",
    "snippet": "Cross-encoder реранкинг переупорядочивает шортлист кандидатов, читая query и passage вместе…",
    "score": 1.02
  }
]

Repository structure

rag-mcp-server/
├── rag_mcp_server/
│   ├── server.py          # точка входа, FastMCP инстанс, регистрация tools
│   ├── core/
│   │   ├── retrieval.py   # портированная гибридная логика поиска (dense + BM25 + RRF + rerank)
│   │   └── indexing.py    # загрузка корпуса, чанкинг, индексация в Qdrant
│   └── config.py          # конфигурация из .env
├── data/                  # bootstrap-корпус (15 markdown-доков, копия из rag-eval-service)
├── tests/
│   └── test_server.py     # unit-тесты на MCP tools (мокают поиск)
├── docker-compose.yml     # опциональный Qdrant-сервер
├── pyproject.toml / requirements.txt
├── .env.example
└── LICENSE (MIT)

Source of the retrieval logic

The hybrid search (rag_mcp_server/core/retrieval.py, core/indexing.py) is ported from rag-eval-service — the eval harness also lives there (NFCorpus/BEIR benchmark, a custom golden set, and hit@k/recall@k/MRR/nDCG metrics), which is intentionally missing from this repository: rag-mcp-server is a thin protocol wrapper around an already validated retrieval pipeline, not a re-evaluation of it.

What would be added next

  • Docker for the MCP server itself — right now only Qdrant is wrapped in a container; deploying the server itself requires its own Dockerfile.

  • SSE/HTTP transport — stdio assumes a local process on the same machine as the client; for remote access (multiple users, cloud deployment), SSE or Streamable HTTP transport from the MCP SDK is needed.

  • Authorization — stdio has none by design (a trusted process run locally); moving to a network transport will require an API key / OAuth at the server level.

  • Incremental indexingcore.indexing currently recreates the whole collection; for a growing corpus, you need to upsert only changed documents.

  • Real Qdrant by default in CI/production — embedded mode is fine for demos and tests, but concurrency multiple processes require a running server.

Install Server
A
license - permissive license
A
quality
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    MCP server for document ingestion and semantic search on Qdrant. Enables ingesting local documents, generating embeddings with OpenAI, and performing vector search with metadata filters.
    Apache 2.0
  • F
    license
    Not graded
    quality
    B
    maintenance
    Enables any MCP-compatible AI assistant to search, filter, and retrieve information from a local document collection using a hybrid search pipeline with vector, BM25, reranking, and LLM enrichment.
    4
  • F
    license
    Not graded
    quality
    C
    maintenance
    Provides RAG-based knowledge retrieval and document management as MCP tools, supporting hybrid search, reranking, and retrieval process visualization.

View all related MCP servers

Related MCP Connectors

  • Turn a GitHub repo or docs site into agent-ready context: pack it or search it, over MCP.

  • OCR, transcription, file extraction, and image generation for AI agents via MCP.

  • Agentic search over your Dewey document collections from any MCP-compatible client.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/q6066697/rag-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server