Skip to main content
Glama
code-search-mcp

code-search-mcp

by genautkin

๐Ÿ” code-search-mcp

Zero-daemon local semantic code search MCP server and CLI powered by LanceDB and in-process ONNX embeddings.
Stop grepping for exact words. Give your AI coding assistant the power to search your codebase by meaning.

Works out-of-the-box with Claude Code, Gemini CLI, Antigravity (agy), and Cursor on macOS, Windows, and Linux.


โšก๏ธ Quick Start (30-Second Setup)

1. Install Globally

npm install -g github:genautkin/code-search-mcp

2. Connect to Your AI Assistant (One-Time)

  • Claude Code:

    claude mcp add code-search -s user -- code-search-mcp
  • Antigravity CLI (agy):

    mkdir -p ~/.gemini/config/plugins/code-search && cat << 'EOF' > ~/.gemini/config/plugins/code-search/mcp_config.json
    {
      "mcpServers": {
        "code-search": {
          "command": "code-search-mcp"
        }
      }
    }
    EOF
  • Cursor / Claude Desktop / Gemini CLI: Add "code-search": { "command": "code-search-mcp" } to your MCP configuration file.

3. Initialize in Any Project

Navigate to any repository and run:

code-search-mcp init

(Or run code-search-mcp init -y for 1-second automated setup with smart defaults)

Now you and your AI coding assistant can search your codebase by meaning! ๐Ÿš€


Related MCP server: smart-coding-mcp

๐Ÿ“– Detailed Guide

๐Ÿ“ฆ 1. Installation

You can install code-search-mcp globally or run it on demand:

  • Global Installation (Recommended):

    npm install -g github:genautkin/code-search-mcp

    Places the fast code-search-mcp binary into your system PATH.

  • On-Demand Execution (No global install):

    npx github:genautkin/code-search-mcp init

๐Ÿ”Œ 2. Connecting to MCP Clients

code-search-mcp operates as a high-speed stdio MCP server. When registered globally, it works across all your projects without draining battery or running background daemons on uninitialized repos.

๐Ÿง  Claude Code

# Available globally across all projects:
claude mcp add code-search -s user -- code-search-mcp

# Or scoped to a single specific project directory:
claude mcp add code-search -- code-search-mcp --path /path/to/your/project

๐Ÿค– Antigravity CLI (agy)

Register the plugin in your user settings:

mkdir -p ~/.gemini/config/plugins/code-search && cat << 'EOF' > ~/.gemini/config/plugins/code-search/plugin.json
{ "name": "code-search" }
EOF
cat << 'EOF' > ~/.gemini/config/plugins/code-search/mcp_config.json
{
  "mcpServers": {
    "code-search": {
      "command": "code-search-mcp"
    }
  }
}
EOF

๐Ÿช„ Gemini CLI

Add to ~/.gemini/settings.json (or workspace .gemini/settings.json):

{
  "mcpServers": {
    "code-search": {
      "command": "code-search-mcp",
      "trust": true
    }
  }
}

๐Ÿ’ป Cursor / Claude Desktop / Windsurf

Add to .cursor/mcp.json or claude_desktop_config.json:

{
  "mcpServers": {
    "code-search": {
      "command": "code-search-mcp",
      "args": ["--path", "${workspaceFolder}"]
    }
  }
}

๐Ÿช„ 3. Initializing a Project (init)

To activate semantic search for a repository, run the interactive setup wizard:

code-search-mcp init

Interactive Wizard Features:

  1. ๐Ÿ“ Index Storage Location:

    • node_modules/.cache/code-search/lancedb (Default for JavaScript/TypeScript projects โ€” Zero Git Noise)

    • .code-search/lancedb (Automatically added to .gitignore to keep your repo clean)

    • Custom path

  2. ๐Ÿ›ก Respect .gitignore: Automatically skips build outputs, bundles, and vendor folders already in your .gitignore.

  3. ๐Ÿ“ Search Ignore File (.codesearchignore): Automatically skips asking if .codesearchignore already exists. If missing, offers recommended exclude patterns for test fixtures and mock snapshots.

  4. ๐Ÿ” File Extension Auto-detection: Scans repository contents to detect active extensions (e.g. .ts, .tsx, .py, .go, .json, .md), with the option to customize.

  5. ๐Ÿš€ Initial Indexing: Builds initial vector index immediately with live progress and status summary.

Non-Interactive / CI Setup:

Pass -y to skip questions and apply smart defaults:

code-search-mcp init -y

Tip: You can change your configuration anytime by editing .codesearchrc.json or .codesearchignore.


๐Ÿ’ป 4. CLI Command Reference

code-search-mcp is both an MCP server and a fast terminal utility:

Command

Description

code-search-mcp init [path]

Interactive setup wizard (use -y for non-interactive)

code-search-mcp uninit [path]

Remove configuration and clean vector database index

code-search-mcp status [path]

