Logo van codexlens-search

codexlens-search

Community
catlog22

Lightweight semantic code search engine — 2-stage vector + FTS + RRF fusion + MCP server for Claude Code

Uitgevercatlog22
Repositorycodexlens-search
TaalPython
Forks
7
Sterren
47
Beschikbare tools
0
Transporttypestdio
Categorieën
LicentieMIT
Links
  • Koppel tools aan AI-workflows

    codexlens-search biedt MCP-functionaliteit die compatibele AI-clients en agenten kunnen gebruiken.

  • 0 beschikbare tools

    Bekijk hieronder de aanroepbare acties, inclusief namen en beschrijvingen als de server die beschikbaar stelt.

  • Configuratie om direct te kopiëren

    Gebruik de installatievoorbeelden om deze server in je favoriete MCP-client te configureren.

  • Indicatoren van opensource-interesse

    47 sterren en 7 forks in de gekoppelde repository.

codexlens-search

Semantic code search engine with MCP server for Claude Code.

Hybrid search: vector + FTS + AST graph + ripgrep regex — with RRF fusion and reranking.

中文文档

Quick Start

bash
pip install codexlens-search[all]

Add to your project .mcp.json:

json
{
  "mcpServers": {
    "codexlens": {
      "command": "uvx",
      "args": ["--from", "codexlens-search[all]", "codexlens-mcp"],
      "env": {
        "CODEXLENS_EMBED_API_URL": "https://api.openai.com/v1",
        "CODEXLENS_EMBED_API_KEY": "${OPENAI_API_KEY}",
        "CODEXLENS_EMBED_API_MODEL": "text-embedding-3-small",
        "CODEXLENS_EMBED_DIM": "1536"
      }
    }
  }
}

That's it. Claude Code will auto-discover the tools: index_project -> Search -> locate.

To enable LLM-enhanced search (locate), add LLM API keys:

json
{
  "mcpServers": {
    "codexlens": {
      "command": "uvx",
      "args": ["--from", "codexlens-search[all]", "codexlens-mcp"],
      "env": {
        "CODEXLENS_EMBED_API_URL": "https://api.openai.com/v1",
        "CODEXLENS_EMBED_API_KEY": "${OPENAI_API_KEY}",
        "CODEXLENS_EMBED_API_MODEL": "text-embedding-3-small",
        "CODEXLENS_EMBED_DIM": "1536",
        "CODEXLENS_LLM_EXPAND_API_KEY": "${GLM_API_KEY}",
        "CODEXLENS_LLM_EXPAND_MODEL": "glm-5-turbo",
        "CODEXLENS_LLM_EXPAND_API_BASE": "https://open.bigmodel.cn/api/paas/v4/"
      }
    }
  }
}

Install

Choose the install that matches your platform:

bash
# Minimal — CPU inference (fastembed bundles onnxruntime CPU)
pip install codexlens-search

# Windows GPU — DirectML, any DirectX 12 GPU (NVIDIA/AMD/Intel)
pip install codexlens-search[directml]

# Linux/Windows NVIDIA GPU — CUDA (requires CUDA + cuDNN)
pip install codexlens-search[cuda]

# Auto-select — DirectML on Windows, CPU elsewhere
pip install codexlens-search[all]

Platform Recommendations

PlatformRecommendedCommand
Windows + any GPU[directml]pip install codexlens-search[directml]
Windows CPU onlybasepip install codexlens-search
Linux + NVIDIA GPU[cuda]pip install codexlens-search[cuda]
Linux CPU / AMD GPUbasepip install codexlens-search
macOS (Apple Silicon)basepip install codexlens-search
Don't know / CI[all]pip install codexlens-search[all]

Note: On Windows, if you install the base package without [directml], the MCP server will auto-detect the missing GPU runtime and install onnxruntime-directml on first launch. GPU takes effect from the second start.

What's Included

All install variants include:

  • MCP server — codexlens-mcp command
  • AST parsing — tree-sitter symbol extraction + graph search
  • USearch — high-performance HNSW ANN backend (default)
  • FAISS — ANN + binary index backend (Hamming coarse search)
  • File watcher — watchdog auto-indexing
  • Gitignore filtering — recursive .gitignore support
  • Focused search — when no index exists, greps relevant files, indexes only those (~10s), then runs semantic search — no waiting for full index build

