# code-memory [Health: Active]

**Category:** 🧠 Knowledge & Memory  
**Repository:** https://github.com/kapillamba4/code-memory  
**GitHub Stars:** 50  
**Views:** 7  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/code-memory

## Description
Local semantic code search with Git history. Works offline, no API key needed.

## Tools
Capabilities this server exposes over MCP:

- **index_codebase** — Indexes 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` (r…
- **search_code** — Perform 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_docs** — Understand the codebase conceptually — how things work, architectural patterns, SOPs. Searches markdown documentation, READMEs, and docstrings extracted from code.
- **search_history** — Debug regressions and understand developer intent through Git history.

## Claude Desktop Quick Installation
Install path detected from listing signals. Uses `uvx` (confidence: high):

```json
"mcpServers": {
  "code-memory": {
    "command": "uvx",
    "args": ["code-memory"]
  }
}
```

## Documentation

## What code-memory MCP server does

The code-memory MCP server turns a local repository into a searchable source of code, documentation, and Git history. It is designed for MCP hosts that need targeted repository context instead of sending whole files into a model prompt. Processing happens locally, with no API key required and zero telemetry stated by the project.

Supported languages receive either structural or whole-file indexing. Python, JavaScript and TypeScript, Java, Go, Rust, C and C++, Ruby, and Kotlin use AST-based extraction. C#, Swift, Scala, Lua, shell, configuration files, web files, SQL, and Markdown use whole-file indexing. Files excluded by `.gitignore` are skipped.

## How it works

Run `index_codebase` against a directory before searching. The indexer parses supported source files, extracts structural information where available, creates dense embeddings with a sentence-transformers model, and stores retrieval data locally. Code search combines BM25 matching with vector similarity, while documentation search uses semantic and fuzzy retrieval. Git history search combines repository history with BM25 and vector retrieval.

The four tools separate common repository questions. `search_code` is intended for definitions, references, structural relationships, and semantic matches. `search_docs` searches Markdown, README files, and docstrings for architecture, workflows, and procedures. `search_history` helps investigate regressions and the intent behind changes. Re-run indexing when the searchable files or embedding model change.

## Setup and configuration

Install from PyPI with `pip install code-memory` or run it directly with `uvx code-memory`. The documented prerequisites are Python 3.13 or newer and, for the recommended setup, the `uv` package manager. Source installation and standalone binaries are also available; the binaries target Linux x86_64, macOS Intel, macOS ARM64, and Windows x86_64.

The default transport is stdio. A shared SSE process can be started with `--transport sse`, with configurable `--host` and `--port`; its documented default endpoint is `http://127.0.0.1:8765/sse`. The endpoint has no authentication, so the project advises keeping it on the loopback address unless authentication is added separately.

`CODE_MEMORY_LOG_LEVEL` controls logging verbosity. `EMBEDDING_MODEL` selects the Hugging Face embedding model and defaults to `jinaai/jina-code-embeddings-0.5b`. The first run downloads an approximately 600 MB model to the local Hugging Face cache. Changing models invalidates existing indexes and requires re-indexing.

## Tools and capabilities

- `index_codebase`: create or refresh the local index for source files and documentation.
- `search_code`: locate definitions, references, semantic matches, and dependency-related structure.
- `search_docs`: search documentation and docstrings for conceptual and architectural context.
- `search_history`: inspect Git history while debugging regressions or tracing intent.

## Limitations and notes

Search depends on an up-to-date index, so newly changed files may not appear until `index_codebase` runs again. Structural extraction is not available for every listed language; fallback languages are indexed as complete files. Local model downloads and embedding generation also require enough disk space and local compute, and the shared SSE mode should not be exposed publicly without protection.

_Full upstream README: https://allmcps.com/mcp/code-memory/readme_

