# Code Index [Health: Active]

**Category:** 🗄️ Databases  
**Repository:** https://github.com/achreftlili/code-index  
**GitHub Stars:** 1  
**Views:** 1  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/code-index-2

## Description
SQLite-backed hybrid (vector + FTS) code search index for Claude Code over MCP.

## Tools
Capabilities this server exposes over MCP:

- **code_search** — Hybrid (vector + FTS) search for **conceptual** queries (e.g., "auth flow", "where do we parse JSON").
- **symbol_lookup** — Exact-name lookup of functions / classes / methods / types. Prefer over `code_search` for identifiers.
- **file_outline** — Symbols (with signatures) in a file, in source order. Use instead of `Read` when you only need shape.
- **module_outline** — Symbols across a directory subtree in one call. Use instead of looping `file_outline`.
- **where_am_i** — Given `path` + `line`, returns the innermost symbol and the full enclosing chain.
- **get_symbol_body** — Full chunk for a `symbol_id` from `symbol_lookup` / `code_search` / `file_outline`.
- **get_symbol_bodies** — Batch version of `get_symbol_body` (up to 20 ids per call).
- **callers** — Symbols that CALL the given symbol. `depth` (1-5) expands transitively.
- **callees** — Symbols that the given symbol CALLS. `depth` (1-5) expands transitively.
- **references** — Non-call uses (subclasses, free identifier references). Companion to `callers` / `callees`.
- **trace** — Build a call-graph tree from an entry symbol; `flat=true` returns nodes/edges for cheap LLM scans.
- **file_imports** — Files this file imports (`direction=imports`) or that import it (`direction=imported_by`).
- **recent_changes** — Files touched in the last N git commits.
- **propose_rename** — v1: same-file rename. Returns an edit list the agent applies via its own `Edit` tool; refuses on clash.

## Claude Desktop Quick Installation
Install path detected from listing signals. Uses `uvx` (confidence: high):

```json
"mcpServers": {
  "code-index": {
    "command": "uvx",
    "args": ["--with","sentence-transformers<5","--with","numpy<2","--from","mcp-code-index","code-index-hook"]
  }
}
```

## Documentation

## What Code Index MCP server does

Code Index MCP server turns a local repository into a searchable code index for MCP-compatible agents. It parses Python, TypeScript/JavaScript, Go, and Rust source with tree-sitter, breaks code into symbol-oriented chunks, expands identifiers for search, and stores the resulting metadata in `.claude/index.db`.

The index contains symbol records, local embeddings, full-text search data, and call/import relationships. Search runs without API keys or external services after the embedding model has been downloaded and cached. Results are returned as bounded JSON, with full symbol content available through dedicated retrieval tools rather than being inserted into every search response.

## How it works

During initialization, the server parses the repository and creates embeddings with the local `jina-embeddings-v2-base-code` model through sentence-transformers. SQLite, sqlite-vec, and FTS5 support vector and keyword retrieval. Conceptual questions such as locating authentication or JSON parsing logic use hybrid search; exact function, class, method, and type names should use symbol lookup instead.

The server also records relationships between symbols and files. Agents can inspect callers, callees, non-call references, call trees, imports, reverse imports, and files changed in recent Git commits. A location query can identify the innermost symbol and its enclosing chain for a given path and line.

## Setup and configuration

The runtime requires Python 3.10 or newer with loadable SQLite extension support, plus `uv`/`uvx` or `pip`. The first initialization needs roughly 600 MB of disk space for the embedding model. Python 3.13 includes the needed SQLite capability by default; Python 3.10–3.12 may require a python.org installation or a pyenv build configured with loadable SQLite extensions.

Install the package with `uvx` or `pip`, then register `code-index-mcp` as a stdio MCP server. From an MCP client, call the administrative `init` operation to build the index. The default database path is `.claude/index.db`. Optional environment variables can select the embedding device, change embedding batch size, or override the database location.

An optional `PostToolUse` hook watches Claude Code `Edit`, `Write`, and `MultiEdit` operations and incrementally reindexes touched files. Without the hook, changes made outside the agent can leave the index stale until initialization runs again.

## Tools and capabilities

The retrieval interface includes `code_search`, `symbol_lookup`, `file_outline`, `module_outline`, `where_am_i`, `get_symbol_body`, and batched symbol-body retrieval. Relationship tools include `callers`, `callees`, `references`, `trace`, and `file_imports`. `recent_changes` reports files touched in recent commits, while `propose_rename` produces a same-file edit list and rejects name clashes.

Administrative operations support initialization, setup diagnostics, hook installation, statistics, and integrity verification. A hidden development ranking diagnostic can be enabled with `CODE_INDEX_DEBUG=1`.

## Limitations and notes

`propose_rename` is limited to same-file renames and does not apply edits itself; the agent must use its own edit capability. The embedding model must be downloaded on first use, although later operation can be offline. Index freshness is not automatic for arbitrary editor saves, moves, or checkouts unless the optional hook is configured or initialization is run again. Python support also depends on a SQLite build that can load extensions.

_Full upstream README: https://allmcps.com/mcp/code-index-2/readme_

