Start in one line
uvx agentic-rag-mcp serve --docs ~/notes
Or add it to Claude Code:
claude mcp add notes -- uvx agentic-rag-mcp serve --docs /absolute/path/to/notes
Or to Claude Desktop, in claude_desktop_config.json:
{
"mcpServers": {
"notes": {
"command": "uvx",
"args": ["agentic-rag-mcp", "serve", "--docs", "/absolute/path/to/notes"]
}
}
}
It indexes every .md, .txt and .rst file under the
folder and hands the client three search tools. Leave out --docs and it serves
a small bundled demo corpus, so you can try it before pointing it at anything of yours.
The first search downloads a 90 MB embedding model once. To do that, and build the index, before a client is waiting on it:
uvx agentic-rag-mcp index --docs ~/notes
Why agentic retrieval
Naive RAG searches once: embed the question, take the top few chunks, answer. That works until a question has two parts living in two places. "How do I authenticate after the 3.0 change, and is the old way still supported?" needs the migration guide and the changelog, and a single top-k search often returns one and misses the other.
Agentic RAG gives the model the search tool instead. It searches, reads what came back, notices that half the question is still open, and searches again with a sharper query.
The client is the agent
Through MCP, Claude does the searching itself. This server needs no API key: it answers searches and nothing else.
Indexing stays local
Embeddings run on your machine through ONNX Runtime. No document is uploaded to build or search the index.
No PyTorch
The same all-MiniLM-L6-v2 model, with vectors identical to sentence-transformers, at a fraction of the install. The whole environment measures 308 MB.
Fast to restart
Embeddings are cached on disk, keyed by a hash of every chunk, so a stale vector is never served and an unchanged corpus loads instantly.
Measured, not asserted
Does one search actually miss things? Nine questions over the demo documents, each listing the facts a complete answer needs. A fact counts as retrieved if its phrase appears in a retrieved chunk from the right document. Whether a question needs more than one chunk is computed from the real chunking, not declared.
At two chunks per search, over the 10-chunk index:
| Strategy | Recall | 2+ chunk questions | 1 chunk questions | Complete | Chunks read |
|---|---|---|---|---|---|
| One search | 79.6% | 79.2% | 80.0% | 5/9 | 2.0 |
| One search, twice the chunks | 85.2% | 79.2% | 90.0% | 6/9 | 4.0 |
| Question split at commas | 79.6% | 79.2% | 80.0% | 5/9 | 3.0 |
| Planned sub-queries | 88.9% | 87.5% | 90.0% | 7/9 | 2.8 |
What it shows
- Better queries beat more chunks on multi-hop questions. Planned sub-queries reach 87.5% where doubling the budget of one search stays at 79.2%, while reading fewer chunks (2.8 against 4.0).
- Splitting the question mechanically does not help. Query planning needs understanding, which is the model's job.
- Some facts no query found. "The defaults are 5 and 30" lives in a code signature, which a purely semantic embedding matches poorly. That is where hybrid keyword search would help, and it is the next upgrade.
Run it yourself. CI reruns it on every push and posts the table to the run summary.
agentic-rag-mcp eval -k 2
agentic-rag-mcp eval -k 2 --agent # also score a real agent's searches (makes API calls)
Three tools, all read-only
| Tool | What it returns |
|---|---|
kb_search(query, k=4) |
The chunks closest in meaning to the query, each with a cosine score, its source
document and a chunk_id to cite. |
kb_fetch(chunk_id) | The full text of one chunk. |
kb_sources() | The indexed documents and the size of the index. |
Every tool publishes an output schema, so clients get validated structured results rather than a string to parse. Mistakes an agent can fix, such as an empty query or an unknown chunk id, come back with an explanation it can act on instead of a bare "error executing tool".
Built-in agents, if you want them
The package also runs the agents itself, with an Anthropic API key:
pip install "agentic-rag-mcp[agents]"
agentic-rag-mcp ask "How do I authenticate a SqlSource after 3.0, and is the old way still supported?"
agentic-rag-mcp ask --naive "..." # one search, one model call: the fair baseline
agentic-rag-mcp ask --pipeline "..." # retriever, synthesizer, verifier
The agent loop is one short function, written by hand so the control flow can be read. It runs Claude Opus 5.5 with adaptive thinking and an explicit effort level, caches the growing conversation, and stops loudly: a refusal, running out of tokens or hitting the turn limit raises an error rather than handing on a placeholder as if it were an answer.
The pipeline is a fixed workflow, not a swarm: a retriever gathers evidence, a synthesizer drafts, and a verifier with structured output sends unsupported claims back for revision. For a task this well shaped, a script is more predictable and cheaper than agents spawning agents.
Honest limitations
- Plain text only. Markdown, text and reStructuredText. PDFs and office documents each need a parser, and a bad extraction quietly poisons retrieval.
- Semantic search only. No keyword (BM25) hybrid and no reranker, and the measurement above shows a question it costs.
- Any edit re-embeds the whole folder. Fine for documentation; slow for a very large corpus.
- Exact search over every chunk. Right for a documentation set, not designed for millions of chunks.
- stdio only. There is no HTTP transport, deliberately: an unauthenticated network server would expose your documents to anyone who can reach it.