minirag
MCP server for a self-hosted RAG system that enables AI tools to search and retrieve grounded answers from locally ingested documents via MCP tools, with local embeddings and no API key required.
README
minirag
A self-hostable RAG system with no signup and no cost by default. Drop in your notes, specs, and docs; they get chunked and embedded locally; retrieve them through an MCP server your AI tools can call. Ships with an evaluation harness so retrieval quality is measured, not guessed.
Quick start
cp .env.example .env
docker compose up
# api: http://localhost:3000/health
No API key needed — embeddings run locally.
Try it now (without Docker)
pnpm install
pnpm ingest ./sample-context # dry-run: parse + chunk + report by doctype
Ingest your context
Point the CLI at any file or folder and pass --write:
pnpm ingest /path/to/your/notes --write
Subfolder names become doctypes automatically (spec/file.md → doctype spec), or pass
--doctype <name> explicitly. Re-running on the same content is idempotent — it won't duplicate
chunks.
How it works
files → chunk → embed → Postgres+pgvector → search → MCP tools → your AI client
↑
eval harness (measures retrieval quality)
Your context is organized by doctype (meeting-notes, spec, codebase, …) — folder names map to doctypes automatically, so retrieval can filter by type.
Stack
TypeScript end to end. Postgres + pgvector, local embeddings (Transformers.js, bge-small-en-v1.5), Fastify API, MCP server. All free, all self-hostable, one language.
Swapping the embedder
Local (default) is free and requires no signup. OpenAI/Voyage are opt-in behind the same
Embedder interface, for higher quality at the cost of an API key:
- Set
EMBEDDER=openai(orvoyage) and the matching API key in.env. - The vector dimension changes with the model, so old chunks won't match the new one — there's no
automated migration, clear and re-ingest:
docker compose exec db psql -U minirag -d minirag -c "TRUNCATE chunks, documents RESTART IDENTITY CASCADE;" pnpm ingest /path/to/your/notes --write - Re-run
pnpm eval runto confirm quality didn't regress.
The embedder id is stored per chunk; retrieval checks it against the active embedder at query time and refuses to mix models rather than silently corrupting search.
Status
Core pipeline (ingest, retrieve, eval, MCP) is complete and verified — see the docs/ for the full picture.
Docs
| Doc | What |
|---|---|
setup.html |
Quick-start setup guide (5 steps) |
docs/mcp-client-setup.md |
MCP server configuration for Claude Code/Cursor |
docs/project-overview.md |
Full overview, principles, doc index |
docs/architecture.md |
Diagram, data flow, schema, boundaries |
docs/eval-strategy.md |
How quality is measured |
Using with Claude Code
Procedural guides live as skills in .claude/skills/ (ingest, retrieve, eval) and are invoked on demand when a task matches. See docs/architecture.md for the architecture boundaries and working conventions.
MCP Server
Register the minirag MCP server with Claude Code:
claude mcp add-json minirag '{
"command": "pnpm",
"args": ["-C", "/path/to/minirag", "--filter", "@minirag/mcp", "start"],
"env": {
"DATABASE_URL": "postgresql://minirag:minirag@localhost:5432/minirag",
"EMBEDDER": "local",
"EMBEDDER_MODEL": "bge-small-en-v1.5",
"EMBEDDER_DIM": "384"
}
}' --scope project
This writes a project-scoped .mcp.json at the repo root. It bakes in your absolute repo path, so it's gitignored, not committed — each teammate runs the command above to generate their own. ~/.config/claude/mcp.json is not read by current Claude Code versions — there's no cwd field in the schema, so -C /path/to/minirag pins pnpm's working directory instead. After adding, run claude (or /mcp → reconnect) to approve and connect the server. See .mcp.example.json for the shape of the generated file.
See docs/mcp-client-setup.md for detailed setup instructions.
/minirag Command
Use the /minirag slash command to search the vector store and get grounded answers with citations:
/minirag how do I configure the embedder?
/minirag [spec] architecture decisions
/minirag [meeting-notes] who attended the sync?
The command calls the MCP search_context tool and returns answers grounded in retrieved chunks with source citations.
Contributing
pnpm lint && pnpm typecheckandpnpm eval run(fixture corpus, metrics must not regress) before opening a PR.- If you changed chunking/embedder/rerank, include the before/after eval delta in the PR.
- To add a doctype: add its chunking strategy in
packages/core(seedocs/architecture.md), then add golden cases inpackages/eval/golden/<name>.yaml. - See
docs/architecture.mdfor module boundaries:coredepends on nothing internal;ingest/retrievenever import each other;apiandmcpare the only entry points and never reimplement retrieval logic;evaltests the real MCP tools.
License
MIT — see LICENSE.
minirag depends on third-party open-source packages — almost all permissively licensed (MIT,
Apache-2.0, ISC, BSD), with one exception: a prebuilt libvips binary (LGPL-3.0-or-later,
transitively pulled in via the embedding library's image-handling dependency, never invoked by
minirag's own text-only pipeline) — and, at runtime, downloads pretrained embedding model weights
from Hugging Face (bge-small-en-v1.5 by default, MIT-licensed; all-MiniLM-L6-v2 as an
alternative, Apache-2.0-licensed). Neither model's weights are vendored in this repo. See
NOTICE for the attribution list and THIRD_PARTY_LICENSES.md
for full third-party license text, including why the LGPL dependency doesn't affect this project's
own MIT license.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。