grounded-rag-mcp
An MCP server that gives any LLM host grounded, cited retrieval over your own documents — hybrid retrieval (BM25 + dense), cross-encoder reranking, citations, and a built-in eval harness.
Point it at a folder of documents. Your MCP host (Claude Desktop, an IDE, a custom agent) can then
searchandanswerover them — grounded in the real text, with citations, and an honest "not in the documents" path.
Why
Most RAG-over-MCP examples are toys. This one is built production-flavored:
- Hybrid retrieval — BM25 (exact terms) + dense (semantics), fused with Reciprocal Rank Fusion.
- Cross-encoder reranking — precision on the top candidates without blowing latency.
- Grounding + citations — answers cite their sources; if the answer isn't in the docs, it says so.
- Built-in eval — measure retrieval quality (recall@k, MRR, hit-rate), not just vibes.
- Local-first — the default path runs with no external services or API keys.
- Both transports — stdio and Streamable HTTP.
Status
🚧 Early development. Building in public, phase by phase (see PROJECT_REQUIREMENTS.md).
- Phase 0 — scaffold, packaging, CI
- Phase 1 — core retrieval (chunk → embed → BM25 + dense → RRF)
- Phase 2 — MCP server (stdio) with
ingest/search - Phase 3 — rerank + grounding +
answer(via MCP sampling) - Phase 4 — tests, types, docs, resource + prompt
- Phase 5 — Streamable HTTP transport +
evaluate_retrieval - Phase 6 — publish to PyPI
Install
pip install grounded-rag-mcp # lean, local-first default (no torch)
pip install "grounded-rag-mcp[st]" # + sentence-transformers for semantic embeddings & reranking
Tools
| Tool | What it does |
|---|---|
ingest_documents |
Chunk, embed, and index files or raw text into a named collection |
search |
Hybrid / dense / bm25 retrieval, optional rerank, per-stage scores |
answer |
Grounded, cited answer via MCP sampling; refuses when nothing is found |
list_collections |
List collections and chunk counts |
evaluate_retrieval |
hit_rate / MRR / recall@k on labeled cases |
Also exposes a resource (rag://collections) and a prompt (grounded_answer).
Use it with an MCP host (e.g. Claude Desktop)
Add to your host's MCP config:
{
"mcpServers": {
"grounded-rag": {
"command": "grounded-rag-mcp"
}
}
}
Or run it directly:
grounded-rag-mcp # stdio (default, for local hosts)
grounded-rag-mcp --http # Streamable HTTP on 127.0.0.1:8000 (remote / multi-client)
Use the retrieval engine as a Python library
from grounded_rag_mcp.collection import Collection
from grounded_rag_mcp.embeddings import HashingEmbedder
from grounded_rag_mcp.ingest import load_texts
from grounded_rag_mcp.config import RetrievalConfig
col = Collection("kb", HashingEmbedder(dim=512))
col.add(load_texts(["The refund policy allows returns within 30 days of purchase."]))
for hit in col.retrieve("refund policy", RetrievalConfig(top_k=1)):
print(hit.chunk.source, hit.score, hit.stage_scores)
Development
pip install -e ".[dev]"
ruff check . && ruff format --check . && mypy src && pytest -q
See docs/ARCHITECTURE.md, docs/BUILD_STORY.md, and PUBLISHING.md.
License
MIT © Chetan C
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file grounded_rag_mcp-0.1.0.tar.gz.
File metadata
- Download URL: grounded_rag_mcp-0.1.0.tar.gz
- Upload date:
- Size: 34.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bc0c81522e0bc7eebe70bd6ffead216f743cae99b428c17f277f8201da50ad97
|
|
| MD5 |
c57e4b26b8c7380300d604bdacc3a8be
|
|
| BLAKE2b-256 |
28d0c9ed3ccdcb30ea3464cb20096dbd1a140aa8f013c0d55217889bc37a9084
|
Provenance
The following attestation bundles were made for grounded_rag_mcp-0.1.0.tar.gz:
Publisher:
release.yml on chetan1521/grounded-rag-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
grounded_rag_mcp-0.1.0.tar.gz -
Subject digest:
bc0c81522e0bc7eebe70bd6ffead216f743cae99b428c17f277f8201da50ad97 - Sigstore transparency entry: 2760588676
- Sigstore integration time:
-
Permalink:
chetan1521/grounded-rag-mcp@e7c64a0decf25498fdf00620dbe1092a580eb90e -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/chetan1521
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e7c64a0decf25498fdf00620dbe1092a580eb90e -
Trigger Event:
release
-
Statement type:
File details
Details for the file grounded_rag_mcp-0.1.0-py3-none-any.whl.
File metadata
- Download URL: grounded_rag_mcp-0.1.0-py3-none-any.whl
- Upload date:
- Size: 22.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c9588d622a91514695e1b8a8b3b8b0d44ad1bf026cfa4ac5824e94bbea0e2600
|
|
| MD5 |
b04b7752a0c25e60ecb70fdac0ec5341
|
|
| BLAKE2b-256 |
847e305c1c525c78cb88e059398462f5f746e3228ad03d57d9755a8402fe64f8
|
Provenance
The following attestation bundles were made for grounded_rag_mcp-0.1.0-py3-none-any.whl:
Publisher:
release.yml on chetan1521/grounded-rag-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
grounded_rag_mcp-0.1.0-py3-none-any.whl -
Subject digest:
c9588d622a91514695e1b8a8b3b8b0d44ad1bf026cfa4ac5824e94bbea0e2600 - Sigstore transparency entry: 2760588687
- Sigstore integration time:
-
Permalink:
chetan1521/grounded-rag-mcp@e7c64a0decf25498fdf00620dbe1092a580eb90e -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/chetan1521
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e7c64a0decf25498fdf00620dbe1092a580eb90e -
Trigger Event:
release
-
Statement type: