Skip to main content

LeIndex MCP bootstrap wrapper for the Rust LeIndex binary

Project description

LeIndex

Rust License MCP

LeIndex

Understand large codebases instantly.

LeIndex is a semantic code search engine that lets you search code by meaning, not just keywords.

Instead of hunting through files with grep or hoping variable names match your query, you can ask things like:

  • "Where is authentication enforced?"
  • "Where are API tokens validated?"
  • "How does session management work?"

LeIndex surfaces the actual implementation — even if the words you're searching for never appear in the code.

Built in Rust. Built for developers and AI coding tools.

Worker Architecture (Plan 3)

  • Version parity with Cargo: PyPI leindex matches the main leindex crate version.
  • Worker binary: first run downloads the Rust binary into ~/.cargo/bin via cargo install.
  • Memory targets: idle_warm ~9852 KiB, index ~20168 KiB, query ~13480 KiB (within A+ bands).
  • Usage (semantic search): leindex search "authentication".

Demo: finding logic that grep and LLMs miss

Imagine a codebase where authentication is implemented like this:

fn validate_session(req: Request) -> Result<User> { ... }
fn verify_token(token: &str) -> bool { ... }
fn authorize_user(user: &User, action: Action) -> bool { ... }

None of these functions contain the word "authentication".

grep

grep -r "authentication" src/
# (no matches)

LeIndex

leindex search "where is authentication enforced"
src/security/session_validator.rs    validate_session    (0.92)
src/auth/token_verifier.rs           verify_token        (0.87)
src/middleware/auth_gate.rs           authorize_user      (0.84)

LeIndex finds the correct logic because it searches by semantic intent, not string matches.

It works across multiple repositories too:

leindex search "where are API rate limits enforced"
gateway/middleware/rate_limit.rs      throttle_request     (0.91)
api/server/request_throttle.go        limit_handler        (0.88)
auth/session_policy.rs                enforce_policy       (0.83)

90%+ Token Savings for AI Coding Tools

When an LLM reads your code with standard tools, it burns tokens on entire files just to understand one function. LeIndex returns only what matters — structured, context-aware results instead of raw file dumps.

Task Standard Tools LeIndex Savings
Understand a 500-line file ~2,000 tokens ~380 tokens 81%
Find all callers of a function ~5,800 tokens ~420 tokens 93%
Navigate project structure ~8,500 tokens ~650 tokens 92%
Cross-file symbol rename ~12,000 tokens ~340 tokens 97%

Every tool call is context-aware — not atomic. When you look up a symbol, you don't just get its definition. You get its callers, callees, data dependencies, and impact radius. When you summarize a file, you get cross-file relationships that Read can never provide at any token cost. One LeIndex call replaces chains of Grep → Read → Read → Read.

See full benchmarks for methodology and detailed comparisons.


Quick Start (2 minutes)

Install

Option 1: PyPI (this package, recommended for Python users)

pip install leindex
leindex setup

The PyPI package installs a small Python launcher that bootstraps the real Rust leindex binary into ~/.cargo/bin via cargo install on first run. Run leindex setup afterwards to install ONNX Runtime and download the qwen3-embed-0.6b.onnx model for neural (semantic) search. TF-IDF (keyword) search works immediately without setup. See docs/NEURAL_SETUP.md for CPU/GPU/AMD/NVIDIA paths and troubleshooting.

Option 2: cargo (recommended for Rust users)

cargo install leindex
leindex setup

Option 3: install script (GitHub Release bundle)

curl -fsSL https://raw.githubusercontent.com/scooter-lacroix/LeIndex/master/install.sh -o install-leindex.sh
bash install-leindex.sh
leindex setup

Option 4: npm MCP wrapper (recommended for AI tools like Cursor, Claude Code)

npm install -g @leindex/mcp
npm run setup --prefix "$(npm root -g)/@leindex/mcp"

Environment Variables:

Name Required Description Default
LEINDEX_HOME No Override storage/index home directory ~/.leindex
LEINDEX_PORT No Override HTTP server port 47500
ORT_DYLIB_PATH No Override ONNX Runtime library path (discovered)

