ragdag is a flat-file knowledge graph engine with three interfaces:
- A Bash CLI (
./ragdag) - A Python SDK (
import ragdag) - Server adapters (FastAPI HTTP + FastMCP)
It stores everything in a local .ragdag/ directory (chunks, edges, config, and processing metadata) and keeps the workflow simple: ingest files, search, ask, inspect graph links, and maintain store integrity.
ragdag- CLI entrypoint scriptlib/*.sh- Bash command implementationssdk/ragdag/- Python SDK (RagDag)engines/- embedding/search/LLM helpersserver/- HTTP API and MCP servertests/- pytest and bats test suitesdocs/- project documentation
ragdag uses a multi-stage search pipeline:
- BM25 keyword scoring — proper term frequency saturation and inverse document frequency weighting over flat
.txtfiles - Vector similarity — cosine similarity over embedded chunks (OpenAI or local sentence-transformers)
- Reciprocal Rank Fusion (RRF) — combines keyword and vector ranked lists using rank-based fusion (k=60), robust to score distribution skew
- Cross-encoder reranking (optional) — re-scores top candidates with a cross-encoder model for higher precision. Enable with
ragdag config set search.rerank true
Use --explain to see per-result score breakdown (BM25, vector, RRF contributions).
./ragdag init
./ragdag add ./docs
./ragdag search "knowledge graph" --top 5
./ragdag search "knowledge graph" --explain # show score breakdown
./ragdag search "knowledge graph" --rerank # enable cross-encoder reranking
./ragdag ask "What does this project do?" --no-llm
./ragdag graphimport ragdag
dag = ragdag.init(".")
dag.add("./docs")
results = dag.search("knowledge graph", mode="hybrid", top=5)
results = dag.search("knowledge graph", explain=True) # score breakdown in r.explain
answer = dag.ask("What does this project do?", use_llm=False)Primary commands exposed by ./ragdag:
init,add,search,askgraph,neighbors,trace,relate,linkconfig,serve,verify,repair,gc,reindex
Run ./ragdag help for full command and flag details.
Implemented in server/api.py.
GET /healthPOST /addPOST /searchPOST /askGET /graphGET /neighbors/{node_path}POST /linkGET /trace/{node_path}POST /relate
Implemented in server/mcp.py.
Tools:
ragdag_searchragdag_askragdag_addragdag_graphragdag_neighborsragdag_trace
Install editable package with extras as needed:
python3 -m pip install -e ".[all]"For testing workflows and commands, see docs/TESTING.md.