TreeDB for Agents · MCP + Pi

Commit-exact code search, AST symbols, and memory in one static binary · 47 MiB idle RAM.

Pass ref=<sha> to verify your exact feature-branch commit in memory — no JVM, no ClickHouse cluster, no stale-index drift.

$curl -fsSL https://treedb.dev/install.sh | sh
vs. git grep + read_file
14.5× fewer tokens
19,228 vs. 279,081 est. tokens · 14/15 hit@1
vs. XERJ Memory
18.3×–26× less RAM
153 MiB vs. 2.73 GiB RSS · 47 MiB idle daemon
Linux v6.12 Phrase
200×–479× faster
2.3 ms vs. 454 ms exact phrase p50
BEIR Retrieval
6 / 6 nDCG@10 wins
Lexical + Hybrid sweep · 24.4× faster FiQA p50
Why Agents Distrust Search

Feature branches move faster than background indexers.

When an agent works three commits ahead of main in a git worktree, ordinary RAG/MCP servers silently return symbols from the wrong commit — forcing agents back to slow, context-bloating read_file loops.

treedb-repo-mcp solves this fail-closed: pass ref="HEAD" (or any commit SHA). It computes the exact git diff-tree delta against the clean indexed base, masks modified paths, overlays commit-exact git cat-file blobs in RAM, and proves it in every response.

// Tool call: find_symbol({ repo: "snissn/gomap", ref: "deadbeef2", name: "OpenVectorIndexSearcher" })
{
  "snapshot": {
    "verified_commit": "deadbeef291c04a8e71f3b2094c8e110a94f102c",
    "base_commit":     "6d962db6bf9e5d681c5a8f63e5b9f78e14aa4f87",
    "overlay_files":   3,
    "drift":           false
  },
  "results": [
    {
      "path": "TreeDB/collections/vector_index_search.go",
      "kind": "func",
      "start_line": 84,
      "end_line": 129
    }
  ]
}
// Recall architectural decisions — automatically warns when linked code changed!
// Tool call: memory_recall({ query: "batch bypass threshold", ref: "HEAD" })
{
  "memories": [
    {
      "kind": "decision",
      "title": "Link batch bypass threshold to FlushThreshold",
      "linked_paths": ["TreeDB/caching/db.go"],
      "linked_commit_sha": "7cf512a...",
      "stale_code_warning": true,
      "changed_paths": ["TreeDB/caching/db.go"]
    }
  ]
}
# ~/.config/treedb-mcp/repos.toml — one daemon across all active repos
http_addr = "127.0.0.1:7337"

[defaults]
git_poll_interval = "60s"
github_poll_interval = "60s"

[[repos]]
name = "snissn/gomap"
path = "/Users/dev/snissn/gomap"

[[repos]]
name = "snissn/physics"
path = "/Users/dev/snissn/physics"
Empirical Proof · Zero Embeddings Required

14.5× fewer context tokens. 95%–98% of hybrid RAG wall time is embedding overhead.

Out of the box, treedb-repo-mcp runs pure lexical BM25F + Block-Max WAND exact phrase + pure-Go AST symbols with zero external models. Optional GPU embeddings plug in via any OpenAI-compatible endpoint when needed.

A/B

Agent Token-Diet Suite (15 Tasks)

Measured using exact production indented MCP JSON responses against git grep + whole-file reads across AST definitions, code search, phrase archaeology, and historical tag overlays.

-93.1% tokens19,228 vs. 279,081 (top-3 read) · 14/15 hit@1
LEX

Linux v6.12 & Rust Exact Phrase

Streaming Block-Max WAND phrase verification and code-aware camelCase/snake_case tokenization under durable Command WAL.

200×–479× faster2.3 ms vs. 454 ms phrase · 204 MiB vs. 5.21 GiB RSS
HYB

BEIR Retrieval Quality (NFCorpus, SciFact, FiQA)

6-for-6 Lexical and Hybrid nDCG@10 sweep against xerj v1.0.0-rc.105 using the identical local GPU BAAI/bge-m3 embedding server.