ANN Backend Selection

Three backends for approximate nearest neighbor search, auto-selected in order:

BackendInstallBest for
usearch (default)IncludedCross-platform, fastest CPU HNSW
faissIncludedGPU acceleration, binary Hamming search
hnswlibIncludedLightweight fallback

Override with CODEXLENS_ANN_BACKEND:

bash
CODEXLENS_ANN_BACKEND=faiss    # use FAISS (GPU when available)
CODEXLENS_ANN_BACKEND=usearch  # use USearch (default)
CODEXLENS_ANN_BACKEND=hnswlib  # use hnswlib
CODEXLENS_ANN_BACKEND=auto     # auto-select (usearch > faiss > hnswlib)

MCP Tools

Search

Hybrid code search combining semantic vector, FTS, AST graph, and ripgrep regex.

ModeDescriptionRequires
auto (default)Semantic + regex parallel. No index? Focused grep-index-search in ~10s.
symbolFind definitions by exact/fuzzy name matchIndex
refsFind cross-references — incoming and outgoing edgesIndex
regexRipgrep regex on live filesrg

Parameters: project_path, query, mode, scope (restricts auto/regex to subdirectory)

Results capped by CODEXLENS_TOP_K env var (default 10).

Cold Start Search

When no index exists, auto mode uses a focused search pipeline instead of waiting for a full index build:

  1. Expand query — split camelCase/snake_case into search terms
  2. Grep files — rg --count finds top 50 relevant files, ranked by match count
  3. Index — embed only those 50 files (~8-10s with GPU)
  4. Search — semantic vector search on the fresh index
  5. Background — full index builds asynchronously for next queries

This gives semantic results in ~10s vs ~100s for a full index build.

locate

LLM-enhanced code localization — finds files relevant to a bug fix or feature request.

Uses a single LLM call to expand the query into symbols, concepts, and alternative search queries, then runs multiple pipeline searches and merges results via reciprocal rank fusion (RRF). Achieves recall comparable to iterative agent approaches at ~10s latency (vs ~60s for full agent loops).

Parameters: project_path, query, top_k (default 10), llm_expand (default true)

Set llm_expand=false to use plain pipeline search without LLM.

Requires LLM API configuration (any OpenAI-compatible API — GLM, DeepSeek, Qwen, OpenAI, etc.):

json
{
  "mcpServers": {
    "codexlens": {
      "command": "uvx",
      "args": ["--from", "codexlens-search[all]", "codexlens-mcp"],
      "env": {
        "CODEXLENS_EMBED_API_URL": "https://api.openai.com/v1",
        "CODEXLENS_EMBED_API_KEY": "${OPENAI_API_KEY}",
        "CODEXLENS_EMBED_API_MODEL": "text-embedding-3-small",
        "CODEXLENS_EMBED_DIM": "1536",
        "CODEXLENS_LLM_EXPAND_API_KEY": "${GLM_API_KEY}",
        "CODEXLENS_LLM_EXPAND_MODEL": "glm-5-turbo",
        "CODEXLENS_LLM_EXPAND_API_BASE": "https://open.bigmodel.cn/api/paas/v4/"
      }
    }
  }
}

Falls back to plain pipeline search if no LLM API key is configured.

How it works

  1. LLM Query Expansion — a single LLM call extracts symbols, technical concepts, error terms, and alternative search queries from the issue description
  2. Multi-Query Search — runs the original query plus expanded queries through the hybrid pipeline (vector + FTS + graph + regex)
  3. RRF Fusion — merges all result lists via reciprocal rank fusion for robust ranking
  4. Reranking — applies cross-encoder reranker (if configured) for final top-k

index_project

Build, update, or inspect the search index.

ActionDescription
sync (default)Incremental — only changed files
rebuildFull re-index from scratch
statusIndex statistics (files, chunks, symbols, refs)

Parameters: project_path, action, scope

find_files

