Skip to content

Tool Pick|microindex-mcp — swap an agent's grep for an AST + vector index

Dec 5, 20265 min
TL;DRmicroindex-mcp is a local Tree-sitter AST + LanceDB vector index exposed as a two-tool MCP server. Install: run `make setup`, then `make index TARGET=/path/to/your-project`. It fixes agents burning tokens on grep sweeps that pull whole files into context just to find one function.

Look up & save

Loading dictionary…

中文版

Tool Info

FieldValue
Namemicroindex-mcp
TypeMCP server
GitHubingvar-soloma/microindex-mcp
Stars3 (less than a day old)
LanguagePython
LicenseMIT
Installmake setup && make index TARGET=/path/to/your-project

What Problem It Solves

You've probably watched an agent do this: ask it to find where a function gets called in a large repo, it runs grep -r, gets a dozen hits, and then reads every matched file in full into context — even though the answer was 20 lines inside a 400-line file. The bigger the file and the more hits, the more tokens that single exploration round burns. Worse, grep matches a string, not a code boundary, so the agent routinely drags in unrelated surrounding lines along with the part it actually needed.

microindex-mcp replaces both the search and the read with structured equivalents. At index time it parses the codebase with Tree-sitter, chunks it along semantic boundaries — functions, classes — capped at 1,500 characters, and embeds each chunk locally (default model all-MiniLM-L6-v2, fully offline, no API key) into LanceDB. At query time it exposes exactly two deliberately minimal MCP tools: search_code does semantic search and returns the most relevant chunks with file path and line range, and get_code_chunk retrieves the AST chunks for a known file instead of the whole file's contents. The README's own benchmark, run against examples/polyglot-mini (a mixed PHP + Vue 3 + Python project), reports roughly 59% fewer tokens than grep-plus-full-file-read and about 64% fewer than rg with a ±30-line window; the author also ran it against three private production codebases, where savings ranged from 76% to 99% — the bigger the repo, the bigger the win.

It's a fit for agents doing semantic exploration across a mid-to-large, multi-language repo (currently Python, TS/JS/TSX, PHP, and Vue 3 SFC are supported) — not for a quick edit to one or two files. It also supports a centralized mode: one shared MCP server backing multiple projects' own .lancedb_data, so you don't have to install a copy per repo.

Getting Started

Install

git clone https://github.com/ingvar-soloma/microindex-mcp.git
cd microindex-mcp

# 1. Create .venv (uses uv if available; CPU-only PyTorch by default on Linux,
#    skipping ~2.5GB of CUDA wheels)
make setup

# 2. Index the project you want to query; the vector store lands in
#    that project's .lancedb_data/
make index TARGET=/path/to/your-project

# 3. (optional) run the example benchmark to see Hit@5 and token savings
make bench

Remember to add .lancedb_data/ to that project's .gitignore.

Basic Usage

Register it as a stdio MCP server:

{
  "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"
      }
    }
  }
}

The agent then only ever sees two tools, and what comes back is a line-numbered code chunk, not an entire file:

search_code(query="webhook retry logic", top_k=5)
→ [1] src/jobs/webhook_retry.py:42-68 (function_definition, score=0.81)
  ...(AST chunk content)...

get_code_chunk(file_path="src/jobs/webhook_retry.py", node_type="class")
→ returns only the AST chunks in that file matching node_type

Advanced Usage: one shared MCP across projects, auto-reindex on commit

Register a "global" server without INDEXER_DATA_DIR and let the agent pass project_dir itself to switch between projects, instead of opening a separate server entry per repo:

search_code(query="...", project_dir="/path/to/active-repo")

To keep the index fresh automatically, add a post-commit hook in the target project (adapted from the README's example):

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-commit
How microindex-mcp replaces grep with an AST vector index
How microindex-mcp replaces grep with an AST vector indexAt index time, Tree-sitter chunks the codebase and stores vectors in a local LanceDB; at query time, the agent only gets relevant chunks through two MCP tools, instead of reading whole files or running grep. Index time (one-off build) Query time (per agent call) Your codebase Python / TS / PHP / Vue Indexer AST + vector index LanceDB .lancedb_data (local) Coding agent Claude Code / Cursor MicroIndex MCP search_code・get_code_chunk parse query

Simplified, drawn from ingvar-soloma/microindex-mcp's README (2026-12-04); omits embedding-provider switching and per-language parsing details.

Compared to Existing Approaches

microindex-mcpplain grep/rgcodebase-memory-mcp (knowledge graph)Cursor / Sourcegraph Cody (built-in indexing)
Unit returnedAST chunk (function/class)matched lines, full file read requiredgraph node + call chainchunks, protocol not exposed
Local embedding, no API keyYes (default all-MiniLM-L6-v2)No embedding neededNeeds separate setupNo (tied to each vendor's service)
Number of MCP tools2 (deliberately minimal)0 (not an MCP tool)15Not exposed as a standalone MCP
Cross-file call-chain analysisNo (chunk-level semantic search only, for now)NoYes (call graph, cross-service calls)Partial
MaturityJust released, 3 starsBuilt into every shell43,000+ starsCommercial product, already at scale

Caveats

  • The v1.0-lite README is upfront about its accuracy ceiling. Pure dense embeddings miss top-5 on roughly 10-20% of queries involving exact camelCase identifiers, dot-separated event names (chat.message.sent), or methods that lost their parent-class context when split into chunks. The author's planned v2.0-hybrid adds BM25 hybrid search to close that gap, but it's not there yet.
  • The index doesn't update itself. You either rerun make index by hand after changes, or wire up the post-commit git hook from the Advanced Usage section above. Forget to reindex, and the agent is searching stale code.
  • It's one day old with 3 stars. It hasn't been through community scrutiny or issue-driven hardening yet. Against codebase-memory-mcp — the 43,000+ star knowledge-graph tool covering the same "stop grepping" territory — this is a much younger project; run make bench-repo against your own repo before rolling it out to a team.
  • The license text is slightly nonstandard. GitHub's automatic license detector reports NOASSERTION (likely because the LICENSE file appends a non-binding "attribution request" paragraph after the standard MIT text, which seems to confuse the detector), but the file itself is the standard MIT License in full — the terms are MIT, just with an extra, legally non-binding attribution ask tacked on.

Today's Takeaway

Two "cut the agent's token bill" tools showed up months apart solving the same underlying problem differently: September's codebase-memory-mcp uses a knowledge graph to remember cross-file call relationships, and today's microindex-mcp uses AST-plus-vector chunk search. Neither is really competing on model size — both are betting on precomputing the codebase's structure once so the agent never has to re-derive it on every query. grep isn't expensive because it's slow; it's expensive because it carries no structural information, so it compensates by reading more. Both tools trade indexing time for query time, so each exploration pulls back only the few dozen lines that actually matter.

References