Fast and Accurate Code Search for Agents
Project description

Fast and Accurate Code Search for Agents
Semble is a code search library built for agents. It returns the exact code snippets they need instantly, cutting both token usage and waiting time on every step. Indexing and searching a full codebase end-to-end takes under a second, with ~200x faster indexing and ~10x faster queries than a code-specialized transformer, at 99% of its retrieval quality (see benchmarks). Everything runs on CPU with no API keys, GPU, or external services. Run it as an MCP server and any agent (Claude Code, Cursor, Codex, OpenCode, etc.) gets instant access to any repo, cloned and indexed on demand.
Quickstart
pip install semble # Install with pip
uv add semble # Install with uv
from semble import SembleIndex
# Index a local directory
index = SembleIndex.from_path("./my-project")
# Index a remote git repository
index = SembleIndex.from_git("https://github.com/MinishLab/model2vec")
# Search the index with a natural-language or code query
results = index.search("save model to disk", top_k=3)
# Find code similar to a specific result
related = index.find_related(results[0], top_k=3)
# Each result exposes the matched chunk
result = results[0]
result.chunk.file_path # "model2vec/model.py"
result.chunk.start_line # 127
result.chunk.end_line # 150
result.chunk.content # "def save_pretrained(self, path: PathLike, ..."
Main Features
- Fast: indexes a repo in ~250 ms and answers queries in ~1.5 ms, all on CPU.
- Accurate: NDCG@10 of 0.854 on our benchmarks, on par with code-specialized transformer models, at a fraction of the size and cost.
- Local and remote: pass a local path or a git URL.
- MCP server: drop-in tool for Claude Code, Cursor, Codex, OpenCode, and any other MCP-compatible agent.
- Zero setup: runs on CPU with no API keys, GPU, or external services required.
MCP Server
Semble can run as an MCP server so agents can search any codebase directly. Repos are cloned and indexed on demand, and indexes are cached for the lifetime of the session.
Setup
Requires uv to be installed.
Claude Code
claude mcp add semble -s user -- uvx --from "semble[mcp]" semble
Codex
Add to ~/.codex/config.toml:
[mcp_servers.semble]
command = "uvx"
args = ["--from", "semble[mcp]", "semble"]
OpenCode
Add to ~/.opencode/config.json:
{
"mcp": {
"semble": {
"type": "local",
"command": ["uvx", "--from", "semble[mcp]", "semble"]
}
}
}
Cursor
Add to ~/.cursor/mcp.json (or .cursor/mcp.json in your project):
{
"mcpServers": {
"semble": {
"command": "uvx",
"args": ["--from", "semble[mcp]", "semble"]
}
}
}
Tools
| Tool | Description |
|---|---|
search |
Search a codebase with a natural-language or code query. Pass repo as a git URL or local path. |
find_related |
Given a file path and line number, return chunks semantically similar to the code at that location. |
How it works
Semble splits each file into code-aware chunks using Chonkie, then scores every query against the chunks with two complementary retrievers: static Model2Vec embeddings using the code-specialized potion-code-16M model for semantic similarity, and BM25 for lexical matches on identifiers and API names. The two score lists are fused with Reciprocal Rank Fusion (RRF).
After fusing, results are reranked with a set of code-aware signals:
Ranking signals
- Adaptive weighting. Symbol-like queries (
Foo::bar,_private,getUserById) get more lexical weight, while natural-language queries stay balanced between semantic and lexical retrievers. - Definition boosts. A chunk that defines the queried symbol (a
class,def,func, etc.) is ranked above chunks that merely reference it. - Identifier stems. Query tokens are stemmed and matched against identifier stems in a chunk, giving an additional weight to chunks that contain them. For example, querying
parse configboosts chunks containingparseConfig,ConfigParser, orconfig_parser. - File coherence. When multiple chunks from the same file match the query, the file is boosted so the top result reflects broad file-level relevance rather than a single out-of-context chunk.
- Noise penalties. Test files,
compat//legacy/shims, example code, and.d.tsdeclaration stubs are down-ranked so canonical implementations surface first.
Because the embedding model is static with no transformer forward pass at query time, all of this runs in milliseconds on CPU.
Benchmarks
We benchmark quality and speed across all methods on ~1,250 queries over 63 repositories in 19 languages. The x-axis is total latency (index + first query); the y-axis is NDCG@10. Marker size reflects model parameter count.
| Method | NDCG@10 | Index time | Query p50 |
|---|---|---|---|
| CodeRankEmbed Hybrid | 0.862 | 57 s | 16 ms |
| semble | 0.854 | 263 ms | 1.5 ms |
| CodeRankEmbed | 0.765 | 57 s | 16 ms |
| ColGREP | 0.693 | 5.8 s | 124 ms |
| BM25 | 0.673 | 263 ms | 0.02 ms |
| ripgrep | 0.126 | — | 12 ms |
Semble achieves 99% of the performance of the 137M-parameter CodeRankEmbed Hybrid, while indexing 218x faster and answering queries 11x faster. See benchmarks for per-language results, ablations, and methodology.
License
MIT
Citing
If you use Semble in your research, please cite the following:
@software{minishlab2026semble,
author = {{van Dongen}, Thomas and Stephan Tulkens},
title = {Semble: Fast Code Search for Agents},
year = {2026},
publisher = {Zenodo},
doi = {10.5281/zenodo.XXXXXXX},
url = {https://github.com/MinishLab/semble},
license = {MIT}
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file semble-0.1.0.tar.gz.
File metadata
- Download URL: semble-0.1.0.tar.gz
- Upload date:
- Size: 262.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
35dad55eaf5c805251e0ba503449d64d7dbf6eed78009566c4af4ccbdf96280b
|
|
| MD5 |
6c177330c848a43b604cf809efd97001
|
|
| BLAKE2b-256 |
99db053fc50f909653042ceccf83cbfa046c62daa25a17489e6286b0a2ff2a63
|
File details
Details for the file semble-0.1.0-py3-none-any.whl.
File metadata
- Download URL: semble-0.1.0-py3-none-any.whl
- Upload date:
- Size: 29.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6738b6f792f958a29e8b76eea40a88a04c21974b752e5c742c3ad8e74bbf3342
|
|
| MD5 |
128977f33d3c50989e04eff0f1c1f3e8
|
|
| BLAKE2b-256 |
e31fb2453eab5007b01670b37ec138aea8d974b7847433f66910d7d4d7b171a7
|