Skip to main content
MCP server CX Codex

code-memory — Claude Code MCP server: what it does, how to install

Runs local semantic searches across your codebase and Git history without third-party API keys. It delivers exact code slices to avoid wasting tokens on entire files.

Install into Claude Code · Platform CLI All methods and platforms ↓
claude mcp add --env CODE_MEMORY_LOG_LEVEL=<CODE_MEMORY_LOG_LEVEL> --env EMBEDDING_MODEL=<EMBEDDING_MODEL> --transport stdio code-memory -- uvx code-memory
Open on GitHub

What code-memory does

The server constructs a local code index using SQLite vec and sentence-transformers. It parses structure and symbols via AST for languages such as Python, TypeScript, Java, Go, and Rust. Secondary formats, including SQL, Markdown, and configuration files, use whole-file indexing. Files listed in .gitignore are omitted automatically.

Queries route through dedicated tools: search_code pairs BM25 keyword matching with dense vectors, search_docs handles architectural questions, search_history inspects Git commit changes, and index_codebase generates embeddings. All processing stays offline with zero telemetry.

Running via uvx requires Python 3.13 or newer, though standalone executables are distributed on GitHub Releases. First startup pulls a ~600MB embedding model into the Hugging Face cache, requiring an active internet connection once. Loading separate processes across multiple folders consumes 1–2 GB RAM each, so running a shared SSE instance prevents duplicate model instances.

What it helps with

  • retrieve code symbols and definitions with hybrid BM25 and vector search
  • investigate regression causes through Git commit history
  • cut LLM token usage by retrieving specific code segments instead of full files
  • index codebases locally without exposing private code to external services

Example prompts for the agent

  • Find where UserSession is defined using search_code.
  • Inspect commit history with search_history to explain why auth logic changed.
  • Run index_codebase to rebuild embeddings for the project.

How to install code-memory

Platform CLI

claude mcp add --env CODE_MEMORY_LOG_LEVEL=<CODE_MEMORY_LOG_LEVEL> --env EMBEDDING_MODEL=<EMBEDDING_MODEL> --transport stdio code-memory -- uvx code-memory

Replace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from code-memory <command>

Step by step, with commands for each platform: How to add an MCP server to Claude Code, Codex, Cursor, VS Code, Gemini CLI and more

Questions about code-memory

How do I install code-memory in Claude Code?

Run claude mcp add code-memory -- uvx code-memory in your terminal. To supply environment variables, run `claude mcp add --env CODE_MEMORY_LOG_LEVEL=<CODE_MEMORY_LOG_LEVEL> --env EMBEDDING_MODEL=<EMBEDDING_MODEL> --transport stdio code-memory -- uvx code-memory`.

Does code-memory need an external API key?

No API key is needed because embeddings run locally via sentence-transformers. The server operates offline and does not send telemetry or source files outside your device.

How do I reduce RAM usage across multiple workspaces?

Start a shared daemon with uvx code-memory --transport sse, which defaults to http://127.0.0.1:8765/sse. Point your MCP client configurations directly to that endpoint URL instead of launching isolated processes.

Similar MCP servers

All MCP servers for Agent setup: memory, context, orchestration →

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor