In one sentence
Searching a codebase by meaning rather than exact text, using embeddings, often combined with keyword search, so a question like "where do we validate refunds" finds the right functions.
Semantic code search finds code by what it does, not only by the words it contains. A keyword search for "refund" misses a function named reverseCharge. A semantic search turns code and questions into embeddings, numeric vectors that place similar meanings close together, and returns the code whose vectors sit nearest the question.
How it works
An indexer splits the codebase into chunks, ideally along real boundaries such as functions and classes rather than fixed line counts. Parsers like Tree-sitter make that possible across many languages. Each chunk is sent to an embedding model and stored with its vector. At query time the question is embedded the same way, and the nearest chunks come back with file paths and line numbers.
Hybrid retrieval
Pure vector search is weak on exact names, error codes and rare identifiers, which keyword search handles well. Most practical tools combine both. A common method is to run a vector search and a BM25 keyword search separately, then merge the two ranked lists with Reciprocal Rank Fusion, which rewards results that rank well in either list. Some tools also boost results whose symbol names or signatures match the query.
Why AI agents need it
A coding agent working on a large repository cannot read every file. Good retrieval decides whether it finds the right function on the first try or wastes its context window on guesses. This is the same idea as retrieval-augmented generation, applied to source code instead of documents. Exposing search as a Model Context Protocol tool lets any MCP client use the index.
What to check
Indexes go stale when code changes, so look for file watching or incremental updates. Decide where embeddings are computed: a local model keeps code on your machine, a cloud API sends chunks to a provider. If the code is sensitive, check whether the index is encrypted at rest.
Our version
Our open-source CodeVault combines vector embeddings and BM25 through Reciprocal Rank Fusion, chunks code with Tree-sitter across 25+ languages, runs with local Ollama models or cloud APIs, and ships an MCP server. It is listed on our projects page.
Keep following the system
Retrieval-Augmented Generation (RAG)
A method where an AI system first looks up relevant documents and then writes its answer using them.
Model Context Protocol (MCP)
An open standard for connecting compatible AI applications to tools, resources, and prompts.
AI Agent
A system that uses a model and tools to pursue a goal across multiple steps within defined permissions and review boundaries.
API Key Rotation
Replacing or cycling the API keys an application uses, either on a schedule for security or across several keys for failover, without breaking the apps that depend on them.