Skip to main content
Glama

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.

MicroIndex Benchmark Card

graph LR
    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 -->|AST Chunking <= 1500 chars| TS["Tree-sitter<br/>.py / .ts / .tsx / .js / .php / .vue"]
    Server -->|Local or Cloud Embeddings| Emb["all-MiniLM-L6-v2 (384d)<br/>or Ollama / OpenAI / Gemini"]
    Server -->|INDEXER_DATA_DIR| LDB[("<project>/.lancedb_data<br/>+ index_state.json")]

For AI Agents: Auto-Setup Protocol

Sharing this with your AI coding assistant? Paste the prompt below into Claude Code, Cursor, Antigravity, Codex, or Gemini CLI inside your target project — it will set up everything end-to-end.

Set up microindex-mcp for my current project:
1. Clone (or use existing) microindex-mcp at <PATH_TO_MICROINDEX_MCP> and run `make setup` if `.venv` does not exist.
2. Check which programming languages my current project uses. If any language is not yet in `src/languages/registry.py`, follow `templates/ADD_LANGUAGE_PROMPT.md` to add its Tree-sitter extractor first.
3. Index my current project with isolated storage:
   `<PATH_TO_MICROINDEX_MCP>/.venv/bin/python -u -m src.indexer --project "$(pwd)" --db-dir "$(pwd)/.lancedb_data"`
4. Add `.lancedb_data/` to my project's `.gitignore` (if not already present).
5. Configure the MCP server for my active IDE/agent using `templates/mcp_config.example.json` (set `INDEXER_DATA_DIR` to `$(pwd)/.lancedb_data`, keep `PYTHONUNBUFFERED=1` and `-u`).
6. Install `templates/AGENT_RULES.md` and `templates/SKILL.md` into the appropriate rules/skills directory for my IDE/agent.
7. Summarize the indexed file/chunk counts and verify `search_code` is ready.
  1. Bootstrap shared runtime once: if <microindex_dir>/.venv does not exist yet, ask the user to run make -C <microindex_dir> setup in their terminal (saves agent tokens and shows live download progress), or run it once without polling.

  2. Verify language coverage: inspect src/languages/registry.py (.py, .ts, .tsx, .js, .jsx, .mjs, .cjs, .php, .vue). Add missing Tree-sitter extractors via templates/ADD_LANGUAGE_PROMPT.md.

  3. Index target project cleanly: <microindex_dir>/.venv/bin/python -u -m src.indexer --project "<target_project>" --db-dir "<target_project>/.lancedb_data"

  4. Keep target git clean: ensure .lancedb_data/ is in <target_project>/.gitignore.

  5. Register MCP stdio server: wire "command": "<microindex_dir>/.venv/bin/python", "args": ["-u", "<microindex_dir>/src/mcp_server.py"], "env": {"PYTHONUNBUFFERED": "1", "HF_HUB_OFFLINE": "1", "INDEXER_DATA_DIR": "<target_project>/.lancedb_data"}.

  6. Enforce Agentic Governance: copy templates/AGENT_RULES.md and templates/SKILL.md into the host's rules/skills paths (see Setting Up Agent Rules & Skills).


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 test

Linux CPU-only by default: On Linux, make setup installs CPU-only PyTorch automatically (CUDA=0) to skip ~2.5 GB of CUDA wheels. Run make setup CUDA=1 if you want GPU/CUDA wheels.

Token-Saving Tip: Prefer running make setup, make bench, and initial make index on 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 a realistic Baseline (Grep + Full-File Read) agent workflow across 6 queries (semantic, symbol, cross_stack):

Provider: local (all-MiniLM-L6-v2) | Files: 4 | AST Chunks: 44 | Queries: 6

Metric

Value

Hit@5

1.00 (100.0%)

MRR

1.0000

Avg Chunk Precision

0.30 (30.0%)

Latency (Avg / P50 / P95)

9.1 / 8.7 / 9.5 ms

Avg Tokens / Query (MicroIndex)

691.7 tok

Avg Tokens / Query (Baseline)

1691.2 tok

Total Tokens (MicroIndex vs Baseline)

4150 vs 10147 tok

Token Savings vs Baseline

59.10%

Note: examples/polyglot-mini only contains 4 small files (~90 lines each). On larger multi-hundred-file repositories, fixed top_k=5 AST retrieval typically reaches 90–97% token savings.

Query ID

Category

Hit@5

RR

Prec

Latency

AST Tok

Base Tok

Saved

q1_semantic_webhook

semantic

PASS

1.00

0.40

10.7 ms

386

1145

66.3%

q2_semantic_budget

semantic

PASS

1.00

0.40

9.5 ms

882

2902

69.6%

q3_symbol_capture

symbol

PASS

1.00

0.20

8.2 ms

462

1145

59.6%

q4_symbol_anomaly

symbol

PASS

1.00

0.20

9.1 ms

878

1124

21.9%

q5_cross_stack_embeddings

cross_stack

PASS

1.00

0.20

8.5 ms

651

1778

63.4%

q6_cross_stack_telemetry

cross_stack

PASS

1.00

0.40

8.7 ms

891

2053

56.6%

Real-World Production Case Studies (v1.0-lite, Anonymized)