Check index health, total indexed files, chunk counts, and database path

code-search-mcp index [path]

Rebuild or update the vector index with live progress (use -f for full clean rebuild)

code-search-mcp search <query>

Run semantic search directly from your terminal with syntax highlighting


โ˜•๏ธ Imagine a Coffee Shop App

Imagine you are building software for a busy local coffee shop.

In your codebase, you have a file that handles what happens when a customer orders an extra oat milk latte and gets a morning discount:

// Apply a 15% promotional deduction if the customer visits before 9 AM
export function calculateEarlyBirdReward(bill: OrderSummary): number {
  if (bill.orderHour < 9) {
    return bill.subtotal * 0.85;
  }
  return bill.subtotal;
}

Now imagine you open your AI coding assistant (like Claude Code, Cursor, or Gemini CLI) and ask:

"Where is the morning drink discount calculated?"

If your tool relies only on traditional text search (like grep), it searches for the exact word "discount".

  • Did it find calculateEarlyBirdReward? No.

  • Why? Because the code used the words promotional deduction and EarlyBirdReward, but never the exact word "discount".

This is where Semantic Search changes everything.


๐Ÿง  What is Semantic Search (In Plain English)?

Traditional search looks for exact letters and words.

Semantic search looks for the meaning behind your words.

How It Works: The Map of Meaning

  1. Numbers instead of letters: An AI model takes a piece of text (or code) and translates it into a list of numbers called an embedding (or vector).

  2. Coordinates on a map: Think of these numbers like GPS coordinates on a giant map of human concepts.

    • "discount" and "promotional deduction" end up sitting right next to each other on the map.

    • "espresso shot" and "latte" sit together.

    • "database migration" sits far away on the other side of the map.

  3. Finding nearest neighbors: When you ask a question in plain English, the search engine turns your question into coordinates and simply finds the pieces of code sitting closest to it on the map.

                  [ Map of Meaning ]

   โ˜•๏ธ "morning drink discount"   ๐Ÿ“ (Your Question)
              โ”‚ (Close match!)
              โ–ผ
   ๐Ÿท "calculateEarlyBirdReward" ๐Ÿ“ (Your Code)
   
   โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
   
   ๐Ÿ—„ "sql database migration"   ๐Ÿ“ (Far Away - Ignored)

๐Ÿš€ Why Semantic Search is a Game-Changer for AI Coding

When AI coding assistants work on large repositories with thousands of files, they cannot read every single file on every prompt โ€” it is too slow and costs too many tokens.

Instead, the AI needs to find the exact 2 or 3 relevant files instantly.

