cc-mem-mcp
Lossless, categorized long-term memory for Claude Code (and any MCP client), backed by Qdrant, capturing compaction summaries across generations.
README
cc-mem-mcp
Lossless, categorized long-term memory for Claude Code (and any MCP client), backed by Qdrant.
Compaction summaries grow without bound and lose a little more every time they're re-summarized — after enough rounds, facts will be dropped. But Claude Code already produces a categorized, updated state at each compaction (its numbered summary: Primary Request, Files and Code Sections, Errors and fixes, Pending Tasks, …). This server's job is not to invent its own taxonomy — it is to capture that summary the moment it's written and keep it losslessly across every compaction generation, so a detail dropped by compaction #7 is still retrievable from #2.
Claude Code writes ~/.claude/projects/<slug>/*.jsonl
│ (each compaction appends an isCompactSummary line — already categorized)
▼
cc-mem-ingest ──► parse numbered sections = categories
│ split into chunks, content-hash dedup across generations
▼
┌──────────────────────── Qdrant ────────────────────────┐
│ embedded local-file (default) or shared server (URL) │
│ payload: category · project · generation · ts │
└──────────────────────────────────────────────────────────┘
▲
│ memory_find(query, category?, project?) ← retrieve on demand
the agent reloads relevant state instead of trusting the lossy summary
The categories are whatever Claude Code produced — not an enum we impose.
An optional built-in taxonomy (code.* / business.*) exists only as a
suggestion for the manual memory_store path; set CC_MEM_STRICT_CATEGORIES=1
if you actually want it enforced.
Lifecycle: init → auto-update → query
memory_init ──► scan repo (project.* baseline) + fold in current session context
(once) + install a managed block in CLAUDE.md so the agent knows to query/update
│
▼
auto-update ──► every compaction is captured by a PostCompact hook / watcher (cc-mem-ingest)
│
▼
query ──► memory_find(query, category?, project?) ← agent reloads state on demand
Init creates the first state and wires Claude Code up in one call:
cc-mem-init # scans cwd, ingests current context, writes CLAUDE.md block
cc-mem-init --install-hooks # also add SessionStart + PostCompact hooks to settings.json
It scans the repo into project.overview / stack / structure / commands / connections / git / docs,
derives the Claude Code transcript folder from the repo path to fold in the current
session, and installs a managed ## Long-term Memory block in CLAUDE.md telling the
agent to memory_find before re-deriving and to rely on automatic updates. Re-run
anytime — it's idempotent.
Tools
| Tool | Purpose |
|---|---|
memory_init(root?, project?, install_claude_md=true, install_hooks=false) |
Bootstrap. Scan repo → baseline, fold in current context, install CLAUDE.md guidance. |
memory_ingest(project?, session_path?) |
Auto-update. Capture Claude Code's compaction summaries from disk. Idempotent. |
memory_find(query, category?, project?, limit=5) |
Query. Semantic retrieval, filterable by category/project. |
memory_store(content, category, project?, tags?, source?) |
Optional manual write-through for a single fact. |
memory_categories() |
List the suggestion taxonomy. |
memory_delete(id) |
Remove a chunk by id. |
memory_stats() |
Collection size, backend, embedding config. |
Capture: keeping compactions losslessly
Ingestion is idempotent (identical chunks re-map to the same id), so run it however you like:
# one-shot, current project
cc-mem-ingest --project <transcript-folder-slug>
# background watcher (polls every 30s)
cc-mem-ingest --watch --interval 30
# or wire it to Claude Code's PostCompact hook (fires right after each compaction)
# settings.json:
# { "hooks": { "PostCompact": [ { "matcher": "*", "hooks": [
# { "type": "command", "command": "cc-mem-ingest --once" } ] } ] } }
Then, in-session, the agent calls memory_find (or memory_ingest on demand) to
reload state after a compaction. See examples/CLAUDE.snippet.md.
Quick start (Docker)
Build:
docker build -t cc-mem-mcp .
Wire it into Claude Code — add to .mcp.json (project) or ~/.claude.json (global):
{
"mcpServers": {
"memory": {
"command": "docker",
"args": ["run", "-i", "--rm", "-v", "cc-mem-data:/data", "cc-mem-mcp"]
}
}
}
That's it — embedded Qdrant persists in the cc-mem-data volume, embeddings run
locally via FastEmbed (no API key). See examples/ for shared-server
and OpenAI variants.
Then paste examples/CLAUDE.snippet.md into your
CLAUDE.md so the agent writes through and retrieves automatically.
Configuration
All via environment variables (see .env.example):
| Var | Default | Meaning |
|---|---|---|
QDRANT_URL |
(unset) | Set to use a shared Qdrant server; unset = embedded local file. |
QDRANT_API_KEY |
(unset) | API key for a protected server. |
QDRANT_PATH |
/data/qdrant |
Embedded storage path (mount a volume here). |
COLLECTION_NAME |
cc_memory |
Qdrant collection. |
EMBEDDING_PROVIDER |
local |
local (FastEmbed) or openai. |
EMBEDDING_MODEL |
BAAI/bge-small-en-v1.5 |
Model for the chosen provider. |
EMBEDDING_QUERY_PREFIX / EMBEDDING_PASSAGE_PREFIX |
(empty) | Instruction prefixes; set "query: " / "passage: " for the e5 family. See eval/. |
OPENAI_API_KEY / OPENAI_BASE_URL |
(unset) | For openai provider. |
CC_MEM_CATEGORIES |
(built-in) | JSON {domain:[sub,...]} to override the taxonomy. |
CC_MEM_STRICT_CATEGORIES |
0 |
1 = reject unknown categories instead of warning. |
Shared memory across machines/people
Run one Qdrant server (e.g. on a box everyone can reach) and point every client at it:
docker compose up -d qdrant # from this repo
# then in each client's mcp config:
# -e QDRANT_URL=http://<host>:6333
Everyone using the same QDRANT_URL + COLLECTION_NAME shares one memory.
Keep the same EMBEDDING_PROVIDER/EMBEDDING_MODEL across clients — vectors
from different models aren't comparable.
Run without Docker (from source)
python -m venv .venv && . .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -e .
# point at your Qdrant (omit for embedded local-file) and run:
QDRANT_URL=http://YOUR_QDRANT_HOST:6333 cc-mem-mcp # stdio MCP server
Wire it into Claude Code with the venv's cc-mem-mcp executable as the command,
passing QDRANT_URL / COLLECTION_NAME / EMBEDDING_MODEL via env
(see examples/).
Automatic capture (PostCompact hook)
Copy a template from hooks/, set your QDRANT_URL, and register it in
.claude/settings.json so every compaction is captured with no manual step. See
hooks/README.md.
Publish the image (to share with others)
Push a v* tag and the bundled GitHub Actions workflow builds and publishes
ghcr.io/<owner>/cc-mem-mcp — no secrets to set up:
git tag v0.1.0 && git push origin v0.1.0
Then anyone replaces OWNER in the examples/ .mcp.json with your
GitHub owner and they're running the same memory server.
Multilingual note
The default embedding model is English-centric. For non-English content set a multilingual model, e.g.:
EMBEDDING_MODEL=sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2
Changing the model changes the vector dimension — use a fresh COLLECTION_NAME
(or re-index) when you switch.
Notes
- MCP is stdio JSON-RPC — the client launches the server per session with
docker run -i; it is not a long-running HTTP service. - All logs go to stderr; stdout is reserved for the protocol.
- Switching embedding models changes the vector dimension. Use a fresh
COLLECTION_NAME(or re-index) when you change models.
License
MIT — see LICENSE.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。