24.4× faster p5065.1 ms vs. 1,588 ms on FiQA-2018 (57.6k docs)
Corpus TreeDB Lexical (Default, No GPU) TreeDB Hybrid (bge-m3 GPU) Added Hybrid Overhead XERJ Lexical → Hybrid
Linux Kernel Featherweight (7.1 MiB, 284 files) 1.78 s (12.4 MiB, 2.3 ms p50) 82.05 s (3,052 embeds) 97.8% 5.96 s → 91.27 s (17,774 embeds)
Linux Kernel Welterweight (182.6 MiB, 21.6k files) 57.98 s (294.6 MiB, 6.2 ms p50) 2,177.7 s (~1.03 GiB RSS) 97.3% 81.30 s → 2,395.7 s (DNF @ 6–8 GiB cap)
BEIR FiQA-2018 (57,638 docs) 23.00 s (122.6 MiB, 18.7 ms p50) 433.41 s (65.1 ms p50) 94.7% 2.81 s → 451.14 s (1,588 ms p50)

Honest trade-offs: XERJ ingests small lexical-only BEIR JSONL corpora faster (1.1–2.8 s) and leads warm cached single-index BM25 QPS at 183 MiB. Full breakdown on /benchmarks.

30-Second Harness Setup

Drop into Claude Code, Pi, Codex, or Cursor.

Or paste one line into any coding agent and let it configure your workspace automatically via llms.txt:

Follow https://treedb.dev/llms.txt to install and configure treedb-repo-mcp for this workspace.
# Install official Pi extension (auto-HEAD ref pinning, [STALE CODE] memory badges, OTel spans)
curl -fsSL https://treedb.dev/install.sh | sh
pi install npm:@snissn/pi-treedb

# Inside Pi: inspect session query & drift telemetry
/treedb-stats
# Install binary, auto-configure MCP + directive, and index workspace
curl -fsSL https://treedb.dev/install.sh | sh
treedb-repo-mcp setup --client claude
treedb-repo-mcp repo add "$(pwd)"
treedb-repo-mcp sync --config ~/.config/treedb-mcp/repos.toml
# Install binary & auto-configure ~/.codex/config.toml (TOML) + ~/.codex/AGENTS.md
curl -fsSL https://treedb.dev/install.sh | sh
treedb-repo-mcp setup --client codex
treedb-repo-mcp repo add "$(pwd)"
treedb-repo-mcp sync --config ~/.config/treedb-mcp/repos.toml
# Install binary & auto-configure Antigravity (~/.gemini/config/mcp_config.json) / Cursor
curl -fsSL https://treedb.dev/install.sh | sh
treedb-repo-mcp setup --client antigravity,cursor
treedb-repo-mcp repo add "$(pwd)"
treedb-repo-mcp sync --config ~/.config/treedb-mcp/repos.toml
Recommended Agent Directive (AGENTS.md / CLAUDE.md / GEMINI.md)
## TreeDB MCP Search & Memory Directive
- Prefer the `treedb` MCP tools FIRST before local recursive grep/rg or GitHub API pagination.
- Call `list_repos` first; prefer `find_symbol(defs_only=true, include_body=true)` for definitions, `search_code(response_mode="passage")` for code/docs, `phrase_search` for exact strings, and `search_github(exclude_bots=true)` + `get_github_thread` for issues/PRs. Pass `ref="HEAD"` for commit-exact verification.
- When NOT to use remote MCP: for uncommitted local edits, untracked files, or exact lines of a single local file you already have open to edit, read the local file directly (remote mirrors only index pushed commits; a local stdio daemon with fsnotify tracks live edits).
- For cross-session memory, call `memory_pack` at task start, `memory_retain` (with `linked_paths`/`linked_symbols`) for durable decisions/gotchas, and `memory_handoff` at session end.
# Note: treedb-repo-mcp also sends MCP protocol `instructions` automatically in `initialize`.