code-search-mcp
This server provides semantic code search capabilities for AI assistants, letting them find relevant code by meaning rather than exact keywords.
code_search: Perform natural language semantic searches across indexed code, with optional filters for path, language, result limit, and code-only mode (excluding docs).code_search_status: Check indexing status, progress percentage, total files, and chunk count.code_search_reindex: Trigger a background re-index or force a full rebuild of the vector database.code_search_guide: Retrieve usage tips and best practices for effectively using the search tool.Initialization & indexing: Set up semantic search in a repository, run interactive/non-interactive init, and manage the LanceDB vector index.
Dormant MCP mode: Connects instantly and stays idle with zero CPU usage until the repository is initialized.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@code-search-mcp where is the morning drink discount calculated?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
๐ 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-mcp2. Connect to Your AI Assistant (One-Time)
Claude Code:
claude mcp add code-search -s user -- code-search-mcpAntigravity 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" } } } EOFCursor / 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-mcpPlaces the fast
code-search-mcpbinary 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 initInteractive Wizard Features:
๐ Index Storage Location:
node_modules/.cache/code-search/lancedb(Default for JavaScript/TypeScript projects โ Zero Git Noise).code-search/lancedb(Automatically added to.gitignoreto keep your repo clean)Custom path
๐ก Respect
.gitignore: Automatically skips build outputs, bundles, and vendor folders already in your.gitignore.๐ Search Ignore File (
.codesearchignore): Automatically skips asking if.codesearchignorealready exists. If missing, offers recommended exclude patterns for test fixtures and mock snapshots.๐ File Extension Auto-detection: Scans repository contents to detect active extensions (e.g.
.ts,.tsx,.py,.go,.json,.md), with the option to customize.๐ 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 -yTip: You can change your configuration anytime by editing
.codesearchrc.jsonor.codesearchignore.
๐ป 4. CLI Command Reference
code-search-mcp is both an MCP server and a fast terminal utility:
Command | Description |
| Interactive setup wizard (use |
| Remove configuration and clean vector database index |
| Check index health, total indexed files, chunk counts, and database path |
| Rebuild or update the vector index with live progress (use |
| 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 deductionandEarlyBirdReward, 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
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).
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.
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_searchin an uninitialized repo, it receives clear instructions or can callcode_search_initdirectly.In-Process ONNX Embeddings: Runs
@huggingface/transformersin-process withall-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 |
|
| 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. |
|
| Initializes semantic search for the repository and builds initial index. | When repository is not yet initialized. |
| (none) | Returns current indexing progress ( | Check indexing progress. |
|
| Triggers a background re-index or complete database rebuild. | After massive merges or when user requests rebuild. |
| (none) | Returns inline agent usage best practices and tips. | Call to self-discover best practices during tool invocation. |
๐ก Strongly Recommended Scenarios for code_search:
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 testAll 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
initWizard: 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 toolscode_searchA
Search the codebase semantically using natural language queries (e.g. "how is payment verified", "calculate discount rate"). Returns relevant code snippets with file paths and line numbers. Supports filtering by directory path, programming language, or codeOnly (to exclude markdown docs).
Inputs: query (required), limit, codeOnly, language, +1 more.
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
Scored across 4 tools
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.
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.
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.
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
Related MCP Connectors
Shared memory for coding agents. Stop re-explaining your codebase every session.
Code intelligence for coding agents: semantic, AST, graph, and full-text search. 279+ languages.
Code intelligence for LLMs. Analyze, search, and retrieve code from any public git repository.
Shared memory for AI coding agents. Save once, reuse from Cursor, Claude Code, Codex.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceProvides 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
- AlicenseAqualityDmaintenanceEnables AI assistants to perform intelligent semantic code search across codebases using local AI embeddings for meaning-based retrieval.624 npmMIT
- FlicenseNot gradedqualityDmaintenanceEnables semantic code search across codebases using AI embeddings and vector similarity, integrated with Claude Desktop and Cursor.-
- AlicenseAqualityBmaintenanceEnables 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.4MIT