grounded-rag-mcp
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@grounded-rag-mcp Using my uploaded docs, what does the refund policy say about returns?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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.
Related MCP server: insight-mcp
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/searchPhase 3 — rerank + grounding +
answer(via MCP sampling)Phase 4 — tests, types, docs, resource + prompt
Phase 5 — Streamable HTTP transport +
evaluate_retrievalPhase 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 & rerankingTools
Tool | What it does |
| Chunk, embed, and index files or raw text into a named collection |
| Hybrid / dense / bm25 retrieval, optional rerank, per-stage scores |
| Grounded, cited answer via MCP sampling; refuses when nothing is found |
| List collections and chunk counts |
| 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 -qSee docs/ARCHITECTURE.md, docs/BUILD_STORY.md, and PUBLISHING.md.
License
MIT © Chetan C
Available Tools
5 toolsanswerA
Answer a question grounded in a collection, with citations.
Retrieves the most relevant passages and asks the host's model (via MCP sampling) to
answer using ONLY those passages, citing them. Returns {grounded, answer, citations}.
If nothing relevant is found, grounded is false and no answer is invented. If the
host does not support sampling, the grounded context is returned for the host to
compose the answer itself.
Inputs: query (required), top_k, collection. Returns: object
evaluate_retrievalA
Measure retrieval quality on labeled cases: hit_rate, MRR, and recall@k.
Each case is {query, relevant_sources}. Use this to quantify quality and catch
regressions — e.g. before and after changing chunking or switching embedders.
Inputs: cases (required), mode, top_k, collection. Returns: object
ingest_documentsA
Ingest documents into a named collection so they can be searched.
Provide paths (files or directories of .txt/.md) and/or texts (raw strings).
Documents are chunked, embedded, and indexed for both semantic and keyword search.
Returns how many chunks were added and the collection's new total.
Inputs: paths, texts, chunk_size, collection, +1 more. Returns: object
list_collectionsA
List all ingested collections and how many chunks each contains.
Inputs: no named parameters. Returns: result
searchA
Search a collection and return the most relevant chunks, each with its source.
mode is "hybrid" (BM25 + semantic, default), "dense" (semantic only), or "bm25"
(keyword only). rerank applies the cross-encoder reranker if one is configured.
Each result includes per-stage scores for transparency. An empty list means nothing
relevant was found — treat that as "not in the documents".
Inputs: query (required), mode, top_k, rerank, +1 more. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 5 tools
Each tool targets a distinct operation: ingestion, search, grounded answering, collection listing, and retrieval evaluation. There is no overlap in purpose, and descriptions clearly delineate when to use each.
Tool names follow a clear imperative, snake_case style. Most use verb_noun (ingest_documents, list_collections, evaluate_retrieval), though search and answer are bare verbs rather than verb_noun, creating a minor inconsistency.
Five tools is well-scoped for a grounded RAG server: ingest, search, answer, list collections, and evaluate retrieval. Each tool covers a necessary part of the workflow without redundancy or bloat.
Core RAG workflows are covered end-to-end, including ingestion, retrieval, grounded answering, and quality evaluation. The main gap is lifecycle management: there is no way to delete or update documents or collections once ingested.
Maintenance
Related MCP Connectors
Cloud or self-hosted knowledge for AI agents: hybrid search, reranking, GraphRAG, scoped MCP tools.
Query your own PDFs and documents from any MCP client. Every answer cites the page it came from.
Agentic search over your Dewey document collections from any MCP-compatible client.
Multi-engine search for AI agents. Trust scoring, local corpus, MCP-native. Self-hostable, BYOK.
Related MCP Servers
- FlicenseNot gradedqualityBmaintenanceEnables 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-
- AlicenseNot gradedqualityCmaintenanceEnables hybrid document search (BM25 and dense) over a configurable corpus via MCP tools, returning passages and sources for AI agents to cite in answers.MIT
- AlicenseNot gradedqualityDmaintenanceProvides hybrid retrieval (dense + BM25 + RRF) with collection-based isolation and document ingestion for private knowledge access via MCP.MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to query and manage a document knowledge base via MCP, with RAG-powered search and grounded answers with citations.MIT