MicroIndex MCP
Summary: This MCP server lets an AI agent query an indexed codebase through two read-only retrieval tools.
search_code: run semantic AST code search over indexed chunks using a requiredqueryand optionaltop_k(default 5).get_code_chunk: retrieve indexed AST chunks for a knownfile_path, optionally filtered bynode_type, instead of reading whole files.Both tools return a string result and are intended to be used before
grepor full-file reads to reduce token usage.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MicroIndex MCP Find where JWT authentication is implemented and show me the relevant code chunk"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MicroIndex MCP (v1.0-lite)
Local AST + Vector Code Index & Minimalist FastMCP Server for ~90%+ AI Token Savings.
Stop letting coding agents burn 10,000+ tokens grepping and reading entire files just to find one method. MicroIndex parses your codebase with Tree-sitter ASTs, embeds compact structural chunks locally into LanceDB, and pairs a 2-tool FastMCP server (search_code, get_code_chunk) with Agentic Governance rules.
Deep-Dive & Benchmarks: Read the full architectural breakdown, Mermaid diagrams, and
pytestquality gates on my blog: Why I Banned AI Agents from Using Grep: AST Indexing, Governance Rules, and 90%+ Token Savings.
graph LR
Indexer["src/indexer.py<br/>(Incremental CLI)"] -->|AST Chunking <= 1500 chars| TS["Tree-sitter<br/>.py / .ts / .tsx / .js / .php / .vue"]
Indexer -->|Local or Cloud Embeddings| Emb["all-MiniLM-L6-v2 (384d)<br/>or Ollama / OpenAI / Gemini"]
Indexer -->|Write Vectors| LDB[("<project>/.lancedb_data<br/>+ index_state.json")]
Agent["AI IDE / CLI Agent<br/>(Claude Code, Cursor, Antigravity)"] -->|MCP stdio + PYTHONUNBUFFERED=1| Server["src/mcp_server.py<br/>(FastMCP: search_code, get_code_chunk)"]
Server -->|Query Embed| Emb
Server -->|INDEXER_DATA_DIR| LDBFor AI Agents: Auto-Setup Protocol
Want your AI coding assistant (Claude Code, Cursor, Antigravity, Codex, Gemini CLI) to set up microindex-mcp end-to-end — including indexing, MCP config, Agentic Governance rules, and post-commit git hooks?
Point your agent to templates/AI_SETUP_PROMPT.md (or paste the prompt inside it into your chat).
Related MCP server: Glancey
5-Minute Quickstart (For Humans)
# 1. Create .venv and install dependencies (uses uv automatically if available)
make setup
# 2. Index examples/polyglot-mini (PHP + Vue 3 + Python) and run benchmark
make bench
# 3. Run pytest quality gates (Hit@5, MRR, Token Savings, Latency, Incremental 0-reencode)
make testLinux CPU-only by default: On Linux,
make setupinstalls CPU-only PyTorch automatically (CUDA=0) to skip ~2.5 GB of CUDA wheels. Runmake setup CUDA=1if you want GPU/CUDA wheels.Token-Saving Tip: Prefer running
make setup,make bench, and initialmake indexon large repositories directly in your own terminal rather than through an AI agent — you'll see live progress bars and avoid burning agent context tokens on long install/indexing logs.
Benchmark Results (examples/polyglot-mini/)
Measured via make bench using tiktoken (o200k_base) against two baselines across 6 queries (semantic, symbol, cross_stack):
Baseline 1 (
Grep + Full-File): keyword grep across files, reading every matched file in full.Baseline 2 (
rg + Targeted ±30L):rg -nsearch output (capped at 50 lines) + reading±30-line targeted windows (up to 3 merged slices per file) across the top-5 ranked files.
Provider: local (all-MiniLM-L6-v2) | Files: 4 | AST Chunks: 44 | Queries: 6
Metric | Value |
Hit@5 (MicroIndex) |
|
Hit@5 ( |
|
MRR |
|
Avg Chunk Precision |
|
Latency (Avg / P50 / P95) |
|
Avg Tokens / Query (MicroIndex) |
|
Avg Tokens / Query (Grep + Full-File) |
|
Avg Tokens / Query ( |
|
Total Tokens (AST vs Full / |
|
Token Savings vs Grep + Full-File |
|
Token Savings vs |
|
Note:
examples/polyglot-minionly contains 4 small files (~90 lines each). On larger multi-hundred-file repositories, fixedtop_k=5AST retrieval typically reaches 92–99% token savings vs Full-File and 76–90% vsrg+ Targeted ±30L.
Query ID | Category | Hit@5 |
| RR | Prec | Latency | AST Tok | Full Tok |
| vs Full | vs |
|
| PASS | PASS | 1.00 | 0.40 | 10.5 ms | 386 | 1145 | 1132 | 66.3% | 65.9% |
|
| PASS | PASS | 1.00 | 0.40 | 10.9 ms | 882 | 2902 | 3063 | 69.6% | 71.2% |
|
| PASS | PASS | 1.00 | 0.20 | 10.4 ms | 462 | 1145 | 670 | 59.6% | 31.0% |
|
| PASS | PASS | 1.00 | 0.20 | 10.5 ms | 878 | 1124 | 898 | 21.9% | 2.2% |
|
| PASS | PASS | 1.00 | 0.20 | 9.9 ms | 651 | 1778 | 2940 | 63.4% | 77.9% |
|
| PASS | PASS | 1.00 | 0.40 | 10.6 ms | 891 | 2053 | 2777 | 56.6% | 67.9% |
Real-World Production Case Studies (v1.0-lite, Anonymized)
Tested on three private production codebases (plus microindex-mcp itself) using developer-style queries synthesized from recent git commits (local all-MiniLM-L6-v2 embeddings on CPU), comparing MicroIndex AST+Vector against both Grep + Full-File Read and rg -n + Targeted ±30L Read:
Codebase | Files / AST Chunks | Hit@5 (AST / | MRR | Avg Latency | Tokens / Query (AST vs Full / | Savings vs Full-File | Savings vs |
Monorepo A (PHP + Vue 3 + Python) |
|
|
|
|
|
|
|
Service B (PHP + Event-Driven) |
|
|
|
|
|
|
|
Service C (Python / AI Agent) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Honest
v1.0-liteDiagnostic (Whyv2.0-hybridExists): Even with natural developer queries, ~10–20% of commit queries miss top-5 when pure denseall-MiniLM-L6-v2embeddings encounter exactcamelCaseidentifiers, dot-separated event names (chat.message.sent), or split methods that lost their parent classScopeheader. That empirical ceiling is exactly whatv2.0-hybrid(ASTScope/Callspassport + LanceDB BM25+Dense RRF) andv3.0-contextual(System-1 Cross-Encoder reranking) are designed to solve.

Install Once, Index Any Project (Own-Project Deployment)
You do not need to copy src/ into your repositories. Install microindex-mcp once in a shared folder and point it at any codebase using TARGET and INDEXER_DATA_DIR:
1. Index Your Repository
# Stores LanceDB + index_state.json inside /path/to/your-project/.lancedb_data
make -C /path/to/microindex-mcp index TARGET=/path/to/your-projectAdd .lancedb_data/ to your project's .gitignore.
(Optional) Add a 2-line shortcut to your own project's Makefile:
index:
/path/to/microindex-mcp/.venv/bin/python -u -m src.indexer --project "$(CURDIR)" --db-dir "$(CURDIR)/.lancedb_data"Auto-Reindex on Git Commit (Git Hooks)
To keep .lancedb_data fresh automatically after every commit without blocking git commit, add an executable .git/hooks/post-commit hook in your target repository:
cat <<'EOF' > .git/hooks/post-commit
#!/usr/bin/env bash
PROJECT_ROOT="$(git rev-parse --show-toplevel)"
HF_HUB_OFFLINE=1 /path/to/microindex-mcp/.venv/bin/python -u -m src.indexer \
--project "$PROJECT_ROOT" \
--db-dir "$PROJECT_ROOT/.lancedb_data" >/dev/null 2>&1 &
EOF
chmod +x .git/hooks/post-commit2. Connect the MCP Server to Your IDE / CLI Agent
Register a stdio MCP server pointing to the shared microindex-mcp .venv and set INDEXER_DATA_DIR to your project's .lancedb_data. See templates/mcp_config.example.json for ready-to-paste configs:
{
"mcpServers": {
"MicroIndex": {
"command": "/path/to/microindex-mcp/.venv/bin/python",
"args": ["-u", "/path/to/microindex-mcp/src/mcp_server.py"],
"env": {
"PYTHONUNBUFFERED": "1",
"HF_HUB_OFFLINE": "1",
"INDEXER_DATA_DIR": "/path/to/your-project/.lancedb_data"
}
}
}
}Tip for multiple repositories (avoiding MCP context bloat):
Centralized Single Global MCP (Recommended for Antigravity / Global Hosts): Register one
MicroIndexserver withoutINDEXER_DATA_DIR(seecentralized_global_mcp_zero_bloatintemplates/mcp_config.example.json), and let your agent passproject_dir="/path/to/active-repo"tosearch_code/get_code_chunk. If that repo isn't indexed yet,search_codeautomatically instructs the agent to ask you before runningmake index— zero extra tool schemas in your system prompt!Project-scoped hosts (Claude Code
.mcp.json, Cursor.cursor/mcp.json, VS Code.vscode/mcp.json) only load the server when that project is open.Zero-MCP CLI mode (for tiny repos): skip MCP altogether and query any local
.lancedb_datavia CLI/Python whenever needed:/path/to/microindex-mcp/.venv/bin/python -c "from src.indexer import search_index; print(search_index('/path/to/your-project', 'your query', top_k=5))"
3. Benchmark Your Own Repository (Auto-Generated from Git History)
Want to measure Hit@5 and token savings on your own codebase in 60 seconds? benchmarks/generate_queries.py samples random non-merge commits and builds a query suite compatible with make bench:
# 1-command benchmark on any repository (auto-generates queries + indexes + saves report)
make bench-repo TARGET=/path/to/your-project COUNT=10
# Add SHARE=1 to also generate an anonymized report, LinkedIn/X post text, and a 1200x630 SVG card:
make bench-repo TARGET=/path/to/your-project COUNT=10 SHARE=1
# Or generate a share card from any existing benchmark JSON report:
make share REPORT=benchmarks/reports/.../local__all-MiniLM-L6-v2_....json
# Or synthesize natural-language queries with a local Ollama model:
make bench-repo TARGET=/path/to/your-project COUNT=10 GEN_PROVIDER=ollama GEN_MODEL=llama3.1:8bPrivacy Warning: Using cloud LLM providers (
GEN_PROVIDER=openaiorGEN_PROVIDER=gemini) sends sampled commit messages and diff snippets to that external API (an interactive confirmation prompt is shown before any request). For private/NDA repositories, useoffline-template(default) orollama.
4. End-to-End Task Benchmark (pass@1 + Session Tokens)
Measure real multi-file task completion (pass@1, total session tokens, peak context, turns, wall-clock time, and estimated USD) comparing rg + Targeted (±30L) against microindex-mcp across clean, isolated git worktree checkouts (covering 4 multi-file code tasks and 3 AST-blind-spot config/doc/schema tasks):
# Offline dry-run smoke test ($0 API cost)
make e2e-eval E2E_AGENT_PROVIDER=mock E2E_REPEATS=1
# Live evaluation with Gemini / OpenAI / Anthropic / Ollama
GEMINI_API_KEY=... make e2e-eval E2E_AGENT_PROVIDER=geminiSee docs/e2e-eval.md for all agent providers, E2E_* Makefile variables, CLI flags, and the custom task JSON schema.
AI & Embedding Providers
Embedding Providers (src/embeddings.py)
Switch providers anytime via CLI flags (--provider, --model) or environment variables (MICROINDEX_EMBEDDING_PROVIDER, MICROINDEX_EMBEDDING_MODEL). If you change providers, MicroIndex automatically detects the mismatch in index_state.json and rebuilds vectors cleanly.
Provider | Env / CLI Value | Default Model | Required Env Vars | Notes |
Local (default) |
|
|
| 100% free, private, works offline once cached |
Ollama |
|
|
| Local GPU/CPU Ollama server |
OpenAI / Compatible |
|
|
| Works with OpenAI, OpenRouter, LM Studio, vLLM |
Google Gemini |
|
|
| Gemini Generative Language API |
Example with Ollama:
make index TARGET=/path/to/your-project PROVIDER=ollama MODEL=nomic-embed-textSupported AI Hosts (MCP Clients)
src/mcp_server.py uses standard FastMCP stdio and exposes 2 minimalist tools (search_code, get_code_chunk) to avoid tool-schema overhead across any MCP-compatible host:
Claude Code (
.mcp.json)Cursor (
.cursor/mcp.json)Google Antigravity (
~/.gemini/antigravity/mcp_config.json)VS Code Copilot / Windsurf (
.vscode/mcp.json)Codex CLI / Gemini CLI (global MCP config)
Setting Up Agent Rules & Skills
Indexing alone is only half the win — Agentic Governance forces your AI assistant to query the AST index before calling grep or read_file:
templates/AGENT_RULES.md— 7 strict rules banning blind full-file scans and noisy terminal floods.templates/SKILL.md— 4-step context-preparation runbook (search_code→get_code_chunk→ boundedstart_line..end_line→ edit & re-index).docs/cli-output-compression.md—rtk(Rust Token Killer) +scripts/mi-runfallback to cut noisy terminal output by 70%+ (--fullto bypass).
AI Client | Where to Copy | Where to Copy |
Claude Code | Append to |
|
Cursor |
|
|
Google Antigravity |
|
|
VS Code Copilot |
|
|
Codex / Gemini CLI | Append to |
|
Adding a New Language in 60 Seconds
Out of the box, MicroIndex supports Python (.py), TypeScript / JavaScript / TSX / JSX (.ts, .tsx, .js, .jsx, .mjs, .cjs), PHP (.php), and Vue 3 SFC (.vue, two-stage HTML + TypeScript parsing with exact line_offset).
Adding Go, Rust, Java, C#, Ruby, or Kotlin takes ~15 lines of Python:
Manual step-by-step guide: see
CONTRIBUTING.md.One-shot AI generator prompt: copy
templates/ADD_LANGUAGE_PROMPT.mdinto your AI assistant to generate, register, and wire tests for any Tree-sitter grammar automatically.
How MicroIndex Compares (Architecture Matrix)
Different tools optimize for different parts of the AI coding workflow. Here is an honest architectural comparison:
Approach / Tool | Retrieval Mechanism | Index Cost & Latency | Privacy / Cost per Query | Best Fit / Trade-offs |
| Local Tree-sitter AST + LanceDB Hybrid ( | Fast incremental CPU index; ~10–25 ms warm query | 100% local, $0/query | Cross-stack ( |
| Indexless structural AST pattern matching | Zero index; fast CLI scan | 100% local, $0/query | Exact syntactic refactors & pattern queries; no semantic/natural-language search |
| Static declarative | Manual / generated static file | 100% local, $0/query | Great for mixed repos (PDFs/schemas/docs); scales worse across thousands of methods |
| Indexless on-the-fly search via System-1 LLM judge | Zero index; LLM-latency per query | Calls external/local LLM per search | Zero index maintenance; higher per-query cost/latency and sensitive to synonyms |
| Static call-graph stored in SQLite | Local graph build | 100% local, $0/query | Ideal for PR blast-radius analysis; blind to cross-stack HTTP/API boundaries |
| Managed cloud code-graph SaaS | Cloud sync required | $5–$24/seat/mo; code leaves machine | Turnkey hosted team graph; requires uploading source code to third-party cloud |
Roadmap
v1.0-lite(Current): Local Tree-sitter AST chunking + LanceDB dense vector search +AGENT_RULES.md.v2.0-hybrid(Next): DeterministicScope:AST headers + LanceDB Hybrid BM25/Dense search + safe config/env indexing with secret redaction.v3.0-contextual: Two-stage retrieval with optional local cross-encoder reranking + SWE-bench-stylepass@1evaluation suite.Community: Expanding
src/languages/(Go, Rust, Java, C#, Kotlin) and OSS benchmarks viabenchmarks/fetch_oss_target.sh.
License & Attribution
Released under the MIT License.
Repository: github.com/ingvar-soloma/microindex-mcp
Author: Ihor Solomianyi (ingvarsoloma.dev | LinkedIn)
Open-Source Attribution: If
microindex-mcpsaves you tokens, speeds up your team, or inspires your own tooling, please keep a link back to the original repository and credit the author when sharing benchmarks or derivatives.
Need help rolling this out across a larger team or monorepo?
microindex-mcp is MIT-licensed and free to use. If you're running a multi-team monorepo and want help setting up shared CI base snapshots, custom language/DSL extractors, or automated token-budget gates in your CI/CD pipeline, feel free to reach out via ingvarsoloma.dev or LinkedIn.
Available Tools
2 toolsget_code_chunkGet Code ChunkC
Retrieve indexed AST chunks for a known file path instead of reading the whole file.
Inputs: file_path (required), node_type. Returns: result
search_codeSearch CodeB
Semantic AST code search. Always call this before reading files or running grep.
Inputs: query (required), top_k. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 2 tools
The two tools target different access patterns: search_code is query-driven semantic search, while get_code_chunk is path-driven retrieval of known files. Boundaries are mostly clear, though a caller may occasionally be unsure whether to use search_code results or fetch chunks directly for a file it already knows.
Both names use a consistent snake_case verb_noun pattern (search_code, get_code_chunk). The verbs accurately reflect their actions with no stylistic mixing.
Two tools is thin for a code-index server; the surface feels minimal and leaves no room for index management or inspection operations. It is focused but borderline under-scoped.
The read path is covered (find code, fetch chunks), but there are notable gaps: no indexing/refresh trigger, no index status or listing of indexed files/repos, and no symbol or metadata lookup. Agents can work around these only if the index is populated externally.
Maintenance
Related MCP Connectors
Code intelligence for coding agents: semantic, AST, graph, and full-text search. 279+ languages.
Shared memory for coding agents. Stop re-explaining your codebase every session.
Token-efficient search for coding agents over public and private documentation.
Codebase intelligence for AI agents — dead code, blast radius, ownership.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceIndexes codebases and lets AI agents retrieve precise code snippets (functions, classes, routes) instead of reading entire files, reducing token usage and improving accuracy.18 npm7MIT
- AlicenseNot gradedqualityDmaintenanceAdds semantic code search to AI coding agents, enabling natural language queries across entire codebases to retrieve relevant code chunks, saving tokens and providing deep context.6 npm1MIT
- AlicenseAqualityBmaintenanceEnables AI coding agents to retrieve only the specific code sections that answer their questions, drastically reducing context usage while running fully locally.11MIT
- AlicenseNot gradedqualityBmaintenanceEnables AI coding agents to search indexed local codebases through AST-aware chunks with BM25 retrieval and CPU reranking, returning whole functions, classes and types instead of arbitrary token windows. It also exposes file outlines, dependency impact radius, related-test mapping, index statistics and reindexing, so agents can navigate and assess blast radius before editing without reading entire files.1MIT