Glob-based file discovery. Parameters: project_path, pattern (default **/*)

Max results controlled by CODEXLENS_FIND_MAX_RESULTS env var (default 100).

watch_project

Manage file watcher for automatic re-indexing on file changes.

Parameters: project_path, action (start / stop / status)

AST Features

Enabled by default. Disable with CODEXLENS_AST_CHUNKING=false.

  • Smart chunking — splits at symbol boundaries instead of fixed-size windows
  • Symbol extraction — 12 kinds: function, class, method, module, variable, constant, interface, type_alias, enum, struct, trait, property
  • Cross-references — import, call, inherit, type_ref edges
  • Graph search — seeded from vector/FTS results, BFS expansion with adaptive weights
  • Query expansion — two-hop symbol vocabulary expansion for natural language queries

Languages: Python, JavaScript, TypeScript, Go, Java, Rust, C, C++, Ruby, PHP, Scala, Kotlin, Swift, C#, Bash, Lua, Haskell, Elixir, Erlang.

Configuration Examples

Reranker (best quality)

Add reranker API on top of the Quick Start config:

json
"CODEXLENS_RERANKER_API_URL": "https://api.jina.ai/v1",
"CODEXLENS_RERANKER_API_KEY": "${JINA_API_KEY}",
"CODEXLENS_RERANKER_API_MODEL": "jina-reranker-v2-base-multilingual"

Multi-Endpoint Load Balancing

json
"CODEXLENS_EMBED_API_ENDPOINTS": "https://api1.example.com/v1|sk-key1|model,https://api2.example.com/v1|sk-key2|model",
"CODEXLENS_EMBED_DIM": "1536"

Format: url|key|model,url|key|model,... — replaces single-endpoint EMBED_API_URL/KEY/MODEL.

Local Models (Offline)

No API needed — fastembed runs the model locally via ONNX runtime.

bash
# List available models
codexlens-search list-models

# Pre-download models (optional — auto-downloads on first use)
codexlens-search download-models

# Download a specific model
codexlens-search download-model nomic-ai/nomic-embed-text-v1.5-Q
json
{
  "mcpServers": {
    "codexlens": {
      "command": "codexlens-mcp",
      "env": {
        "CODEXLENS_DEVICE": "directml"
      }
    }
  }
}

Default local model: BAAI/bge-small-en-v1.5 (384d, 512 tokens). To use a different model:

json
{
  "mcpServers": {
    "codexlens": {
      "command": "codexlens-mcp",
      "env": {
        "CODEXLENS_EMBED_MODEL": "nomic-ai/nomic-embed-text-v1.5-Q",
        "CODEXLENS_EMBED_DIM": "768",
        "CODEXLENS_DEVICE": "directml"
      }
    }
  }
}

Available Local Models

General

ModelDimTokensSizeNotes
BAAI/bge-small-en-v1.538451268MBDefault, fastest
BAAI/bge-base-en-v1.5768512215MBBetter quality
BAAI/bge-large-en-v1.510245121.2GBBest English quality
sentence-transformers/all-MiniLM-L6-v238425692MBLightweight general
snowflake/snowflake-arctic-embed-xs38451292MBCompact, good quality
snowflake/snowflake-arctic-embed-s384512133MBLight, better than xs

Code / Long Context

ModelDimTokensSizeNotes
jinaai/jina-embeddings-v2-base-code7688192655MBCode-specialized, 30+ programming languages
nomic-ai/nomic-embed-text-v1.5-Q7688192133MBQuantized, best value for code
nomic-ai/nomic-embed-text-v1.57688192532MBLong context, code + text
jinaai/jina-embeddings-v2-small-en5128192122MBLong context, lightweight

Chinese / Multilingual

ModelDimTokensSizeNotes
BAAI/bge-small-zh-v1.551251292MBChinese, fast
BAAI/bge-large-zh-v1.510245121.2GBChinese, best quality
jinaai/jina-embeddings-v2-base-zh7688192655MBChinese-English bilingual
intfloat/multilingual-e5-large10245122.2GB100+ languages

CODEXLENS_EMBED_DIM must match the model's output dimension. Mismatched dim will cause indexing errors.

Recommended for Code Search

Use caseModelWhy
Best valuenomic-ai/nomic-embed-text-v1.5-Q768d, 8192 tokens, only 133MB
Code-specializedjinaai/jina-embeddings-v2-base-codeTrained on 30+ programming languages
Lightweight + long contextjinaai/jina-embeddings-v2-small-en512d, 8192 tokens, 122MB
FastestBAAI/bge-small-en-v1.5384d, 68MB, default

Manual Model Download

If codexlens-search download-model fails (e.g. behind a firewall), you can download models manually:

  1. Find the ONNX repo — fastembed remaps model names. Check the actual HuggingFace repo:

    Model nameActual HF repo
    BAAI/bge-small-en-v1.5qdrant/bge-small-en-v1.5-onnx-q
    nomic-ai/nomic-embed-text-v1.5-Qnomic-ai/nomic-embed-text-v1.5
    jinaai/jina-embeddings-v2-base-codejinaai/jina-embeddings-v2-base-code

    Run codexlens-search list-models --json to check cache paths.

  2. Download from HuggingFace — clone or download the repo:

    bash
    # Using git (requires git-lfs)
    git lfs install
    git clone https://huggingface.co/qdrant/bge-small-en-v1.5-onnx-q
    
    # Or download via huggingface-cli
    pip install huggingface-hub
    huggingface-cli download qdrant/bge-small-en-v1.5-onnx-q --local-dir ./model-files
  3. Place in cache directory — the cache follows HuggingFace Hub layout:

    <cache_dir>/
      models--<org>--<model>/
        snapshots/
          <commit_hash>/
            model_optimized.onnx   (or model.onnx)
            tokenizer.json
            config.json
            special_tokens_map.json
            tokenizer_config.json

    Default cache locations:

    • Windows: %LOCALAPPDATA%\fastembed_cache or %TEMP%\fastembed_cache
    • Linux/macOS: /tmp/fastembed_cache
    • Custom: set CODEXLENS_MODEL_CACHE_DIR

    Example for BAAI/bge-small-en-v1.5:

    bash
    mkdir -p /tmp/fastembed_cache/models--qdrant--bge-small-en-v1.5-onnx-q/snapshots/main/
    cp model-files/*.onnx model-files/*.json \
       /tmp/fastembed_cache/models--qdrant--bge-small-en-v1.5-onnx-q/snapshots/main/
  4. Verify — run codexlens-search list-models and check the ● status.

China Mirror

json
"CODEXLENS_HF_MIRROR": "https://hf-mirror.com"

Custom Model Cache

json
"CODEXLENS_MODEL_CACHE_DIR": "/path/to/cache"

GPU

Windows: pip install codexlens-search[directml] — works with any DirectX 12 GPU (NVIDIA/AMD/Intel). No CUDA needed. Even without [directml], the server auto-installs it on first launch.

Linux: pip install codexlens-search[cuda] adds CUDA support (requires CUDA + cuDNN).

Auto-detection priority: CUDA > DirectML > CPU

  • Embedding — ONNX runtime selects best available GPU provider, ~12x faster than CPU
  • FAISS — index auto-transfers to GPU 0 (CUDA only)

Force specific device: CODEXLENS_DEVICE=directml / cuda / cpu

CLI

bash
codexlens-search --db-path .codexlens sync --root ./src
codexlens-search --db-path .codexlens search -q "auth handler" -k 10
codexlens-search --db-path .codexlens status
codexlens-search list-models
codexlens-search download-models
codexlens-search download-model BAAI/bge-base-en-v1.5
codexlens-search delete-model BAAI/bge-small-en-v1.5

Environment Variables

Local Model

VariableDefaultDescription
CODEXLENS_EMBED_MODELBAAI/bge-small-en-v1.5Local fastembed model name
CODEXLENS_EMBED_DIM384Vector dimension (must match model)
CODEXLENS_MODEL_CACHE_DIRfastembed defaultModel download cache directory
CODEXLENS_HF_MIRRORHuggingFace mirror (e.g. https://hf-mirror.com)

Embedding API (overrides local model)

VariableDescription
CODEXLENS_EMBED_API_URLAPI base URL (e.g. https://api.openai.com/v1)
CODEXLENS_EMBED_API_KEYAPI key
CODEXLENS_EMBED_API_MODELModel name (e.g. text-embedding-3-small)
CODEXLENS_EMBED_API_ENDPOINTSMulti-endpoint: url|key|model,...

Reranker

VariableDescription
CODEXLENS_RERANKER_API_URLReranker API base URL
CODEXLENS_RERANKER_API_KEYAPI key
CODEXLENS_RERANKER_API_MODELModel name

LLM Query Expansion (locate tool)

VariableDefaultDescription
CODEXLENS_LLM_EXPAND_ENABLEDfalseEnable LLM expansion globally for search_files
CODEXLENS_LLM_EXPAND_API_KEYAPI key (any OpenAI-compatible LLM)
CODEXLENS_LLM_EXPAND_MODELglm-5-turboModel name
CODEXLENS_LLM_EXPAND_API_BASEhttps://open.bigmodel.cn/api/paas/v4/API base URL

Fallback: If CODEXLENS_LLM_EXPAND_* vars are not set, the system also checks CODEXLENS_AGENT_LLM_* vars for backward compatibility.

Features

VariableDefaultDescription
CODEXLENS_AST_CHUNKINGtrueAST chunking + symbol extraction
CODEXLENS_GITIGNORE_FILTERINGtrueRecursive .gitignore filtering
CODEXLENS_EXPANSION_ENABLEDtrueTwo-hop query expansion for NL queries
CODEXLENS_DEVICEautoauto / cuda / directml / cpu
CODEXLENS_AUTO_WATCHfalseAuto-start file watcher after indexing

MCP Tool Defaults

VariableDefaultDescription
CODEXLENS_TOP_K10Search result limit
CODEXLENS_FIND_MAX_RESULTS100find_files result limit

Tuning

VariableDefaultDescription
CODEXLENS_BINARY_TOP_K200Binary coarse search candidates
CODEXLENS_ANN_TOP_K50ANN fine search candidates
CODEXLENS_FTS_TOP_K50FTS results per method
CODEXLENS_FUSION_K60RRF fusion k parameter
CODEXLENS_RERANKER_TOP_K20Results to rerank
CODEXLENS_EMBED_BATCH_SIZE32Texts per API batch
CODEXLENS_EMBED_MAX_TOKENS8192Max tokens per text (0=no limit)
CODEXLENS_INDEX_WORKERS2Parallel indexing workers
CODEXLENS_MAX_FILE_SIZE1000000Max file size in bytes

Architecture

Query -> [QueryExpander] -> expanded query (NL queries only)
          |-> [Embedder] -> query vector
          |     |-> [FAISS Binary] -> candidates (Hamming)
          |     |     +-> [USearch/FAISS HNSW] -> ranked IDs (cosine)
          |     +-> [FTS exact + fuzzy] -> text matches
          |-> [GraphSearcher] -> symbol neighbors (seeded from vector/FTS)
          +-> [ripgrep] -> regex matches
               +-> [RRF Fusion] -> merged ranking
                     +-> [Reranker] -> final top-k

Development

bash
git clone https://github.com/catlog22/codexlens-search.git
cd codexlens-search
pip install -e ".[dev,all]"
pytest

License

MIT

Installatie

TypingMind
Vereisten:

Node.js 18+

{
  "mcpServers": {
    "catlog22-codexlens-search": {
      "command": "uvx",
      "args": [
        "codexlens-search"
      ]
    }
  }
}

Gebruik codexlens-search MCP met meerdere AI-modellen

TypingMind koppelt MCP-tools aan de werkruimte. Zodra codexlens-search is verbonden, kun je deze dus met verschillende AI-modellen in TypingMind gebruiken, zonder de verbinding voor elk model apart in te stellen. Deze MCP-integratie draait lokaal via de TypingMind MCP-connector op je apparaat.

Installatiehandleiding voor de lokale connector

Gebruik dit als de MCP-server toegang nodig heeft tot lokale bestanden, apps of privébronnen op je computer.

1

Open de MCP-instellingen

Ga in TypingMind naar Instellingen, Geavanceerde instellingen en vervolgens Model Context Protocol. Kies daar Connector instellen.

  1. Open TypingMind in je browser.
  2. Klik op het pictogram Instellingen.
  3. Ga naar Geavanceerde instellingen.
  4. Open het gedeelte Model Context Protocol.
  5. Klik op Connector instellen en kies Dit apparaat.
Instelscherm voor de TypingMind MCP-connector met Dit apparaat geselecteerd
2

Voer de connectoropdracht uit

Kies Dit apparaat, kopieer de opdracht uit TypingMind en voer deze uit in Terminal. Laat het proces draaien zolang je MCP gebruikt.

  1. Kopieer de installatieopdracht die TypingMind toont.
  2. Open Terminal op macOS of Windows Terminal op Windows.
  3. Plak de opdracht en voer deze uit.
  4. Keur de pakketinstallatie goed als Terminal vraagt of je wilt doorgaan.
  5. Laat het proces in het Terminal-venster draaien zolang je MCP-tools gebruikt.
3

Voeg codexlens-search toe als server

Klik op Servers bewerken zodra de connectorstatus Gereed is en plak de MCP-serverconfiguratie.

  1. Wacht tot de connectorstatus Gereed aangeeft.
  2. Klik op Servers bewerken.
  3. Plak de MCP-serverconfiguratie van codexlens-search.
  4. Sla de serverlijst op.
  5. Vernieuw om te controleren of de connector nog steeds klaar is voor gebruik.
MCP-instellingen van TypingMind met een actieve server en de knop Servers bewerken
{
  "mcpServers": {
    "catlog22-codexlens-search": {
      "command": "npx",
      "args": [
        "-y",
        "codexlens-search"
      ]
    }
  }
}
4

Gebruik de verbinding met verschillende modellen

Sla de serverlijst op, open Plug-ins en schakel de MCP-tools van codexlens-search in. Selecteer vervolgens een ondersteund AI-model in TypingMind en gebruik de tools in de chat of wijs ze toe aan een AI-agent.

  1. Open de pagina Plug-ins in TypingMind.
  2. Schakel de MCP-tools van codexlens-search in.
  3. Start een chat en kies het AI-model dat je wilt gebruiken.
  4. Gebruik de MCP-tools in een chat of wijs ze toe aan een AI-agent.
  5. Schakel wanneer nodig over naar een ander AI-model zonder opnieuw verbinding te maken met MCP.
TypingMind-chat met ingeschakelde MCP-tools en een geselecteerd AI-model
Kun je codexlens-search gebruiken om me hiermee te helpen?
codexlens-search
Zeker. Ik heb het gelezen.
Dit vond ik met codexlens-search.

Veelgestelde vragen

Waarvoor wordt de MCP-server codexlens-search gebruikt?

codexlens-search is een MCP-server waarmee compatibele AI-clients verbinding kunnen maken met externe tools en context. In TypingMind hoef je deze MCP-server maar één keer toe te voegen om de tools beschikbaar te maken in je AI-werkruimte.

Kan ik codexlens-search MCP met meerdere AI-modellen in TypingMind gebruiken?

Ja. TypingMind verbindt MCP-tools op werkruimteniveau. Daardoor kun je codexlens-search gebruiken met verschillende AI-modellen, zoals Claude, ChatGPT, Gemini of andere modellen die je in TypingMind hebt ingesteld, zonder de MCP-server voor elk model afzonderlijk in te stellen.

Waarom codexlens-search MCP gebruiken met TypingMind?

TypingMind is een van de beste interfaces voor chats met LLM's, omdat het meerdere AI-modellen, prompts, plug-ins, AI-agenten, API-sleutels en MCP-tools samenbrengt in één werkruimte. Als codexlens-search verbonden is, kun je de MCP-tools ervan gebruiken met je favoriete modellen en je chatworkflow overzichtelijk houden in TypingMind.

Hoe verbind ik codexlens-search MCP met TypingMind?

codexlens-search werkt via de lokale MCP-connector van TypingMind. Dit is de beste optie als de MCP-server toegang nodig heeft tot lokale bestanden, desktopapps, opdrachtregeltools of privébronnen op je computer.

Welke tools biedt codexlens-search MCP in TypingMind?

codexlens-search biedt MCP-functies die je kunt inschakelen via de pagina Plug-ins in TypingMind. Je kunt ze gebruiken in chats of toewijzen aan AI-agenten.

Moet ik mijn API-sleutels delen met TypingMind om codexlens-search MCP te gebruiken?

Nee. TypingMind werkt in de eerste plaats lokaal en laat je de controle houden over je modelaanbieders, API-sleutels, prompts en MCP-configuratie. Als codexlens-search authenticatie vereist, voeg je bij het maken van de verbinding de vereiste headers, OAuth-instellingen of lokale configuratie voor die MCP-server toe.

Gerelateerde MCP-servers

Toon alles

Maak nu je eigen AI-werkruimte

Schrijf je in voor onze nieuwsbrief en blijf op de hoogte van nieuwe functies en toekomstige weggeefacties 👇