KeyRAG
OfficialThis server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
KeyRAG — by KitiLab
Beat 133 MB Transformer RAG stacks on official public BEIR benchmarks — in ~5–14 ms on a laptop CPU, inside one portable
.kragSQLite file, with zero PyTorch, zero Docker, and zero background servers.
Verified BEIR Benchmarks (Reproducible in One Command)
Measured locally on an x86_64 Linux laptop (Python 3.15, SQLite 3.54, sqlite-vec 0.1.9) using minishlab/blink-8M quantized to a 7.44 MB int8 mmap table + SQLite Porter FTS5 + Adaptive IDF-Weighted Convex Fusion:
System | Runtime Engine | Model Size | SciFact | SciFact | NFCorpus | Local CPU Latency ( |
KeyRAG (Adaptive Hybrid) | C SQLite + C | 7.4 MB | 72.83% | 86.79% | 35.19% | 5.7–11.5 ms / 8.6–16.0 ms |
| 33M Transformer (PyTorch/ONNX) | 133 MB | 70.80% | 83.0% | 34.20% | ~30–80 ms |
BM25 Only (KeyRAG Porter FTS5) | C SQLite FTS5 | 0 MB | 69.33% | 82.38% | 32.90% | 1.8–6.2 ms / 4.8–11.5 ms |
Dense Only ( | C | 7.4 MB | 65.64% | 79.97% | 31.28% | 4.2–6.1 ms / 4.6–8.7 ms |
| 22M Transformer (PyTorch/ONNX) | 80 MB | 65.29% | 82.29% | 31.83% | ~25–60 ms |
Honest Ablation Note (Why We Cut MS-MARCO Cross-Encoders): We tested
cross-encoder/ms-marco-TinyBERT-L-2-v2(17 MB) on top of KeyRAG. It dropped SciFactnDCG@10from 72.60% → 69.96% (-2.64%) and NFCorpus from 35.23% → 34.99% while slowing queries 40× (399 ms P50). Web-trained MS-MARCO cross-encoders do not transfer to scientific corpora—so KeyRAG stays lean, fast, and purely adaptive-hybrid by default.
Native Research-Paper PDF Speed (C++ PDFium)
Paper (arXiv) | Layout | Parse Time | Throughput | Quality |
Attention Is All You Need (15 pages) | 1-col NeurIPS | 153.9 ms | 97.4 pages/sec |
|
BERT (16 pages) | 2-col ACL/NAACL | 122.2 ms | 130.9 pages/sec |
|
RAG (19 pages) | 1-col NeurIPS | 92.7 ms | 204.9 pages/sec |
|
All 3 papers (50 pages, 283 chunks) parse, chunk, embed (blink-8M/int8), and index into a single .krag file in 781 ms total.
Related MCP server: corpus-rag
Architecture (Clean, Readable, Native Speed)
AI CLIENTS: Claude Desktop · Cursor · Windsurf · VS Code · REST / OpenAPI · CLI
│ MCP stdio (JSON-RPC 2.0) │ Streamable HTTP (/mcp) │ REST (/v1/*)
▼
┌────────────────────────────── KeyRAG (Python shell) ───────────────────────────────┐
│ 1. Native C++ PDFium Reader (pypdfium2) │
│ 100% lossless · 2-column reading order · font-size titles · section tree │
│ 2. Single-File `.krag` Vault (C SQLite + C sqlite-vec) │
│ Live-only Porter FTS5 + fts5vocab IDF + int8 vectors (auto-IVF at >=15k rows) │
│ 3. Adaptive IDF-Weighted Convex Hybrid Search │
│ Zero-PyTorch mmap `blink-8M/int8` (7.4 MB) + query-adaptive BM25/Dense fusion │
└────────────────────────────── one file: papers.krag ───────────────────────────────┘Quickstart (2 Minutes)
1. Install
git clone https://github.com/KitiLab/KeyRAG.git
cd KeyRAG
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\Activate.ps1
pip install -e .2. Export the 7.4 MB blink-8M Retrieval Table (One-Time)
pip install -e ".[export]"
keyrag export-model --model minishlab/blink-8M3. Ingest & Search Real Research Papers
# Grab 3 classic open-access arXiv papers (Attention, 2-column BERT, RAG)
python scripts/fetch_papers.py
# Parse & index all 3 into ONE portable `papers.krag` file (~780 ms total!)
keyrag ingest papers/
# Search with exact verifiable page & section citations (~5 ms)
keyrag search "How does multi-head attention work and what is d_k?"
keyrag search "How does BERT pre-training use masked language modeling?"
keyrag docs
keyrag stats4. Plug Into Any AI Client (Universal MCP + OpenAPI)
# One-command auto-registration for Cursor, Claude Desktop, Windsurf, or VS Code:
keyrag --db papers.krag install --client cursor
keyrag --db papers.krag install --client claude-desktop
# Or start Streamable HTTP MCP (/mcp) + REST (/v1/*) + OpenAPI (/openapi.json):
keyrag --db papers.krag serve --http --port 87655. Reproduce the Public BEIR Benchmarks & Charts
python bench/run_beir.py --dataset scifact
python bench/run_beir.py --dataset nfcorpusRepository Structure
KeyRAG/
├── keyrag/
│ ├── pdf.py # Native C++ PDFium paper reader (2-col, font titles, sections, hyphen repair)
│ ├── embed.py # Vendored WordPiece + 7.4 MB mmap int8 table (`blink-8M`) + IVF k-means
│ ├── vault.py # Single-file `.krag` SQLite + live Porter FTS5 + fts5vocab + sqlite-vec
│ ├── search.py # Adaptive IDF-Weighted Convex Hybrid search + token_budget packing
│ ├── mcp_server.py # Zero-dependency MCP stdio + Streamable HTTP + REST + OpenAPI server
│ ├── rerank.py # Optional pure-NumPy cross-encoder (for ablations)
│ └── cli.py # `keyrag` CLI
├── bench/ # Reproducible BEIR runner + exact TREC metrics + zero-dep SVG charts
├── scripts/ # `fetch_papers.py` arXiv downloader
├── tests/ # 11 fast unit & integration tests
└── .github/workflows/ # GitHub Actions CI across Linux & macOSLicense
MIT — Built by KitiLab (hello.kitilab@gmail.com).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Self-hosted AI workspace: semantic RAG document search, long-term memory, and AI chat via MCP.
PDF AI for your own documents: ask from any MCP client and get answers that cite the source.
Query your own PDFs and documents from any MCP client. Every answer cites the page it came from.
Personal knowledge base MCP server with semantic search, auto-categorization, metadata extraction
Related MCP Servers
- AlicenseAqualityDmaintenanceA local-first MCP server that ingests PDFs, extracts structure, and provides semantic search and sequential navigation tools for AI clients to query and learn from documents.10MIT
- AlicenseNot gradedqualityBmaintenanceMCP server for local RAG over personal notes, PDFs, and documents, enabling plain-English querying and hybrid search with multi-hop context expansion.MIT
- AlicenseAqualityBmaintenanceLocal-first RAG MCP server that indexes local documents and provides hybrid search (semantic + keyword) with file ingestion, URL fetching, and a CLI, keeping data on-device.1259MIT
- FlicenseNot gradedqualityDmaintenanceA fully local MCP server that imports Markdown, PDF, and web pages into a running knowledge base, providing hybrid search and document retrieval via authenticated Streamable HTTP for Codex and DeepSeek agents.-