CodeXray

June 16, 2026 Β· View on GitHub

Code search & knowledge engine for the AI era. Semantic + full-text hybrid search, real-time indexing, call graph + code vectors + commit vectors + knowledge vectors β€” unified into one native MCP server.

Built natively for Claude Code/Codex CLI β€” zero daemon, zero config overhead.

πŸ“– δΈ­ζ–‡ζ–‡ζ‘£

Highlights

🧠 Hybrid Search Engine β€” Semantic + Full-Text Dual Channel

Goes beyond keyword matching. Dense vector search understands code intent ("login logic" β†’ authenticateUser), while BM25 full-text search locks in exact matches. Results are fused via RRF and re-ranked by Cross-Encoder for precision. When embedding API is unavailable, gracefully falls back to graph search β€” never breaks.

πŸ”— 4D Knowledge Graph

Call graph + code vectors + commit vectors + knowledge vectors β€” four dimensions of codebase awareness. Tree-sitter AST parses 7 languages to build complete function/class/method relationships:

  • Who calls this function?
  • What does this function depend on?
  • Find code by describing what it does

⚑ Real-time Incremental Indexing

Full build on first run, only re-processes changed files thereafter (MD5 diff). Auto-indexes on MCP startup and watches file changes during runtime. Auto-cleans orphaned embeddings β€” index never bloats.

πŸ”Œ Native MCP, Local-First

Built specifically for Claude Code/Codex CLI MCP stdio protocol. Install registers MCP automatically β€” no manual config, no persistent daemon. Starts and exits with Claude Code, zero residue. All code and data stay local, no SaaS required.

Quick Start

curl -fsSL https://raw.githubusercontent.com/iohub/codexray/main/install.sh | sh

Auto-detects OS/arch/libc, downloads, installs, and registers MCP. Restart Claude Code after β€” done.

First run: codexray install auto-launches an interactive setup wizard for the embedding API (graph search works without configuration). CodeXray works out of the box for call graph and name search.

Manual download (Linux musl example)

curl -L -o codexray.tar.gz https://github.com/iohub/codexray/releases/latest/download/codexray-linux-x64-musl.tar.gz
tar -xzf codexray.tar.gz
./codexray install && rm codexray.tar.gz

Other platforms: replace linux-x64-musl with darwin-arm64, darwin-x64, or linux-x64 from the latest release.

From source

git clone https://github.com/iohub/codexray.git && cd codexray
cargo build --release && ./rust-core/target/release/codexray install

How It Works

Index Building

Source files
  β†’ Tree-sitter AST parse (7 languages)
  β†’ Extract functions / classes / methods
  β†’ Build call graph (PetCodeGraph)
  β†’ Batch embed via API (SQLite cache)
  β†’ Store vectors in LanceDB
  β†’ Build BM25 index in Tantivy
  β†’ Save to ~/.codexray/<project_hash>/

Idempotent: index builds are incremental β€” the first run is a full build, subsequent runs compare MD5 hashes and only re-process changed files.

                        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
User query ────────────→│  Embedding Model     │──→ Query vector
                        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                  β”‚
          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
          β–Ό                       β–Ό                       β–Ό
   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚ Dense Search β”‚       β”‚ Sparse Searchβ”‚       β”‚ Graph Search β”‚
   β”‚ (LanceDB ANN)β”‚       β”‚ (Tantivy BM25)β”‚      β”‚ (PetCodeGraph)β”‚
   β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜       β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜       β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
          β”‚                      β”‚                      β”‚
          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                 β–Ό
                        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                        β”‚   RRF Fusion    β”‚  ← Reciprocal Rank Fusion
                        β”‚  (Top-20 candidates)β”‚
                        β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                 β”‚
                                 β–Ό
                        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                        β”‚    Reranker     β”‚  ← Cross-Encoder fine re-ranking
                        β”‚ (Qwen3-Reranker)β”‚     scores each (query, code) pair
                        β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                 β”‚
                                 β–Ό
                        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                        β”‚   Final Results  β”‚  ← Top-5 (or Top-N)
                        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
StageTechnologyRole
Dense SearchLanceDB + Embedding ModelSemantic vector similarity
Sparse SearchTantivy BM25Keyword & token matching
RRF FusionReciprocal Rank FusionMerge heterogeneous scores fairly
RerankerCross-Encoder (Qwen3-Reranker-4B)Full-interaction precision scoring
FallbackPetCodeGraphGraph-based name search (no API needed)

If embedding/reranker are unavailable, the pipeline falls back gracefully to graph-based name search and BM25-only mode.

Auto-Indexing Modes

ModeWhenTrigger
MCP serverOn startup + file changescodexray install + restart Claude Code

The MCP server automatically indexes on startup, watches file changes during runtime, and injects CLAUDE.md for tool discovery.

Storage

  • Config: ~/.codexray/config.json (global, shared across all projects)
  • Index: ~/.codexray/<md5(project_root)>/
    • project.json β€” Project metadata
    • graph.bin β€” Serialized call graph
    • embeddings.lance/ β€” LanceDB vector data
    • tantivy_bm25/ β€” BM25 full-text index
    • file_hashes.json β€” MD5 incremental tracking
    • embedding_hashes.json β€” Embedding incremental tracking

No daemon, no HTTP server. Every CLI command is a standalone process.

Supported Languages

LanguageFunctionsStructs/ClassesCall Graph
Rustβœ…βœ…βœ…
Pythonβœ…βœ…βœ…
JavaScriptβœ…βœ…βœ…
TypeScriptβœ…βœ…βœ…
Goβœ…βœ…βœ…
C/C++βœ…βœ…βœ…
Javaβœ…βœ…βœ…

Configuration

~/.codexray/config.json:

{
  "embedding": {
    "provider": "openai-compatible",
    "model": "Qwen/Qwen3-Embedding-4B",
    "api_token": "sk-...",
    "api_base_url": "https://api.siliconflow.cn/v1",
    "dimensions": 2560
  },
  "index": {
    "min_code_block_length": 16,
    "enable_reranker": true,
    "hybrid": {
      "enable_bm25": true,
      "bm25_top_k": 100,
      "vector_top_k": 100,
      "rrf_k": 60,
      "rrf_top_k": 20,
      "short_code_threshold": 30,
      "short_code_penalty": 0.5
    },
    "reranker": {
      "enabled": true,
      "model": "Qwen/Qwen3-Reranker-4B",
      "api_token": "sk-...",
      "api_base_url": "https://api.siliconflow.cn/v1/rerank",
      "top_n": 5,
      "candidate_multiplier": 5,
      "timeout_secs": 60
    }
  },
  "installed_hooks": {}
}

Model Roles

ModelRoleWhen
Qwen/Qwen3-Embedding-4BConverts code β†’ vectors for dense searchIndex building
Qwen/Qwen3-Reranker-4BScores (query, code) pairs for precisionSearch time

Set via the interactive wizard on first run, or create manually. If embedding API is unavailable, graph-based search still works.

Development

cd rust-core

# Build
cargo build

# Build release
cargo build --release

# Run tests
cargo test

# Run specific test
cargo test test_build_graph_functionality -- --nocapture

License

MIT

Built with: Tree-sitter Β· Petgraph Β· LanceDB Β· Tantivy Β· Tokio Β· Clap Β· Axum