In real-world projects, our codebases are full of rich context:

  • Markdown documentation (.md): Architecture decision records, API guides, onboarding docs.

  • Code comments: Explaining why a business rule exists (e.g. // Deduct beans from bean hopper inventory).

  • Function and variable names: Naming patterns that may differ across libraries.

Semantic search connects your natural language thoughts directly to those markdown docs, comments, and code snippets โ€” even when you do not remember the exact function names.


๐Ÿ›  Architecture & Dormant MCP Mode

Many existing semantic search tools for developers require heavy setups (Python, virtual environments, external background daemons).

code-search-mcp is designed around Explicit Opt-In & Zero Resource Waste:

  • Dormant by Default: If a repository does not have .codesearchrc.json, the MCP server connects instantly in <10ms and stays dormant โ€” zero background workers, zero file watchers, and zero CPU usage until initialized.

  • On-Demand AI Initialization: If an AI assistant calls code_search in an uninitialized repo, it receives clear instructions or can call code_search_init directly.

  • In-Process ONNX Embeddings: Runs @huggingface/transformers in-process with all-MiniLM-L6-v2. 100% private, zero network calls.

  • Embedded LanceDB: Serverless, embedded vector database.

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                       AI Client                             โ”‚
โ”‚       (Claude Code / Gemini CLI / Antigravity / Cursor)     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                               โ”‚ MCP Protocol (JSON-RPC over stdio)
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                      code-search-mcp                        โ”‚
โ”‚                                                             โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚   Scanner &      โ”‚  โ”‚  EmbeddingEngine โ”‚  โ”‚  Watcher  โ”‚  โ”‚
โ”‚  โ”‚ Layered Ignores  โ”‚  โ”‚  (all-MiniLM-L6) โ”‚  โ”‚(chokidar) โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ”‚           โ”‚                     โ”‚                  โ”‚        โ”‚
โ”‚           โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜        โ”‚
โ”‚                       โ–ผ                                     โ”‚
โ”‚              VectorStore (LanceDB)                          โ”‚
โ”‚        node_modules/.cache/code-search/                     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โš™๏ธ Configuration Reference

.codesearchrc.json

Full repository configuration with JSON Schema support:

{
  "$schema": "https://raw.githubusercontent.com/genautkin/code-search-mcp/main/schema.json",
  "version": 1,
  "indexPath": "node_modules/.cache/code-search/lancedb",
  "respectGitignore": true,
  "supportedExtensions": [".ts", ".tsx", ".js", ".vue", ".py", ".md"],
  "customExcludes": [
    "legacy_vendor/**",
    "docs/archive/**"
  ],
  "maxFileSizeKb": 500,
  "embeddingModel": "Xenova/all-MiniLM-L6-v2"
}

.codesearchignore

Standard .gitignore style glob file for search exclusions:

# Test fixtures and mocks
**/fixtures/**
**/mocks/**
*.snap

# Auto-generated code
*.generated.*
locales/**

๐Ÿค– AI Agent Guide & Tool Reference

If you are an AI assistant (Claude Code, Gemini CLI, Cursor, Antigravity, or Windsurf) reading this repository:

๐Ÿ› ๏ธ Available MCP Tools

Tool Name

Arguments

Description

When to Call

code_search

query (required)limit (optional, default 10)pathFilter (optional string)language (optional string)codeOnly (optional boolean)

Performs hybrid semantic + lexical search across indexed repository files. Returns line-numbered code chunks with similarity scores.

Primary tool for natural language & conceptual queries: Call whenever locating concepts, business logic, workflows, UI components, or features described in natural language, before attempting blind greps.

code_search_init

indexPath (optional)respectGitignore (optional)supportedExtensions (optional)

Initializes semantic search for the repository and builds initial index.

When repository is not yet initialized.

code_search_status

(none)

Returns current indexing progress (READY, INDEXING, UNINITIALIZED), percentage, total files, and chunk count in LanceDB.

Check indexing progress.

code_search_reindex

forceFull (optional boolean)

Triggers a background re-index or complete database rebuild.

After massive merges or when user requests rebuild.

code_search_guide

(none)

Returns inline agent usage best practices and tips.

Call to self-discover best practices during tool invocation.

  • Natural Language & Conceptual Questions: When searching for concepts, domain rules, business workflows, UI components, or features (e.g. "where are authentication tokens refreshed", "how is discount calculated", "dark mode toggle component").

  • Exploring Unfamiliar Codebases: When you do not know the exact file names, functions, or variable names.

  • Finding Meaning Behind Code: When exact keyword search / grep returns too many noisy results or misses synonyms.


๐Ÿงช Verification & Testing

To run the automated test suite:

npm test

All 45 unit & integration tests verify the MCP protocol handshake, ONNX vector generation, LanceDB storage, watcher lifecycle, word stemming, typo correction, init wizard, and dormant server mode.


๐Ÿ’ก Summary

  • โœ… Explicit Opt-in: Dormant until initialized, saving battery and CPU.

  • โœ… Interactive init Wizard: Discovers file types and configures settings with smart defaults.

  • โœ… No background daemons: Zero external background services or Python dependencies.

  • โœ… Zero Git noise: Default storage in node_modules/.cache.

  • โœ… Handles typos & word variations automatically.

  • โœ… Instant search by meaning, connecting natural language questions to the exact code you need.

Happy coding! โ˜•๏ธ๐Ÿš€

Available Tools

4 tools
code_search_guideA

Get best practices and usage instructions for AI agents on how and when to use code_search.

Inputs: no named parameters.

code_search_reindexA

Trigger a background re-index of the repository. Can be used to force a full reindex.

Inputs: forceFull.

code_search_statusA

Get the current indexing status, progress percentage, total files, and indexed chunk count.

Inputs: no named parameters.

Tool Schema Changelog

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

Loading tool schema changelogโ€ฆ

    TDQS

    A4.2/5.0

    Scored across 4 tools

    Disambiguation5/5

    Each tool has a unique, clearly defined purpose: search, status, reindex, and guide. There is no overlap or ambiguity between them, and the descriptions make it obvious which tool to use for each task.

    Naming Consistency5/5

    All tool names follow the same convention: 'code_search_' followed by a simple action verb (search, status, reindex, guide). This is perfectly consistent and makes the tool set easy to predict and use.

    Tool Count5/5

    With 4 tools, the set is tightly scoped and every tool serves a necessary function for a code search server. This is an ideal countโ€”not too thin or over-bloatedโ€”for the domain.

    Completeness5/5

    The tool surface covers the full lifecycle of a code search server: performing searches, checking index status, triggering reindexes, and providing usage guidance. There are no obvious gaps in functionality.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Provides Claude Code with local semantic search and indexing of your codebase using AST-aware chunking and hybrid search, enabling deep code understanding without sending data to the cloud.
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      Enables AI assistants to perform intelligent semantic code search across codebases using local AI embeddings for meaning-based retrieval.
      6
      24 npm
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Enables AI coding assistants to perform local semantic code search using AST parsing and embeddings, finding code by meaning with exact file and line locations, plus AST-based usage lookup.
      4
      MIT