turbocontext
The turbocontext server enables high-performance, local codebase indexing and semantic search for AI coding agents via MCP. You can:
Index a codebase: Parse source files (Python, JavaScript, TypeScript, Rust, Go, C++, and more) into AST chunks using Tree-sitter, generate embeddings with FastEmbed, and store them in a 4-bit quantized Turbovec index. Files unchanged since last indexing are automatically skipped; use
force=Trueto re-index everything.Search code semantically: Query the index using natural language; results are retrieved from the vector index and reranked with a cross-encoder (
BAAI/bge-reranker-v2-m3) for sub-20ms, highly relevant context.Add memory notes: Inject plain-text architectural decisions or notes directly into the index, searchable alongside code chunks.
Monitor status: Get diagnostic metrics (chunk, file, memory counts, disk size, model info) for any workspace.
Clear a workspace: Purge all data (chunks, memories, file hashes) for a workspace, resetting its index.
Real-time file watching: Start/stop watchers to automatically update the index on file edits or deletions.
Workspace isolation: Each operation is scoped to a unique
workspace_id, preventing cross-workspace leakage.Optimized performance: 4-bit quantization and efficient algorithms deliver sub-20ms search latency and up to 8x memory compression, suitable for large codebases.
Allows Hermes AI agents to integrate with codebase indexing and search capabilities via MCP.
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., "@turbocontext search my codebase for the error handling middleware"
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.
A 100,000 code chunk index takes 307 MB of RAM as float32. Turbocontext fits it in 38 MB - and searches it in sub-20ms with cross-encoder accuracy.
Turbocontext is a high-performance, real-time codebase indexing engine and vector context retriever for AI coding agents (Claude Code, Cursor, Aider, Hermes, Windsurf, Continue). Built on Tree-sitter AST parsing, FastEmbed local ONNX embeddings, Google Research's TurboQuant 4-bit quantization algorithm via turbovec, and Cross-Encoder reranking, it serves workspace-isolated context queries over Model Context Protocol (MCP) stdio transport.
Incremental online ingest. SHA-256 file hashing skips unchanged files automatically (~90% indexing work saved). Added or modified files are AST-chunked and indexed immediately — no parameter tuning, no separate training step.
8.0x Memory compression. Quantizes dense 768-dim float32 vectors down to 4-bit representations ($384\text{ bytes/vec}$ instead of $3,072\text{ bytes/vec}$), enabling massive codebase indexing in RAM.
Tree-sitter AST breadcrumbs. Decomposes multi-language source code (
.py,.js,.ts,.rs,.go,.cpp,.c,.java,.html,.css,.json) into semantic function and class blocks with prepended breadcrumbs (File: [path]\nType: [Class|Function]\n\n[code]).Filtered allowlist search. Pass a workspace
uint64ID allowlist tosearch()and the Turbovec kernel honours it directly. You get zero cross-workspace data leakage and no over-fetching penalty.Two-stage cross-encoder precision. Oversamples candidate vectors from Turbovec search, then reranks top candidates using
BAAI/bge-reranker-v2-m3cross-encoder to eliminate context noise.Pure local & air-gapped. Runs locally via stdio MCP. No cloud API calls, no third-party vector database service, no code leaving your machine or VPC.
Building AI agent workflows where context quality, RAM footprint, or sub-20ms latency matters? You're in the right place.
Quickstart (Python & MCP)
Environment Setup
# Clone the repository
git clone https://github.com/e-x-h-i-b-i-t/turbocontext.git
cd turbocontext
# Synchronize dependencies with uv
uv sync
# Run FastMCP stdio server
uv run python src/server.pyPython API Usage
import numpy as np
from storage import VectorStore
from indexer import index_file
# Initialize VectorStore with local SQLite + Turbovec 4-bit index
store = VectorStore(db_path="storage.db", dim=768, bit_width=4)
# Index a source file (AST chunking + FastEmbed vectorization + SHA-256 hash skip)
chunks_indexed = index_file("src/server.py", workspace_id="my_project", vector_store=store)
# Search with two-stage vector search + cross-encoder reranking
query_text = "FastMCP stdio server tools"
query_vec = np.random.randn(768).astype(np.float32) # Generated via FastEmbed
results = store.search(
query_vector=query_vec,
workspace_id="my_project",
top_k=20, # Oversample 20 candidates from Turbovec
query_text=query_text,
final_k=3 # Rerank to top 3 best chunks
)
for res in results:
print(f"[{res['file_path']}] score={res['rerank_score']:.4f}\n{res['text']}\n")
store.close()Related MCP server: ContextAtlas
MCP Tools Reference
Connecting AI agents to src/server.py over stdio MCP grants access to 7 tools:
MCP Tool Name | Parameters | Description |
|
| Recursively scans code files, parses AST chunks, computes SHA-256 hashes, and indexes chunks. |
|
| Embeds text query, retrieves candidates via Turbovec allowlist, and cross-encoder reranks top matching chunks. |
|
| Injects plain-text notes or architectural decisions into the index without needing a file path. |
|
| Returns diagnostic metrics: chunk counts, file counts, memory counts, DB disk size, and model metadata. |
|
| Purges all indexed code chunks, memories, and file hashes for a workspace ID and rebuilds vector index. |
|
| Starts an asynchronous real-time background file watcher that updates the index on file edits/deletions. |
|
| Stops the asynchronous background file watcher for a workspace ID. |
Verified MCP Integration Specs & Schemas
Verified configuration schemas across supported AI agent clients:
1. Claude Code (CLI)
Global registration via CLI:
claude mcp add turbocontext -- uv run /path/to/turbocontext/src/server.pyOr repository-level .mcp.json:
{
"mcpServers": {
"turbocontext": {
"command": "uv",
"args": ["run", "/path/to/turbocontext/src/server.py"]
}
}
}2. Claude Desktop App
Configuration file path by OS:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonLinux:
~/.config/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"turbocontext": {
"command": "uv",
"args": [
"run",
"/path/to/turbocontext/src/server.py"
],
"cwd": "/path/to/turbocontext"
}
}
}3. Cursor IDE
Add to .cursor/mcp.json in your workspace root, or configure under Cursor Settings → Features → MCP:
{
"mcpServers": {
"turbocontext": {
"command": "uv",
"args": [
"run",
"/path/to/turbocontext/src/server.py"
]
}
}
}4. Cline / Roo Code / CoolCline (VS Code Extensions)
File path: ~/.vscode/extensions/.../cline_mcp_settings.json or roo_code_mcp_settings.json:
{
"mcpServers": {
"turbocontext": {
"command": "uv",
"args": [
"run",
"/path/to/turbocontext/src/server.py"
],
"disabled": false,
"autoApprove": []
}
}
}5. Continue (VS Code & JetBrains IDEs)
File path: ~/.continue/config.json:
{
"mcpServers": [
{
"name": "turbocontext",
"command": "uv",
"args": [
"run",
"/path/to/turbocontext/src/server.py"
]
}
]
}6. Aider CLI
Launch via CLI flag:
aider --mcp-server "uv run /path/to/turbocontext/src/server.py"Or save in .aider.conf.yml:
mcp-servers:
- "uv run /path/to/turbocontext/src/server.py"7. Hermes / Open-WebUI Agents
Add to agent tool configuration (mcp_servers.yaml):
mcp_servers:
turbocontext:
transport: stdio
command: uv
args:
- run
- /path/to/turbocontext/src/server.pySearch Speed & Benchmarks
All empirical benchmarks evaluated on Linux with Python 3.12 and CPU-only ONNX execution:
Benchmark Domain | Metric Measured | Result | Evaluation |
AST Parsing Speed | Throughput | 137,404 files/sec | 0.0073 ms/file parsing latency |
FastEmbed Embedding | Throughput | 130.9 chunks/sec (9.8 KB/s) | Local ONNX CPU execution |
Turbovec Quantized Search | Latency (1,000 vectors) | 0.318 ms P50 / 0.321 ms P95 | Sub-millisecond vector retrieval |
Memory Compression | Footprint Ratio | 8.0x Reduction (3072 → 384 B/vec) | 87.5% memory footprint savings |
End-to-End Search Response |
| 15.7 ms Mean (16.5 ms P95) | Sub-20ms total context retrieval |
Compression Footprint Comparison
Corpus Scale | Unquantized Float32 | 4-Bit Turbovec | Memory Saved |
10,000 Chunks | 29.3 MB | 3.7 MB | -25.6 MB |
100,000 Chunks | 293.0 MB | 36.6 MB | -256.4 MB |
1,000,000 Chunks | 2.93 GB | 366.0 MB | -2.56 GB |
How It Works
Turbocontext compresses context retrieval latency and RAM footprint using a 6-stage architectural pipeline:
1. AST Chunking --> 2. Dense Embedding --> 3. 4-Bit Quantization
(Tree-sitter node) (FastEmbed 768-dim) (384 bytes/vector)
│
6. MCP Response <-- 5. Cross-Encoder <-- 4. Allowlist SIMD Search
(Sub-20ms stdio) (bge-reranker-v2-m3) (Workspace uint64 IDs)AST Decomposition: Tree-sitter parses multi-language source code files into semantic definitions (
function_definition,class_definition,struct_item) with contextual breadcrumbs (File: [path]\nType: [Class|Function]\n\n[code]).Local Vector Embedding: FastEmbed ONNX model (
jinaai/jina-embeddings-v2-base-code) maps each code block to a 768-dimensional dense vector space.Random Orthogonal Quantization:
turbovec.IdMapIndexapplies a random orthogonal rotation matrix to map coordinates to a canonical distribution, quantizing 768 float32 dimensions into 4-bit representations ($384\text{ bytes/vec}$).Allowlist SIMD Search:
turbovec.search()takes a 1Duint64numpy array allowlist corresponding toworkspace_idrow IDs in SQLite, executing short-circuited SIMD search with zero cross-workspace data leakage.Cross-Encoder Precision Reranking: Candidate chunks from vector search are reranked by
BAAI/bge-reranker-v2-m3cross-encoder, scoring raw query text against retrieved code blocks to eliminate false positives.FastMCP Stdio Transport: Returns structured results over stdio MCP transport to AI agents within ~16.22 ms.
References
TurboQuant: Online Vector Quantization with Near-optimal Distortion Rate (ICLR 2026) — vector quantization algorithm implemented by
turbovecFastEmbed — lightweight local ONNX text embedding library
Model Context Protocol — open standard protocol for connecting AI models to context tools
Tree-sitter — parser generator tool and incremental parsing library
Available Tools
5 toolsadd_memoryC
Shortcut tool to store a plain-text memory or note into the index without needing a file path.
Inputs: text (required), workspace_id (required). Returns: result
clear_workspaceC
Purges all indexed code chunks, stored memories, and file hashes for workspace_id from storage.
Inputs: workspace_id (required). Returns: result
get_statusA
Returns real-time status and statistics about the Turbocontext vector store, database size, chunk counts, unique files, stored memories, and model metadata.
Inputs: workspace_id. Returns: result
index_workspaceB
Recursively finds code files in directory_path and indexes them using Tree-sitter AST chunking,
FastEmbed vector generation, and Turbovec storage. Skips unchanged files automatically unless force=True.
Inputs: workspace_id (required), directory_path (required), force. Returns: result
search_codeA
Embeds the search query using FastEmbed, retrieves candidate chunks from Turbovec vector index,
reranks them using Cross-Encoder, and returns top_k matching code/memory chunks (default top_k=3).
Inputs: query (required), workspace_id (required), top_k. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 5 tools
Each tool targets a distinct operation: indexing code files, searching the index, adding plain-text memories, getting status, and clearing the workspace. There is no functional overlap.
All tool names follow a consistent verb_noun pattern in snake_case (e.g., index_workspace, search_code). The naming is predictable and easy to understand.
With 5 tools, the server covers the core workflow of indexing, searching, and managing a code/memory vector store without being overly sparse or bloated.
The tool set covers indexing, searching, memory addition, status, and full clearing. A minor gap is the lack of granular deletion (e.g., removing specific files or memories without clearing everything), but for most use cases this is sufficient.
Related MCP Connectors
Team memory for AI coding agents and code reviews, reviewed by humans and served over MCP.
Cloud or self-hosted knowledge for AI agents: hybrid search, reranking, GraphRAG, scoped MCP tools.
Shared memory for coding agents. Stop re-explaining your codebase every session.
A second brain for your AI agent. Shared memory for your team's AI agents, plus public and private knowledge bases — works with ChatGPT, Claude, Cursor and any MCP client.
Related MCP Servers
- AlicenseAqualityBmaintenanceNexus-MCP is a local MCP server for coding agents. Hybrid code search and a call graph for 10 languages give the agent the right code in one call, so it reads less. No API key, no telemetry, MIT. * 95% fewer tokens to reach the right file * About 9× faster search than Grep and Read * Live Claude Code runs on 11 repos: cost per task lower on 8 of 115901 PyPIMIT
- AlicenseNot gradedqualityDmaintenanceEnables AI coding agents to retrieve and manage code context with hybrid search, project memory, and observability via MCP tools.30MIT
- AlicenseAqualityDmaintenanceMCP server for semantic code indexing using vector embeddings, enabling AI agents to maintain persistent memory of codebases through natural language queries and intelligent chunking.1912 npm4MIT
- AlicenseAqualityBmaintenanceSemantic codebase search + persistent working memory for AI code editors. Local, zero-config, MCP. No API key.2347 PyPI2MIT