Index and search

# Index your project
leindex index /path/to/project

# Search by meaning
leindex search "authentication flow"

# Deep structural analysis
leindex analyze "how authorization is enforced"

That's it. You're searching by meaning.


What LeIndex Is Useful For

  • Understanding unfamiliar codebases — ask questions instead of reading every file
  • Onboarding new engineers — find relevant code without tribal knowledge
  • Exploring legacy systems — surface logic buried in decades of code
  • AI coding assistants — give LLMs real structural context via MCP
  • Cross-project search — query across multiple repositories simultaneously

Built for AI-Assisted Development

Modern AI coding tools struggle with large codebases because they lack global structural context.

LeIndex provides that missing layer.

It builds a semantic index of your repository that both developers and AI assistants can query to understand:

  • where logic lives
  • how components interact
  • what code paths enforce behavior

LeIndex runs as an MCP server, allowing tools like Claude Code, Cursor, and other MCP-compatible agents to explore your codebase with semantic understanding.

# Start MCP stdio mode (for Claude Code / Cursor)
leindex mcp

# Or run the HTTP MCP server
leindex serve --host 127.0.0.1 --port 47500
Claude: "Where is request validation implemented?"

LeIndex MCP → src/http/request_validator.rs
              src/middleware/input_guard.rs

How It Works

LeIndex builds a semantic index of your codebase using embeddings and structural analysis (tree-sitter parsing + program dependence graphs).

This allows queries to match:

  • code intent — what the code does, not what it's named
  • related logic paths — follow data flow and control flow
  • implementation patterns — structural similarity across files

Indexes can span multiple repositories, enabling cross-project search.

Codebase → Tree-sitter Parser → PDG Builder → Semantic Index → Query Engine → Results

Features

  • Semantic search — find code by meaning, not keywords
  • PDG analysis — program dependence graph for structural understanding
  • 5-phase analysis — additive multi-pass codebase analysis pipeline
  • Cross-project indexing — search across multiple repos at once
  • 20 MCP tools — read, analyze, edit preview/apply, rename, impact analysis
  • HTTP + WebSocket server — available through the unified leindex server modules and commands
  • Dashboard — Bun + React operational UI with project metrics and graph telemetry
  • Low resource mode — works on constrained hardware
  • Built in Rust — fast indexing, low memory, safe concurrency
  • Flexible embedding backends — choose between TF-IDF, local ONNX models, or remote cloud providers (OpenAI, Cohere)

Other Install Options

crates.io

cargo install leindex

PyPI

pip install leindex

This package is a bootstrap wrapper for the Rust release. It keeps using the unified leindex command, installs the binary into ~/.cargo/bin, and then forwards all CLI arguments to the real Rust executable.

From source

git clone https://github.com/scooter-lacroix/LeIndex.git
cd LeIndex
cargo build --release

Feature flags: Use --features to customize the build:

  • full (default) — Full library plus the leindex CLI binary
  • minimal — Library-focused parse/search build slice; does not produce the leindex binary by itself
  • cli — Required feature for the leindex binary target
  • server — Enables the HTTP/WebSocket server library modules; combine with cli for a runnable binary

MCP Server Integration

For AI coding tools, the recommended integration path is the npm MCP wrapper so the client resolves the published MCP entrypoint directly:

{
  "mcpServers": {
    "leindex": {
      "command": "npx",
      "args": ["-y", "@leindex/mcp"]
    }
  }
}

If you intentionally installed the full Rust binary via cargo install leindex, install.sh, or the PyPI bootstrapper, you can replace npx -y @leindex/mcp with leindex mcp.

Every MCP tool is also available from the CLI bridge:

leindex tools list
leindex tools help leindex_project_map
leindex tools run leindex_project_map --args '{"path":"src","depth":2}'
Zed IDE

Add to ~/.config/zed/settings.json:

{
  "context_servers": {
    "leindex": {
      "command": {
        "path": "npx",
        "args": ["-y", "@leindex/mcp"]
      }
    }
  }
}
Cursor IDE

