fast-indexer-mcp
# fast-indexer-mcp (v3.0)
**Zero-dependency Windows MCP server for AI coding agents** — combining [Voidtools Everything (`es.exe`)](https://www.voidtools.com/) NTFS MFT indexing, [Ripgrep (`rg.exe`)](https://github.com/BurntSushi/ripgrep) PCRE2 SIMD content search, and an in-process lexical scope extractor (`JS/TS`, `Python`, `Java`, `Kotlin`, `C#`, `C/C++`, `Rust`, `Go`, `Dart`, and Android `.smali`).
> **نبذة سريعة (العربية):** خادم MCP مجاني ومفتوح المصدر صُمّم في الأصل لإيقاف اعتماد وكلاء البرمجة على أوامر PowerShell البطيئة (`Get-ChildItem -Recurse` و `Select-String`) وتقليل استهلاك التوكنز التراكمي. يجمع بين فهرس NTFS الفوري في أداة `Everything` وسرعة `Ripgrep`، مع مخرجات مجمّعة حسب الملف، واستخراج دقيق لنطاقات الدوال والكلاسات بدون أي مكتبات npm خارجية.
---
## Table of Contents
1. [Why `fast-indexer-mcp` Exists (The Idea)](#why-fast-indexer-mcp-exists-the-idea)
2. [What Changed in v3.0 & Verified Benchmarks](#what-changed-in-v30--verified-benchmarks)
3. [Agent Search Architecture](#agent-search-architecture)
4. [Tool Reference](#tool-reference)
5. [Installation & Setup (Windows + Antigravity)](#installation--setup-windows--antigravity)
6. [Engineering Post-Mortem: What Didn't Work, Rejected Ideas & Limitations](#engineering-post-mortem-what-didnt-work-rejected-ideas--limitations)
7. [License](#license)
---
## Why `fast-indexer-mcp` Exists (The Idea)
AI coding agents on Windows historically burn huge amounts of time and context tokens during codebase exploration for three structural reasons:
1. **Slow, noisy shell fallbacks:** Without structured search tools, agents default to `Get-ChildItem -Recurse`, `dir /s`, `Select-String`, or `findstr /s` inside PowerShell—crawling `node_modules`, `.git`, and build outputs, hitting quoting errors, and dumping thousands of raw path lines into conversation history.
2. **Native search tool gaps across agent surfaces:** Some modern agent runtimes (for example, Antigravity 2.0 App's core toolset) expose file reading/editing and terminal execution (`read_file`, `write_file`, `edit_file`, `run_command`) without built-in `grep` or `glob` tools. Removing a dedicated search MCP forces the agent right back to slow terminal loops.
3. **Cumulative token inflation across turns:** Every verbose tool response stays in conversation history and gets re-sent on subsequent turns. Repeating a full Windows path on 50 matching lines or returning entire 500-line files just to inspect one function compounds token cost exponentially.
`fast-indexer-mcp` solves this with a single-file Vanilla Node.js (`>=18`) server speaking **MCP `2024-11-05` over JSON-RPC 2.0 `stdio`**, orchestrating native OS-level binaries (`es.exe` + `rg.exe`) behind 5 compact, agent-first tools.
---
## What Changed in v3.0 & Verified Benchmarks
All figures below were measured directly via JSON-RPC 2.0 `stdio` harness tests against `v2.2` vs. `v3.0`:
| Metric / Capability | v2.2 Baseline | v3.0 Result | Impact |
| :--- | :--- | :--- | :--- |
| **Total Schema Footprint (5 tools)** | `6,023 chars` | `4,333 chars` | **-28.1%** schema size |
| **Eager Prefix Footprint (Top 3 tools)** | `6,023 chars` (if all eager) | `3,065 chars` (~766 tokens) | **0** extra lazy round-trips for daily search |
| **Lazy Structural Tools (2 tools)** | Loaded on demand | `0` upfront prompt tokens | Loaded only when outlining/scoping code |
| **Grouped Search Output** (`armTimeout` in `index.mjs`) | `596 chars` | `388 chars` (`21 ms`) | **-34.9%** output chars on single-file search; `1,403 → 1,114 chars` (**-20.6%**) across multi-file repo search |
| **Arabic / Unicode File Locate** | Corrupted (`?????`) via stdout | Intact UTF-8 via `-export-json` (`82 ms`) | Full Unicode fidelity + `[DIR]` tags |
| **Everything `lstat` Disk Syscalls** | 24-concurrent `lstat` per batch | **0** `lstat` calls (`-export-json` metadata) | Size + UTC mtime returned directly from MFT |
| **Junk Directory Filtering** | Leaked `node_modules`/`.git` | `exclude_junk: true` + `!**/dir/**` globs | Prevents third-party noise in results |
| **Multi-Language Scope Extraction** | Indent-only regex | Balanced brace / Python indent / Smali scanner | `0–3 ms` (`JS 3ms`, `Py 1ms`, `Java 1ms`, `Smali 0ms`) |
### Key v3.0 Upgrades
* **Everything UTF-8 `-export-json` Pipeline:** Replaced `-export-txt` + disk `batchStats()` with `-export-json` (`-size-format 1 -date-format 3 -no-digit-grouping`). Fixes Windows OEM codepage corruption on Arabic/Unicode filenames, marks directories cleanly (`/` + `[DIR ...]`), and excludes `node_modules`, `.git`, `dist`, `build`, `.next`, `__pycache__`, `.venv`, and `target` by default (`exclude_junk: true`).
* **Grouped Search & Outline Payloads:** `instant_content_search` and `project_symbol_outline` print `Root: <dir>` once and group matches under `## <relative/path>` instead of repeating the full drive path on every line.
* **Hidden & Gitignored Escape Hatches:** Added `include_hidden` and `no_ignore` to `instant_content_search` so agents can inspect `.env`, `.github/`, or ignored build logs intentionally instead of silently receiving zero results.
* **Clean Error & Early-Stop Semantics:** Added `stderr` capture (`isError: true` on `rg` exit code `>= 2` instead of silent empty matches) and explicit `stoppedEarly` tracking so killing `rg` at `max_matches` never emits false partial-failure warnings.
* **Accurate Scope Extraction (`full_scope`):** Replaced the naive indent heuristic in `ast_context_search` with `findEnclosingScope()` + `stripStringsAndComments()` supporting brace-delimited languages, Python indentation, and Android `.smali` (`.method`..`.end method`), with `full_scope: true` returning the full enclosing block up to 120 lines.
---
## Agent Search Architecture
Agents using `fast-indexer-mcp` should follow a strict **narrowing funnel**—moving from disk/folder discovery to file filtering, then symbol outlines, and only reading targeted line ranges last.
```mermaid
flowchart TD
Q["Agent Needs Code or File Context"] --> KnowPath{"Know target file or folder?"}
KnowPath -- "No (file/folder name)" --> Loc["instant_file_locate (Eager: Everything MFT -> Ripgrep)"]
KnowPath -- "Single folder contents" --> Dir["instant_directory_list (Eager: non-recursive + token est.)"]
KnowPath -- "Yes (need text/symbol inside)" --> Broad{"Broad query across repo?"}
Broad -- "Yes" --> FilesOnly["instant_content_search (output_mode='files_only')"]
FilesOnly --> Grouped["instant_content_search (output_mode='matches', grouped by file)"]
Broad -- "No (targeted dir/file)" --> Grouped
Grouped -. "Missing dotfiles or ignored files?" .-> Flags["Retry with include_hidden=true or no_ignore=true"]
Grouped --> SymNeed{"Need full file map or function body?"}
SymNeed -- "Map classes/functions" --> Outline["project_symbol_outline (Lazy: ~150 tok outline)"]
SymNeed -- "Inspect one symbol's block" --> Scope["ast_context_search (Lazy: full_scope=true, <=120 lines)"]
Outline --> Scope
Scope --> Read["read_file (StartLine..EndLine surgical slice)"]
Loc --> Read
Dir --> Read
```
### Eager vs. Lazy Tool Split (Antigravity 2.0 Optimization)
Antigravity 2.0 supports **Lazy MCP Loading** by default and selective `"eager": true` overrides per tool in `mcp_config.json`:
* **Eager (`instant_file_locate`, `instant_content_search`, `instant_directory_list`):** Registered upfront (~766 tokens total) so the agent invokes them in **1 turn** without wasting an extra `read_file` turn to inspect JSON schemas on disk—and is never tempted to fall back to PowerShell.
* **Lazy (`project_symbol_outline`, `ast_context_search`):** Zero per-turn prompt tax until the agent specifically needs structural symbol mapping or enclosing block extraction.
See [AGENTS.md](AGENTS.md) for the condensed agent execution rules and engineering invariants.
---
## Tool Reference
| Tool | Loading | Purpose | Key Parameters | Typical Latency |
| :--- | :--- | :--- | :--- | :--- |
| `instant_file_locate` | **Eager** | Disk-wide or scoped file/folder lookup via Everything MFT + Ripgrep fallback | `query`, `target_dir`, `sort_by`, `max_results`, `max_size_kb`, `summary_mode`, `fuzzy`, `exclude_junk` (`true`) | `80–190 ms` |
| `instant_content_search` | **Eager** | Ripgrep PCRE2 regex/literal search with grouped file output | `pattern`, `target_path`, `file_glob`, `output_mode` (`matches` / `files_only` / `count_only`), `include_hidden`, `no_ignore`, `search_compressed`, `context_lines` | `15–25 ms` |
| `instant_directory_list` | **Eager** | Non-recursive folder listing with sizes, relative ages, symlinks, and token total | `dir_path`, `max_results`, `show_hidden` | `2–10 ms` |
| `project_symbol_outline` | **Lazy** | PCRE2 symbol index grouped by file (JS/TS, Python, Go, Rust, Java, Kotlin, C/C++, C#, Smali) | `target_path`, `file_glob`, `symbol_type` (`all` / `functions` / `classes` / `types`), `max_symbols` | `~21 ms` |
| `ast_context_search` | **Lazy** | Lexical brace/indent/Smali enclosing scope extractor around a symbol | `file_path`, `pattern`, `context_radius`, `full_scope` (`false` / `true` up to 120 lines) | `0–3 ms` |
---
## Installation & Setup (Windows + Antigravity)
### Prerequisites
1. **Node.js `>= 18.0.0`** (`node -v`).
2. **Ripgrep (`rg.exe`):** Install via `winget install BurntSushi.ripgrep.MSVC` (recommended path: `C:\tools\ripgrep\rg.exe` or on `PATH`).
3. **Voidtools Everything + CLI (`es.exe`):** Optional but strongly recommended for whole-disk millisecond file lookup. Ensure Everything is running in the background and place `es.exe` at `C:\tools\es.exe` (or on `PATH`).
### Clone & Verify
```powershell
git clone https://github.com/Akramx15/fast-indexer-mcp.git C:\tools\fast-indexer-mcp
cd C:\tools\fast-indexer-mcp
npm run check
```
### Configure Antigravity / MCP Clients
Copy the ready-made portable templates from [`templates/`](templates):
* **MCP Server Config (with selective `eager: true`):** [`templates/mcp_config.example.json`](templates/mcp_config.example.json) → merge into `~/.gemini/config/mcp_config.json`.
* **Auto-Allow Permissions (all 5 tools):** [`templates/antigravity_permissions.example.json`](templates/antigravity_permissions.example.json) → merge into `userSettings.globalPermissionGrants.allow` in `~/.gemini/config/config.json`.
* **Always-On Rule (ban PowerShell scans):** [`templates/zero_powershell_indexing.rule.md`](templates/zero_powershell_indexing.rule.md) → copy to `~/.gemini/config/rules/zero_powershell_indexing.md`.
* **Agent Skill:** [`templates/fast-local-indexing.SKILL.md`](templates/fast-local-indexing.SKILL.md) → copy to `~/.gemini/config/skills/fast-local-indexing/SKILL.md`.
---
## Engineering Post-Mortem: What Didn't Work, Rejected Ideas & Limitations
Transparency matters more than hype. Below is everything we tested, hit, rejected, or deliberately left out while building `v3.0`.
### 1. Platform Quirks & Bugs Discovered During Testing
* **`es.exe -json` stdout corrupts Arabic & Unicode:** Spawning `es.exe -json` from Node.js and reading `stdout` passes text through the Windows OEM console codepage, turning `أدوات` into `?????`. Using `-export-json <tempFile>` writes clean UTF-8 JSON to disk and preserves Arabic/Unicode paths reliably.
* **`es.exe -timeout 5000` causes a 5-second hang + `Error 8`:** On `ES 1.1.0.38`, passing `-timeout 5000` caused `es.exe` to block for 5,000 ms and fail with `Error 8: Everything IPC not found` even while Everything was running, forcing a slow Ripgrep fallback. Removing `-timeout` restored `<110 ms` execution, while Node's `armTimeout()` still prevents hangs.
* **Ripgrep `-g !node_modules/**` silently fails on absolute paths:** When `rg.exe` runs from one working directory against an absolute `target_path` elsewhere, `-g !node_modules/**` fails to match nested paths and leaks `node_modules` files. Switching all exclusions to `!**/node_modules/**` fixed this across both locate and symbol outline.
* **Non-NTFS volumes & `.gitignore` blindness in Everything:** Everything only indexes NTFS/ReFS volumes and has no `.gitignore` awareness. `fast-indexer` mitigates this by warning when an indexed drive check fails (`driveIndexed()`) and injecting explicit `!path:\<junk>\` exclusions unless `exclude_junk: false` or the user explicitly targets that directory.
### 2. Alternatives Considered & Why We Rejected Them
#### A. Why we did NOT integrate `ast-grep` (`sg.exe`) or external Tree-sitter binaries
We evaluated `ast-grep` (`0.51.3` via `winget`) and rejected integrating it into `fast-indexer-mcp` for 4 concrete reasons:
1. **Zero `.smali` support:** Reverse-engineering workflows rely heavily on Android `.smali` files, which `ast-grep` / standard Tree-sitter grammars do not parse cleanly.
2. **Brittle on half-edited code:** Agents frequently inspect files containing temporary syntax errors mid-refactor; strict AST parsers either drop error nodes or fail to match partial signatures, whereas a lexical brace/indent scanner stays resilient.
3. **Per-language AST query maintenance:** Supporting 10+ languages with Tree-sitter node kinds adds complex grammar mappings or native binary build chains (`node-gyp`/WASM loading overhead).
4. **Spawn overhead:** Launching an external AST binary per query adds process startup latency compared to `0–3 ms` in-process lexical scanning inside Node.
#### B. Why we did NOT add Vector Embeddings / Local Semantic RAG
* Semantic embedding MCPs require model downloads, background chunking/indexing warm-up, disk/RAM overhead, and risk returning stale or approximate matches.
* For local repos under ~50k lines, exact MFT lookup + Ripgrep PCRE2 + targeted symbol scopes are deterministic, zero-warmup, and faster.
#### C. Should You Use `fast-indexer-mcp` or `Serena MCP` (or Both)?
**Use the right tool for the job—and if another server solves a task better, switch to it.** `fast-indexer-mcp` and LSP-backed servers like [Serena MCP](https://github.com/oraios/serena) solve different layers of the problem:
| Dimension | `fast-indexer-mcp` | `Serena MCP` (LSP-based) | Built-in Shell (`PowerShell` / `findstr`) |
| :--- | :--- | :--- | :--- |
| **Warm-up Time** | **0 ms** (stateless, instant start) | Requires spawning/indexing per-language LSP servers | 0 ms, slow per-call crawl |
| **Whole-Disk Windows File Search** | **Yes** (`Everything` NTFS MFT) | Workspace-scoped only | Very slow |
| **Configs, Logs, Compressed (`.gz`), `.smali`** | **Yes** (`rg -z`, PCRE2, Smali scopes) | Limited to supported LSP languages | Partial / brittle quoting |
| **Cross-File Type Resolution (`Find References`, `Rename Symbol`)** | **No** (text & single-file scope only) | **Yes** (compiler-grade semantic AST/types) | No |
| **Token Footprint** | Very low (~766 eager tokens; grouped output) | Moderate-High (large tool surface + LSP state) | Very high (noisy dumps) |
**Practical rule:** Use `fast-indexer-mcp` as your lightweight daily search/navigation engine; add `Serena MCP` alongside it (or instead of it) when working inside massive typed repositories (TypeScript, Java, C++, Rust, Python) where compiler-accurate cross-file reference graphs and safe symbol renaming justify LSP startup overhead.
#### D. Why we kept exactly 5 tools (No `repo_map` or `multi_grep` bloat)
Expanding from 5 to 8–10 overlapping tools increases upfront schema tokens and causes LLM tool-selection hesitation. Grouping outputs and supporting `files_only` + `full_scope` inside 5 orthogonal tools delivered better token savings without diluting tool choice.
### 3. Known Limitations (Honest Negatives)
* **Windows-centric acceleration:** `es.exe` is Windows-only. Running on Linux/macOS works via `rg.exe` fallback, but without disk-wide NTFS MFT indexing.
* **Lexical scope scanner ≠ full parser:** `ast_context_search` handles normal brace-delimited code, Python indentation, and Smali methods, but **single-line functions** (`foo(x) { return x; }` matched inside the same line) or unusual multi-line preprocessor/macro blocks may fall back to `context_radius` lines instead of a complete `full_scope`.
* **Regex-based `project_symbol_outline`:** PCRE2 line matching is fast (~21 ms) and language-agnostic, but multi-line function headers or non-standard formatting can be missed, and non-brace/non-keyword declarations may not appear.
* **Requires Everything background service for MFT speed:** If Everything is closed or indexing a non-NTFS/network drive, `instant_file_locate` falls back to directory-scoped `rg --files`.
* **Default `cwd` trap when omitting `target_dir`/`target_path`:** If an agent omits the path argument when no workspace is set, search runs in the MCP server's own working directory. v3.0 always prints `Root: <path>` / `in <path>` in headers so the agent immediately catches path mistakes.
* **Eager loading cost:** Marking the top 3 tools `"eager": true` adds `3,065 chars` (~766 tokens) to the static system prompt prefix—still smaller than a single extra lazy schema-read turn, and cached across turns.
---
## License
[MIT](LICENSE)
TDQS
Scored across 5 tools
The five tools cover distinct retrieval modes: file-name location, content search, non-recursive directory listing, project-wide symbol outline, and single-file AST scope extraction. The only mild overlap is between project_symbol_outline and ast_context_search, but their different granularity (project outline vs enclosing scope) is clear enough.
All names use snake_case with a subject_action pattern, and the three instant_* tools are internally consistent. The two AST/symbol tools drop the instant_ prefix, which is a minor stylistic deviation rather than a confusing one.
Five tools is well-scoped for a focused code-index/search server, with each tool covering a distinct retrieval capability. There is no obvious filler or missing core operation at this scale.
The surface covers file discovery, content search, directory browsing, symbol outlining, and AST context, which fits the stated indexing purpose well. A file-content retrieval tool is arguably missing, but content search plus AST extraction covers most practical workflows.