Tested on three private production codebases using 10 developer-style queries each, synthesized from recent git commits (GEN_PROVIDER=gemini, local all-MiniLM-L6-v2 embeddings on CPU):

Codebase (Anonymized)

Files / AST Chunks

Hit@5

MRR

Avg Precision

Avg Latency

Tokens / Query (AST vs Base)

Token Savings

Monorepo A (PHP + Vue 3 + Python)

329 / 3,838

0.80 (80%)

0.8000

0.14

14.7 ms

666.5 vs 60,666.7

98.90%

Service B (PHP + Event-Driven)

92 / 410

0.80 (80%)

0.7500

0.34

10.6 ms

539.5 vs 10,795.9

95.00%

Service C (Python / AI Agent)

81 / 2,335

0.90 (90%)

0.9000

0.30

11.7 ms

750.1 vs 54,824.9

98.63%

Honest v1.0-lite Diagnostic (Why v2.0-hybrid Exists): Even with natural developer queries, ~10–20% of commit queries miss top-5 when pure dense all-MiniLM-L6-v2 embeddings encounter exact camelCase identifiers, dot-separated event names (chat.message.sent), or split methods that lost their parent class Scope header. That empirical ceiling is exactly what v2.0-hybrid (AST Scope/Calls passport + LanceDB BM25+Dense RRF) and v3.0-contextual (System-1 Cross-Encoder reranking) are designed to solve.

MicroIndex Benchmark Terminal Output


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-project

Add .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"

2. 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: In global configs (e.g. Antigravity ~/.gemini/antigravity/mcp_config.json), register one entry per repo (MicroIndex-backend, MicroIndex-frontend) with each entry pointing INDEXER_DATA_DIR to that repo's .lancedb_data.

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 MODEL=llama3.1:8b

Privacy Warning: Using cloud LLM providers (GEN_PROVIDER=openai or GEN_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, use offline-template (default) or ollama.


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)

local

all-MiniLM-L6-v2 (384d)

HF_HUB_OFFLINE=1 (optional)

100% free, private, works offline once cached

Ollama

ollama

nomic-embed-text

OLLAMA_BASE_URL (default http://localhost:11434)

Local GPU/CPU Ollama server

OpenAI / Compatible

openai

text-embedding-3-small

OPENAI_API_KEY, optional OPENAI_BASE_URL

Works with OpenAI, OpenRouter, LM Studio, vLLM

Google Gemini

gemini

text-embedding-004

GEMINI_API_KEY

Gemini Generative Language API

Example with Ollama:

make index TARGET=/path/to/your-project PROVIDER=ollama MODEL=nomic-embed-text

Supported 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 — 4 strict rules banning blind full-file scans during discovery.

  • templates/SKILL.md — 4-step context-preparation runbook (search_code → get_code_chunk → bounded start_line..end_line → edit & re-index).

AI Client

Where to Copy AGENT_RULES.md

Where to Copy SKILL.md

Claude Code

Append to CLAUDE.md

.claude/skills/microindex-code-discovery/SKILL.md

Cursor

.cursor/rules/microindex.mdc

.cursor/skills/microindex-code-discovery/SKILL.md

Google Antigravity

.agent/rules/microindex.md

.agent/skills/microindex-code-discovery/SKILL.md

VS Code Copilot

.github/copilot-instructions.md

.github/skills/microindex-code-discovery/SKILL.md

Codex / Gemini CLI

Append to AGENTS.md or GEMINI.md

~/.agents/skills/microindex-code-discovery/SKILL.md


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:


Version Roadmap (Git Tags)

Evolution path across releases (v1.0-lite → v2.0-hybrid → v3.0-contextual → v4.0-ast-edit):

Tag / Milestone

Status

Architecture & Capabilities

v1.0-lite

Released

AST chunking (Tree-sitter, <= 1500 chars) + local CPU embeddings (LanceDB) + AGENT_RULES.md + pytest quality gates

v2.0-hybrid

Planned

Deterministic AST passport (Scope, Calls, Imports) + Hybrid Search in LanceDB (Dense + BM25 FTS + RRF)

v3.0-contextual

Planned

Two-Stage Retrieval with a lightweight local System-1 Cross-Encoder reranker (narrowing top-20 to top 2–3 chunks) + optional --enrich summaries

v4.0-ast-edit

Planned

Surgical MCP AST editing (replace_ast_node, insert_ast_node) by Tree-sitter symbol/span with syntax verification and instant incremental re-indexing

Community / Language Support

Ongoing

Expanding src/languages/ (Go, Rust, Java, C#, Kotlin) and running benchmarks on large OSS repositories (benchmarks/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-mcp saves 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 tools
get_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

    B3.3/5.0

    Scored across 2 tools

    Disambiguation4/5

    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.

    Naming Consistency5/5

    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.

    Tool Count3/5

    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.

    Completeness3/5

    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

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      C
      maintenance
      Indexes codebases and lets AI agents retrieve precise code snippets (functions, classes, routes) instead of reading entire files, reducing token usage and improving accuracy.
      18 npm
      7
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Adds 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 npm
      1
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Enables AI coding agents to retrieve only the specific code sections that answer their questions, drastically reducing context usage while running fully locally.
      1
      1
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables 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.
      1
      MIT