Skip to main content
Glama
LocalCodeRAG-MCP

LocalCodeRAG-MCP

LocalCodeRAG-MCP

License: MIT Python 3.10+ Offline: 100% Protocol: MCP Latency: Sub-10ms

100% Offline, Zero-Network Hybrid AST Code Retrieval Engine for AI Coding Assistants (Claude Code, Cursor, Windsurf).


Why LocalCodeRAG-MCP?

Traditional retrieval solutions for code either leak intellectual property to cloud embedding APIs (OpenAI, Voyage, Cohere) or rely on brittle regex search that lacks semantic relevance.

LocalCodeRAG-MCP solves both problems:

  1. Zero Cloud Egress: 100% air-gapped; runs entirely in local Python and embedded SQLite. Zero API keys, zero network connections.

  2. AST-Boundary Chunking: Chunks source files along syntactic boundaries (classes, functions, async methods, module docstrings) rather than arbitrary line counts.

  3. Reciprocal Rank Fusion (RRF): Fuses SQLite FTS5 BM25 full-text keyword ranking with local sub-word feature-hashed dense vector embeddings ($k=60$).

  4. Sub-10ms Latency: Delivers instantaneous semantic code lookups in 2ms to 8ms.


Related MCP server: anyindex-mcp

Architecture

                  +---------------------------------------+
                  |  AI Coding Assistant (Claude, Cursor) |
                  +---------------------------------------+
                                      |
                           JSON-RPC 2.0 (stdio)
                                      v
                  +---------------------------------------+
                  |            LocalCodeRAG-MCP           |
                  +---------------------------------------+
                     /                |                \
                    v                 v                 v
          +-----------------+ +---------------+ +---------------+
          | AST Code Chunker| | Local Embedder| | RRF Ranker    |
          | (Classes/Funcs) | | (128-dim L2)  | | 1/(60+r)      |
          +-----------------+ +---------------+ +---------------+
                     \                |                /
                      +---------------+---------------+
                                      |
                                      v
                  +---------------------------------------+
                  |       SQLite FTS5 Embedded Store      |
                  |             (.coderag.db)             |
                  +---------------------------------------+

Flagship MCP Tools

Tool

Purpose

Latency

local_index_codebase

Recursively chunks and indexes repositories into SQLite FTS5 + vector tables

~10-20 ms/file

local_search_hybrid

Reciprocal Rank Fusion of BM25 lexical search and dense cosine similarity

< 8 ms

local_find_definition

Exact & prefix AST symbol lookup with line ranges and parameters

< 2 ms

local_find_references

Cross-repository caller and reference discovery

< 5 ms

local_codebase_stats

Database health metrics (total chunks, functions, classes, file size)

< 1 ms


Installation & Setup

1. Install via pip

pip install -e .

2. Standalone CLI Usage

# Index current repository
coderag index .

# Execute hybrid search
coderag search "AST chunker for functions and classes"

# Locate a symbol definition
coderag def LocalHybridSearchEngine

# View index metrics
coderag stats

3. Connect to Claude Code

Add to your ~/.claude.json:

{
  "mcpServers": {
    "localcoderag": {
      "command": "python",
      "args": ["-m", "localcoderag.cli", "serve", "--db", ".coderag.db"]
    }
  }
}

4. Connect to Cursor

Add to your .cursor/mcp.json:

{
  "mcpServers": {
    "localcoderag": {
      "command": "python",
      "args": ["-m", "localcoderag.cli", "serve"]
    }
  }
}

Verification & Benchmarks

Run the built-in test suite:

pytest tests/ -v

Run the live interactive demonstration:

python examples/run_coderag_demo.py

Benchmark Results

  • Codebase Indexing: 17 files (70 AST chunks, 44 functions, 9 classes) indexed in 129.6 ms.

  • Search Latency: Hybrid RRF search executed in 5.23 ms.

  • Database Footprint: 4.0 KB SQLite file.


Author & Engineering Leadership

Chethan Raj D S
Technical Lead / Hands-on Engineering Leader / Principal Solutions Architect


License

This project is licensed under the MIT License.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables local semantic code search across repositories using natural language, with AST-aware chunking and hybrid vector/FTS5 retrieval.
      -
    • A
      license
      A
      quality
      B
      maintenance
      Enables semantic and keyword search over a local codebase by chunking source files along function and class boundaries, embedding them offline, and fusing vector and BM25 results. Runs entirely on your machine in a single SQLite file, so AI coding agents can find relevant code with no API keys, telemetry, or cloud calls.
      7
      17 npm
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Local long-term memory shared by every AI coding assistant on one machine: a single SQLite file with FTS5 search and optional multilingual semantic search, no daemon and no cloud.
      13
      2
      MIT