Sextant is a retrieval system built on the Model Context Protocol. The knowledge base is not an internal module — it is a real MCP server that runs as its own process and speaks JSON-RPC over stdio, so an IDE assistant, an agent or a chat app can query it natively with no glue code. It is published on PyPI as sextant-kb (MIT), listed in the official MCP registry, and open source at github.com/hulagerushikesh/sextant.
The aim
Most RAG projects are a pipeline wrapped in a bespoke HTTP API, which means the retrieval is only ever reachable from the one app it was built for. Sextant inverts that: the knowledge base is the distributable component, and the FastAPI agent server is just one of its clients. pip install sextant-kb gets you the server and the two commands that feed it — no web framework, no model client, nothing else.
The second aim is that no retrieval decision is taken on intuition. Every stage had to earn its place in a budgeted experiment, and the ones that did not were rejected and written up rather than quietly left in.
Retrieval, measured
- Four modes, all graded — dense cosine search over ChromaDB, Okapi BM25 implemented from scratch, Reciprocal Rank Fusion over both, then a cross-encoder rerank. All four are scored against a 65-question golden set in CI: dense reaches hit@1 0.873, fusion 0.909, and the reranked pipeline 0.927 with recall@5 0.982 and nDCG@5 0.952.
- Checked on public data too — on three public BEIR benchmark sets the full pipeline beats the published BM25 + cross-encoder baseline. Its own keyword stage loses to standard BM25 on all three, and the results page says that first.
- A quality gate that can actually fail —
sextant-eval --checkcompares a run against a committed baseline and fails on a regression, on a mode left ungraded, on a shortened question set, or on a missing baseline file. No baseline is a failure, not a pass. - The rejections are output too — HyDE, prompt caching, a score-floor fallback and per-query index routing were each measured and deliberately turned down. Table-aware chunking (a table row is a record, so each row becomes its own chunk carrying the caption and header in front of it), per-document candidate caps, and model-written document overviews earned their place and shipped. Each decision is a write-up with its numbers in
learning/.
Index Lab — the vector index, from scratch
Flat, HNSW and IVF-PQ are all implemented by hand, with FAISS kept alongside purely as a reference to check them against, and the running server can switch between them live. Measured at 100k and 1M vectors, HNSW beats IVF-PQ on both recall and latency at every size and IVF-PQ’s only real win is memory — so the system tiers per deployment instead of trying to route per query, because the query text carries no signal for that choice.
Built to be depended on
- Multi-tenant by construction — every tool result is scoped to the asker, deny by default: an entry is trimmed out of a response unless the caller may see it, and a write is checked against an allow-list before the store is touched, because re-using a document id is a replacement. The caller’s name is believed only when it arrives with a shared secret from the reverse proxy; a name without it is a 403, never a quiet fallback.
- Cost is a first-class constraint — a per-UTC-day spend cap persisted to disk, so a redeploy or a container restart does not begin the day again at zero; a per-user share underneath that cap; per-query cost in the structured log; and the cheapest Gemini model that actually survives the agentic tool loop rather than the cheapest one that passes a single-shot probe.
- Honest reporting — a spend figure the server cannot date is labelled as such instead of being printed beside “resets 00:00 UTC”, and a PDF page that fails to extract is reported to the uploader rather than logged and skipped, because a missing page is never noticed by the person searching for it.
Stack
Python 3.11+, roughly 9,800 lines across one import package. ChromaDB with all-MiniLM-L6-v2 embeddings and a ms-marco cross-encoder reranker, PyMuPDF ingestion, FastAPI for the agent server, and a React 19 + TypeScript + Tailwind v4 + shadcn front end with inline citations, an agent trace and drag-and-drop upload. 939 Python tests and 72 front-end tests run in CI alongside the type checker, the linter and the retrieval gate.
Recent versions also read scanned PDFs with text recognition (English by default, Hindi and Marathi on request) and name each document by its path, so files that share a name are all indexed. A hosted version was built and verified with test accounts, then removed in November 2026 to keep costs at zero: the package is the part you can run yourself today.