Local semantic code search with Git history. Works offline, no API key needed.
Copy the AI prompt to install this server into Claude Code, Cursor, or another agent β or use 1-click editor setup below.
π‘ Paste the JSON block into your client's configuration file under mcpServers, then restart the application.
A deterministic, high-precision code intelligence layer exposed as a Model Context Protocol (MCP) server.
uvx code-memory and you're readyPlease help star code-memory if you like this project!
Finding the right context from a large codebase is expensive, inaccurate, and limited by context windows. Dumping files into prompts wastes tokens, and LLMs lose track of the actual task as context fills up.
Instead of manually hunting with grep/find or dumping raw file text, code-memory runs semantic searches against a locally indexed codebase. Inspired by claude-context, but designed from the ground up for large-scale local search.
Full AST Support (structural parsing with symbol extraction): Python, JavaScript/TypeScript, Java, Go, Rust, C/C++, Ruby, Kotlin
Fallback Support (whole-file indexing): C#, Swift, Scala, Lua, Shell, Config (yaml/toml/json), Web (html/css), SQL, Markdown
Files matching
.gitignorepatterns are automatically skipped.
Instead of a single monolithic search, code-memory routes queries through three purpose-built tools:
| Question Type | Tool | Data Source |
|---|---|---|
| "Where / What / How?" β find definitions, references, structure, semantic search | search_code | BM25 + Dense Vector (SQLite vec) |
| "Architecture / Patterns" β understand architecture, explain workflows | search_docs | Semantic / Fuzzy |
| "Who / Why?" β debug regressions, understand intent | search_history | Git + BM25 + Dense Vector (SQLite vec) |
| "Setup / Prepare" β index parsing & embedding generation | index_codebase | AST Parser + sentence-transformers |
This forces the LLM to pick the right retrieval strategy before any data is fetched.
Download standalone executables from GitHub Releases β no Python installation required.
| Platform | Architecture | File |
|---|---|---|
| Linux | x86_64 | code-memory-linux-x86_64 |
| macOS | x86_64 (Intel) | code-memory-macos-x86_64 |
| macOS | ARM64 (Apple Silicon) | code-memory-macos-arm64 |
| Windows | x86_64 | code-memory-windows-x86_64.exe |
Note: The first run will download the embedding model (~600MB) to ~/.cache/huggingface/. Subsequent runs use the cached model.
uv package manager (recommended) or pipInstall uv if you don't have it:
You can use either uvx (requires Python) or the standalone binary (no dependencies).
Add to your MCP settings (e.g. ~/.gemini/settings.json):
Add to ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):
Add to .mcp.json in your project root or ~/.mcp.json for global access:
Add to .vscode/mcp.json in your workspace:
Replace the path with the location of your downloaded binary:
For Windows:
By default, each MCP host project launches its own code-memory process, which loads the embedding model (~1β2 GB) once per project. To avoid this, you can run a single shared instance over SSE (Server-Sent Events) and point all your MCP hosts at it.
The server listens on http://127.0.0.1:8765/sse by default.
Instead of launching a new process, point your MCP host at the running SSE endpoint.
.mcp.jsonTip: Configure
uvx code-memory --transport sseto start via a single-instance service manager (e.g. systemd user service, launchd agent, or another one-time login/startup mechanism) so the shared server starts automatically.
Security: The SSE endpoint is unauthenticated. Keep the default
--host 127.0.0.1so only local processes can connect; do not bind to0.0.0.0or a public interface unless you've put authentication in front of it.
| Option | Description | Default |
|---|---|---|
--transport | Transport protocol: stdio or sse | stdio |
--port | Port for SSE transport (only when --transport sse is used) | 8765 |
--host | Host/bind address for SSE transport (only when --transport sse is used) | 127.0.0.1 |
| Variable | Description | Default |
|---|---|---|
CODE_MEMORY_LOG_LEVEL | Logging verbosity (DEBUG, INFO, WARNING, ERROR) | INFO |
EMBEDDING_MODEL | HuggingFace model ID for embeddings | jinaai/jina-code-embeddings-0.5b |
Example:
You can use a different embedding model by setting the EMBEDDING_MODEL environment variable:
For MCP hosts, add the environment variable to your configuration:
Note: Changing the embedding model will invalidate existing indexes. You'll need to re-run
index_codebaseafter switching models.
index_codebaseIndexes or re-indexes source files and documentation in the given directory. Run this before using search_code or search_docs to ensure the database is up to date. Uses tree-sitter for language-agnostic structural extraction and generates dense vector embeddings using sentence-transformers (runs locally, in-process) for semantic search.
search_codePerform semantic search and find structural code definitions, locate where functions/classes are defined, or map out dependency references (call graphs). Uses hybrid retrieval (BM25 + vector embeddings) to find exact matches and semantic similarities.
search_docsUnderstand the codebase conceptually β how things work, architectural patterns, SOPs. Searches markdown documentation, READMEs, and docstrings extracted from code.
No reviews yet β be the first to share how this listing worked for you.
Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.
[](https://allmcps.com/mcp/code-memory)<a href="https://allmcps.com/mcp/code-memory"><img src="https://allmcps.com/api/badge/code-memory?style=directory" alt="Code Memory on AllMCPs" /></a>