Add to Cursor settings (settings.json):

{
  "mcpServers": {
    "leindex": {
      "command": "npx",
      "args": ["-y", "@leindex/mcp"],
      "env": {}
    }
  }
}
VS Code

Requires the Model Context Protocol extension.

Configure in settings.json:

{
  "mcp.mcpServers": {
    "leindex": {
      "command": "npx",
      "args": ["-y", "@leindex/mcp"]
    }
  }
}
Claude Code

Add to ~/.claude/settings.json or project-local .claude/settings.json:

{
  "mcpServers": {
    "leindex": {
      "command": "npx",
      "args": ["-y", "@leindex/mcp"],
      "type": "stdio"
    }
  }
}

Optional guidance pack:

  • Install the shared skill from integrations/skills/leindex-toolkit/ into ~/.claude/skills/leindex-toolkit/
  • Merge integrations/claude-code/settings.example.json to add the LeIndex reminder hook
Amp CLI (Sourcegraph)

Add to ~/.config/amp/settings.json:

{
  "amp.mcpServers": {
    "leindex": {
      "command": "npx",
      "args": ["-y", "@leindex/mcp"]
    }
  }
}
OpenCode

Add to ~/.config/opencode/opencode.json:

{
  "mcp": {
    "leindex": {
      "command": ["npx", "-y", "@leindex/mcp"],
      "type": "local"
    }
  }
}
Qwen CLI

Add to ~/.qwen/settings.json:

{
  "mcpServers": {
    "leindex": {
      "command": "npx",
      "args": ["-y", "@leindex/mcp"]
    }
  }
}
iFlow CLI

Add to ~/.iflow/settings.json:

{
  "mcpServers": {
    "leindex": {
      "command": "npx",
      "args": ["-y", "@leindex/mcp"]
    }
  }
}
Droid (Factory)

Add to ~/.factory/mcp.json (note: requires type: "stdio"):

{
  "mcpServers": {
    "leindex": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "@leindex/mcp"]
    }
  }
}
Gemini CLI

Add to ~/.gemini/settings.json:

{
  "mcpServers": {
    "leindex": {
      "command": "npx",
      "args": ["-y", "@leindex/mcp"]
    }
  }
}

Agent guidance packs:

  • Claude Code: shared skill plus reminder hook
  • Codex: install integrations/skills/leindex-toolkit/ into ~/.codex/skills/leindex-toolkit/
  • Gemini CLI, Amp, OpenCode, Qwen, and iFlow: reuse the shared skill text as project instructions or agent rules
  • Full instructions: docs/AGENT_GUIDANCE.md
Claude Desktop

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json Windows: %APPDATA%\Claude\claude_desktop_config.json Linux: ~/.config/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "leindex": {
      "command": "npx",
      "args": ["-y", "@leindex/mcp"]
    }
  }
}

Dashboard (optional)

cd dashboard
bun install
bun run build
leindex dashboard

CLI Reference

leindex index /path/to/project       # Index a project
leindex search "query"                # Semantic search
leindex analyze "query"               # Deep structural analysis
leindex phase --all --path /path      # 5-phase additive analysis
leindex diagnostics                   # System health check
leindex mcp                           # MCP stdio mode
leindex serve                         # HTTP/WebSocket server
leindex dashboard                     # Launch dashboard UI

MCP Tools (20)

Tool Purpose
LeIndex [Context] Expand context around a code node via PDG
LeIndex [Deep Analyze] Deep analysis: semantic + PDG traversal
LeIndex [Diagnostics] Index health and stats
LeIndex [Edit Apply] PRIMARY file editor (use instead of edit_file)
LeIndex [Edit Preview] Preview a code edit with impact report
LeIndex [File Summary] Structural file analysis
LeIndex [Git Status] Git status with PDG structural analysis
LeIndex [Grep Symbols] Structural symbol search
LeIndex [Impact Analysis] Blast radius analysis
LeIndex [Index] Index a project
LeIndex [Phase Analysis] 5-phase additive analysis
Phase Analysis Compatibility alias for LeIndex [Phase Analysis] (same handler, no-bracket title for legacy clients)
LeIndex [Project Map] Annotated project structure
LeIndex [Read File] PRIMARY file reader (replaces Read)
LeIndex [Read Symbol] PRIMARY symbol reader (replaces Read for symbols)
LeIndex [Rename Symbol] Rename across all references
LeIndex [Search] Semantic code search
LeIndex [Symbol Lookup] Symbol definition + callers/callees
LeIndex [Text Search] PRIMARY text search (replaces Grep/rg)
LeIndex [Write] Create or overwrite a file

