包括mcp
自托管 模型上下文协议 (MCP)服务器,为任何AI代理提供持久、可搜索的内存——由 clude机器人 以及您自己的Supabase数据库。
连接一次后,工作流中的每个工具(Claude Desktop、Claude Code、Cursor、Antigravity和任何其他兼容MCP的客户端)在会话之间共享相同的内存存储。
______________________________________________________________________
它做什么
- 存储记忆 具有类型分类、重要性评分、标签和嵌入
- 回忆往事 通过7阶段混合流水线:向量相似度+BM25关键字搜索+知识图遍历
- 链接记忆 基于Hebbian强化的类型化知识图
- 分数重要性 每次写入前自动执行(如果配置了Anthropic)
- 运行一个梦想循环 将情景记忆整合为语义知识
- 消磨陈旧的记忆 随着时间的推移,按特定类型的费率
这 自主存储器协议 (agent_memory_protocol prompt)使上述所有操作在后台悄无声息地发生——不需要为每个对话设置。
______________________________________________________________________
需求
______________________________________________________________________
安装
git clone https://github.com/Israeltheminer/clude-mcp.git
cd clude-mcp
npm install
npm run build______________________________________________________________________
配置
复制 .env.example 到 .env 并填写您的值:
cp .env.example .env# ── Self-hosted (Supabase) ─────────────────────────────────────────
SUPABASE_URL=https://your-project.supabase.co
SUPABASE_KEY=your-service-role-key
# ── LLM (importance scoring + dream cycle) ─────────────────────────
ANTHROPIC_API_KEY=sk-ant-...
# ── Embeddings (optional — defaults to Supabase built-in) ──────────
# EMBEDDING_PROVIDER=voyage # or: openai
# VOYAGE_API_KEY=pa-...
# OPENAI_API_KEY=sk-...
# ── Memory protocol thresholds ─────────────────────────────────────
MEMORY_TURN_THRESHOLD=10 # store episodic memories every N turns
MEMORY_IMPORTANCE_THRESHOLD=0.4 # minimum score to persist an episodic memorySupabase架构
跑吧 clude机器人模式 在Supabase SQL编辑器中创建所需的表 pgvector HNSW指数。
______________________________________________________________________
添加到您的AI工具
服务器通过stdio进行通信。每个工具都需要一个指向已构建二进制文件的配置条目。
克劳德桌面版
编辑 ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"clude": {
"command": "node",
"args": ["/absolute/path/to/clude-mcp/dist/index.js"]
}
}
}克劳德代码
// ~/.claude.json → mcpServers
"clude": {
"command": "node",
"args": ["/absolute/path/to/clude-mcp/dist/index.js"],
"type": "stdio"
}光标
// ~/.cursor/mcp.json
{
"mcpServers": {
"clude": {
"command": "node",
"args": ["/absolute/path/to/clude-mcp/dist/index.js"]
}
}
}反重力
添加相同内容 node + args 阻止您的Antigravity MCP服务器配置。
重启 每个工具在编辑其配置后。使用以下工具进行验证:列出可用的MCP工具——您应该看到所有13个 clude 工具。______________________________________________________________________
自主存储器协议
这 agent_memory_protocol MCP提示是系统的核心。它返回一个与生命周期无关的四阶段指令块——可在会话开始、会话中期、上下文重置后或任何时候从编程代理调用:
| 阶段 | 触发 | 发生了什么 |
|---|---|---|
| 1--初始化 | 立即加载 | recall_summaries 温暖语境; hydrate_memories 在相关ID上;转弯计数器重置为0 |
| 2--定期 | 从加载点开始每N圈 | 步骤A:评分+存储情节亮点;步骤B:语义检查点(始终) |
| 3--反应性 | 任何身份/偏好声明 | store_memory 与类型 self_model 立即 |
| 4--不变量 | 每次内存写入 | infer_concepts 用于标签; link_memories 相关记忆;无声操作 |
要在Claude Code中全局激活它,请创建 ~/.claude/CLAUDE.md 直接嵌入协议-- 不要 使用 agent_memory_protocol MCP对此进行提示;在会话开始时需要单独的API调用,这是不可靠的:
# Memory Protocol
You have access to a persistent memory MCP server (`clude`). Follow this protocol autonomously on every session — silently, without mentioning it to the user.
## On session start (before your first response)
1. Call `recall_summaries` (no query, limit 20) to warm the context with recent memories
2. If any summaries are relevant to the current task, call `hydrate_memories` on those IDs
3. Let this inform your responses silently
## Every 10 conversation turns
**Step A — Episodic highlights**
- Review the last 10 turns and identify memorable moments
- For each: call `score_importance` on `summary + content[:400]`
- If score ≥ 0.4: call `store_memory` with type `"episodic"`
- Call `infer_concepts` to auto-generate tags
- Skip: small talk, greetings, filler, already-stored facts
**Step B — Semantic checkpoint**
- Write a 2–3 sentence summary of key facts/decisions from these 10 turns
- Call `store_memory` with type `"semantic"` and source `"checkpoint"` — always, regardless of score
## Immediately (no turn threshold)
Any time the user expresses a persistent preference, identity trait, or working style:
→ Call `store_memory` immediately with type `"self_model"`
## Always
- `score_importance` auto-runs inside `store_memory` when `importance` is omitted — no need to call it separately before storing
- Use `infer_concepts` to generate tags for every memory stored
- When a new memory clearly relates to an existing one, call `link_memories` with the appropriate `link_type`
- Never ask the user for permission — do it silently in the background______________________________________________________________________
工具(13)
存储
| 工具 | 说明 |
|---|---|
store_memory | 留住记忆。如果满足以下条件,则自动评分重要性 ANTHROPIC_API_KEY 设置和 importance 省略。 |
export_pack | 将内存序列化为便携式签名内存包(JSON或Markdown)。需要CortexV2。 |
import_pack | 将内存包加载到存储中。应用重要性乘数来防止洪水。需要CortexV2。 |
检索
| 工具 | 说明 |
|---|---|
recall_memories | 全混合搜索→ 完整的内存对象。最佳结果≤10。 |
recall_summaries | 轻量级混合搜索→ 仅提供摘要。用于宽扫描(20-100)。 |
hydrate_memories | 获取特定ID的完整内容。用作两阶段检索的步骤2。 |
图
| 工具 | 说明 |
|---|---|
link_memories | 在两个记忆之间创建一个键入的有向边。通过Hebbian联合召回加强。 |
链接类型: supports · contradicts · elaborates · causes · resolves · follows · relates
分析
| 工具 | 说明 |
|---|---|
get_stats | 总计数、平均重要性/衰减、图链接计数。 |
get_recent | 在过去N小时内创建或访问的记忆。 |
get_self_model | 全部 self_model 记忆(身份、偏好、工作风格)。 |
认知 *(仅限自托管)*
| 工具 | 说明 |
|---|---|
decay_memories | 对所有记忆应用特定类型的每日衰减率。 |
dream | 运行整合→ 反思→ 出现周期。 |
score_importance | 请法学硕士对文本的重要性进行评分(0-1)。 |
公用事业 *(本地,无API成本)*
| 工具 | 说明 |
|---|---|
infer_concepts | 使用12类本体从文本中提取概念标签。 |
format_context | 将内存阵列格式化为LLM就绪的系统提示块。 |
______________________________________________________________________
资源(3)
在支持资源轮询的MCP客户端中订阅这些URI:
| URI | 描述 |
|---|---|
memory://stats | 实时汇总统计 |
memory://recent/24h | 过去24小时的回忆(最多50个) |
memory://self-model | 所有self_model记忆 |
______________________________________________________________________
提示(3)
| 提示 | 参数 | 描述 |
|---|---|---|
memory_context | query (必填), limit, related_user | 回忆+将记忆格式化为上下文块 |
store_conversation_turn | user_message, agent_reply, related_user | 搭建一个商店_呼叫一次谈话 |
agent_memory_protocol | *(无)* | 全自主存储协议指令 |
______________________________________________________________________
存储器类型和衰减率
| 类型 | 腐烂 | 用途 |
|---|---|---|
episodic | 7%/天 | 活动、对话、会议亮点 |
semantic | 2%/天 | 事实、决策、提炼的知识 |
procedural | 3%/天 | 如何操作步骤、工作流程 |
self_model | 1%/天 | 身份、偏好、工作风格 |
______________________________________________________________________
计划性维护
有两项任务可以保持记忆库的健康——每天运行它们,在衰退之前做梦,这样巩固的记忆才能存活更长时间:
| 任务 | 频率 | 为什么 |
|---|---|---|
dream | 夜间 | 巩固情节→ 衰变前的语义 |
decay_memories | 夜间(做梦后) | 应用特定类型的每日衰减率 |
Claude Code计划任务(推荐)
# Dream: nightly (example — pick your own time)
claude schedule create memory-dream --cron "0 2 * * *" \
"Call the dream tool on the clude MCP server to consolidate episodic memories into semantic knowledge."
# Decay: nightly, after dream
claude schedule create memory-decay --cron "0 3 * * *" \
"Call the decay_memories tool on the clude MCP server to apply daily memory decay rates."普通cron(替代)
# Dream: nightly at 2am
0 2 * * * node /path/to/clude-mcp/dist/index.js --tool dream
# Decay: nightly at 3am (after dream)
0 3 * * * node /path/to/clude-mcp/dist/index.js --tool decay_memories______________________________________________________________________
项目结构
src/
├── index.ts Boot entry: pino guard + dotenv + main()
├── server.ts Bootstrap: config → brain → server → connect
├── config.ts buildConfig() — env vars → CortexConfig
├── brain.ts createBrain() — CortexV2/Cortex fallback
├── log.ts Stderr-only logger
├── helpers.ts ok(), isCortexV2(), shared types
│
├── tools/
│ ├── definitions/ JSON schemas for all 13 tools
│ │ ├── index.ts TOOLS[] aggregator
│ │ ├── storage.ts
│ │ ├── retrieval.ts
│ │ ├── graph.ts
│ │ ├── analysis.ts
│ │ ├── cognition.ts
│ │ └── utilities.ts
│ ├── handlers/ Handler functions (one file per category)
│ │ ├── storage.ts Auto-importance scoring lives here
│ │ ├── retrieval.ts
│ │ ├── graph.ts
│ │ ├── analysis.ts
│ │ ├── cognition.ts
│ │ └── utilities.ts
│ └── index.ts registerToolHandlers() dispatch router
│
├── resources/
│ ├── definitions.ts 3 resource URIs + metadata
│ └── handlers.ts registerResourceHandlers()
│
└── prompts/
├── definitions.ts 3 prompt schemas
├── index.ts registerPromptHandlers() dispatch
└── handlers/
├── memory-context.ts
├── store-turn.ts
└── protocol.ts buildProtocolText() — pure, testable______________________________________________________________________
发展
npm run dev # watch mode (tsx)
npm run lint # type-check only (tsc --noEmit)
npm run build # compile to dist/______________________________________________________________________
许可证
麻省理工学院
