
Code Memory
io.github.kapillamba4由 GitHub 账号 kapillamba4 发布v1.0.33更新于 Oct 25, 2026
Local semantic code search with Git history. Works offline, no API key needed.
发布方自己的服务:Memory.fit
概览
一个本地 MCP 服务器,为代码库建立索引,让助手离线进行代码、文档和 Git 历史的语义搜索。
- 可以做什么
- 为指定目录中的源码和文档建立索引,使用 tree-sitter 解析和本地嵌入生成 SQLite 向量索引,并在改动或更换模型后重新索引。以语义或结构化方式搜索代码,查找定义、引用、调用关系和文件结构,采用 BM25 与向量混合检索。搜索文档、README 和提取出的 docstring,帮助理解架构与工作流程。搜索 Git 历史中的提交、单文件历史和 blame,用于排查回归和理解改动意图。
- 适用场景
- 适合助手需要在大型或不熟悉的代码库中工作、希望精确检索而非粘贴整个文件的场景,也适合代码必须留在本机、包括离线或隔离环境的场景。
- 运行要求
- 以 stdio 在本地运行。需要 Python 3.13 或更高版本并配合 uv 或 pip,或使用 GitHub Releases 提供的独立二进制文件。首次运行会下载约 600MB 的嵌入模型到 Hugging Face 缓存,加载模型约需 1GB 内存。可选环境变量 CODE_MEMORY_LOG_LEVEL 和 EMBEDDING_MODEL。Git 历史搜索需要 Git 仓库。无需 API 密钥。
安装
在 SourceWeft 中
- 打开 控制台中的 Code Memory,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
code-memory
[code-memory logo][Zero Telemetry] [No API Key] [Offline First]
A deterministic, high-precision code intelligence layer exposed as a Model Context Protocol (MCP) server.
- Zero telemetry — your code never leaves your machine
- No API key required — runs entirely locally with sentence-transformers
- 1 min setup — just
uvx code-memoryand you're ready - Token saving by 50% — precise code retrieval instead of dumping entire files
Please help star code-memory if you like this project!
Why code-memory?
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.
Supported Languages
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.
Architecture: Progressive Disclosure
Instead of a single monolithic search, code-memory routes queries through three purpose-built tools:
This forces the LLM to pick the right retrieval strategy before any data is fetched.
Installation
From PyPI (Recommended)
From Source
Pre-built Binaries (Standalone)
Download standalone executables from GitHub Releases — no Python installation required.
Note: The first run will download the embedding model (~600MB) to ~/.cache/huggingface/. Subsequent runs use the cached model.
Quickstart
Prerequisites
- Python ≥ 3.13
uvpackage manager (recommended) or pip
Install uv if you don't have it:
Install & Run
Development
Configure Your MCP Host
You can use either uvx (requires Python) or the standalone binary (no dependencies).
Using uvx (Python required)
Gemini CLI / Gemini Code Assist
Add to your MCP settings (e.g. ~/.gemini/settings.json):
Claude Desktop
Add to ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):
Claude Code (CLI)
Add to .mcp.json in your project root or ~/.mcp.json for global access:
VS Code (Copilot / Continue)
Add to .vscode/mcp.json in your workspace:
Using Standalone Binary (No Python required)
Replace the path with the location of your downloaded binary:
For Windows:
Shared SSE Server (Reduce Memory Usage)
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.
Start the shared server
The server listens on http://127.0.0.1:8765/sse by default.
Configure MCP hosts to use the shared server
Instead of launching a new process, point your MCP host at the running SSE endpoint.
Claude Desktop
VS Code (Copilot / Continue)
Claude Code (CLI) — .mcp.json
Tip: 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.
Configuration
CLI Options
Environment Variables
Example:
Custom Embedding Model
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.
Tools
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 (runs locally, in-process) for semantic search.
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.
Project Structure
Troubleshooting
"Git repository not found" error
Make sure you're running search_history from within a git repository. The tool searches upward from the current directory to find .git.
Empty search results
Run index_codebase(directory=".") first to index your code and documentation. The index is stored locally in code_memory.db.
Slow indexing
Indexing generates embeddings using a local sentence-transformers model. The first run downloads the model (~600MB for jina-code-embeddings-0.5b). Subsequent runs are faster.
Embedding model errors
Ensure you have enough disk space and memory. The jina-code-embeddings-0.5b model requires ~1GB RAM when loaded.
Privacy & Security
Your code never leaves your machine. Unlike cloud-based code intelligence tools, code-memory runs entirely locally:
- Zero telemetry — no usage data, analytics, or tracking
- Zero external API calls — all processing happens in-process
- Zero cloud dependencies — works without internet (after initial setup)
- Your data stays local — indexes stored in local SQLite database
This makes code-memory ideal for:
- Proprietary and confidential codebases
- Security-conscious organizations
- Air-gapped development environments
- Privacy-focused developers
See COMPARISON.md for a detailed comparison with cloud-based alternatives.
Air-gapped & Offline Support
code-memory works in completely isolated environments:
Method 1: Pre-built Binary + Cached Model
-
On a connected machine, run code-memory once to cache the embedding model:
-
Transfer to air-gapped machine:
- Standalone binary from GitHub Releases
- Model cache directory (
~/.cache/huggingface/hub/models--*)
-
Run on air-gapped machine — no network required.
Method 2: Offline pip Install
- Download the wheel from PyPI on a connected machine
- Transfer and install:
pip install code-memory-*.whl - Pre-cache the model as above
- Run offline
Roadmap
- Milestone 1 — Project scaffolding & MCP protocol wiring
- Milestone 2 — Implement
search_codewith AST parsing + SQLite +sqlite-vec - Milestone 3 — Implement
search_historywith Git integration - Milestone 4 — Implement
search_docswith semantic search - Milestone 5 — Production hardening & packaging
Contributing
See CONTRIBUTING.md for development setup and guidelines.
Changelog
See CHANGELOG.md for version history.
License
MIT
来源:README.md,提交 5a8db16
工具
0版本历史
1- v1.0.33最新Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分
其他 Memory 集成

Memory.fit
fit.memory官方发布者
托管式 Memory.fit 服务器,让 AI 读取你的训练、睡眠、恢复与饮食数据,并写回每周计划、每日目标和饮食计划。
pg.ddx.io: the PostgreSQL community's memory
io.ddx.pg官方发布者
pg.ddx.io: the PostgreSQL community's memory 的托管 MCP 服务,由 pg.ddx.io 发布;无需登录;Streamable HTTP;29 个工具。
var.gg Naming Memory
gg.var官方发布者
远程 MCP 服务器,可根据领域概念推荐并检索韩、日、中、越、英多语言的代码标识符名称,并提供 ERD 结构查询。

Counterparts
ai.counterparts
面向 Claude Code 与 Claude Desktop 的本地优先长期记忆:助手自行写下关于你和项目的笔记,并在之后的会话中回忆起来。

LAHZE - Persian AI Memory Platform
由 GitHub 账号 pedramgholizadeh 发布
以波斯语为先的地理记忆平台:发现地点,起草并发布仅限波斯语的记忆。AI 翻译