MCP tool names returned by tools/list are the exact strings emitted by each handler (e.g. leindex.index, leindex.search, leindex.edit-preview, leindex.write). The naming is a mix of dotted and hyphenated forms — single-word tools use a dot (leindex.context, leindex.index, leindex.search, leindex.write, leindex.diagnostics), multi-word tools use hyphens (leindex.edit-preview, leindex.edit-apply, leindex.read-file, leindex.symbol-lookup, leindex.phase-analysis, etc.). Use these exact names when calling tools/call — dispatch in handle_tool_call is exact-equality on the handler name, so a hyphen-vs-dot mismatch (e.g. leindex-search vs leindex.search) returns method-not-found. The display form above (LeIndex [...]) is the human-readable title; it is not accepted on the wire. The underscore form (leindex_edit_preview) is only used by the CLI bridge (leindex tools help, leindex tools run).

Output formatting

  • MCP payloads are trimmed to the minimum needed for an LLM: short snippets, capped counts, dropped internal byte ranges and verbose fields. No ANSI color, no UI chrome.
  • CLI output is rendered for human reading: split-view color diffs for LeIndex [Edit Preview], LeIndex [Edit Apply], and LeIndex [Rename Symbol] (line numbers + separator + paired +/- markers); tree-style map for LeIndex [Project Map]; structured tables for LeIndex [Search] and LeIndex [Context].

Unified Module Layout

LeIndex is now a single crate with feature-gated modules:

Module Role
parse Language parsing and signature extraction
graph Graph construction and traversal
search Retrieval, scoring, vector search
storage SQLite persistence + storage
phase Additive phase analysis pipeline
cli CLI + MCP protocol handlers
global Cross-project discovery/registry
server HTTP/WebSocket API server
edit Edit preview/apply support
validation Validation and guardrails

Legacy crate-style aliases remain available from leindex::leparse, leindex::legraphe, and similar compatibility re-exports.


Security

Database discovery (LEINDEX_DISCOVERY_ROOTS) is opt-in only. Sensitive directories (.ssh, .aws, .gnupg, etc.) are automatically excluded. All SQL operations use parameterized queries. See ARCHITECTURE.md for details.


Docs


License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

leindex-1.8.3.tar.gz (26.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

leindex-1.8.3-py3-none-any.whl (16.1 kB view details)

Uploaded Python 3

File details

Details for the file leindex-1.8.3.tar.gz.

File metadata

  • Download URL: leindex-1.8.3.tar.gz
  • Upload date:
  • Size: 26.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for leindex-1.8.3.tar.gz
Algorithm Hash digest
SHA256 917f097821a43dad45c8d68d28fb531cc8c99b5b733ca6562cdf074f3aa6a02b
MD5 fe4230854c826daa694c1d4de8cce46f
BLAKE2b-256 93befc80bc9439a7d03ac359bac5d59eef1349ca4f9a3db51250e5e87c25fa38

See more details on using hashes here.

File details

Details for the file leindex-1.8.3-py3-none-any.whl.

File metadata

  • Download URL: leindex-1.8.3-py3-none-any.whl
  • Upload date:
  • Size: 16.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for leindex-1.8.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0d500ebe98ec1f89497cb641d4d4db05b61a55d7f5071b707024c12b7fcbea35
MD5 78e5c0c46407239f0ea116dafe9ffc23
BLAKE2b-256 7830100b338542da494631f6445bc0f3d6aa5f9d8bd88f7e2d46c54c617efbd5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page