使用说明
🧠 OpenMemory
为你的人工智能助手提供跨会话的持久内存。
OpenMemory是一款开源内存服务器,让人工智能助手记住事实,记日记,并在对话中维护上下文-由SQLite支持,并通过RESTneneneba API+MCP公开。
为什么选择OpenMemory?
每一次AI对话都是从头开始的。 OpenMemory修复了这个问题。
- 🔒 持久内存 --事实、偏好和背景在各个会话中都存在
- 📓 自动日记 --每一个
save附加带时间戳的日记条目 - 🔌 MCP服务器 --直接插入Claude Code、Cursor、Windsurf或任何MCP客户端
- 🌐 REST API --通过HTTP与任何语言或平台集成
- 💻 命令行界面 --从终端管理内存
- 🐳 Docker就绪 --一个
docker compose up部署 - ⚡ 零配置 --SQLite数据库,无需外部服务
快速开始
# Clone and install
git clone https://github.com/naimkatiman/OpenMemory.git
cd OpenMemory
npm install
# Start the server
npm run dev
服务器启动时间 http://localhost:8787 --Swagger文档位于 http://localhost:8787/docs
混合模式(中心+项目实例)
使用内置预设运行独立实例:
# central user memory (port 8787)
npm run dev:central
# project memory instances (ports 8788, 8789)
npm run dev:project-a
npm run dev:project-b
请参阅完整指南: hybrid-setup.md
Docker变体:
docker compose -f docker-compose.hybrid.yml up -d
试试看
# Save a memory
curl -X POST http://localhost:8787/v1/save \
-H "Content-Type: application/json" \
-d '{
"memory_updates": [
{"scope": "preferences", "key": "language", "value": "TypeScript"},
{"scope": "preferences", "key": "editor", "value": "VS Code"}
],
"summary": "User prefers TypeScript and VS Code"
}'
# Recall memories
curl http://localhost:8787/v1/memory
# Review diary entries
curl http://localhost:8787/v1/diary/recent?limit=5
# Switch profiles
curl -X POST http://localhost:8787/v1/profiles/switch \
-H "Content-Type: application/json" \
-d '{"profile": "assistant"}'
通过CLI使用
npm run cli -- save --update preferences:language:TypeScript --summary "setup complete"
npm run cli -- review --limit 5
npm run cli -- switch assistant
npm run cli -- execute "Summarize today's progress"
MCP服务器(克劳德代码/光标/风帆)
添加到MCP配置中(例如。 ~/.cursor/mcp.json 或克劳德代码设置):
{
"mcpServers": {
"memorycore": {
"command": "node",
"args": ["dist/src/mcp.js"],
"cwd": "/path/to/OpenMemory"
}
}
}
先构建: npm run build
关于混合中央/项目MCP接线,请参见 hybrid-setup.md.
可用的MCP工具:
| 工具 | 说明 |
|---|---|
memory_save |
保存记忆事实和日记条目 |
memory_recall |
检索存储的内存事实 |
diary_review |
阅读最近的日记 |
profile_switch |
在助手配置文件之间切换 |
profile_list |
列出所有配置文件和功能 |
建筑
┌─────────────────────────────────────────┐
│ Client Layer │
│ MCP Server │ REST API │ CLI │
├─────────────────────────────────────────┤
│ Service Layer │
│ Command Engine │ Profile Manager │
├─────────────────────────────────────────┤
│ Storage Layer │
│ SQLite (better-sqlite3) │
│ ┌──────────┬──────────┬──────────┐ │
│ │ Memory │ Diary │ Command │ │
│ │ Facts │ Entries │ Log │ │
│ └──────────┴──────────┴──────────┘ │
└─────────────────────────────────────────┘
文件结构
OpenMemory/
├── src/
│ ├── server.ts # Fastify server bootstrap
│ ├── api.ts # REST route definitions
│ ├── mcp.ts # MCP server for AI editors
│ ├── service.ts # Command engine + profile logic
│ ├── storage.ts # SQLite persistence layer
│ ├── schemas.ts # Zod validation schemas
│ ├── config.ts # Environment config
│ └── cli.ts # CLI runner
├── examples/
│ ├── curl-commands.sh # Example API calls
│ └── js-client.mjs # JavaScript client example
├── tests/
├── Dockerfile
├── docker-compose.yml
└── package.json
档案
MemoryCore支持 双助手配置文件 共享同一内存后端:
| 配置文件 | 模式 | 用例 |
|---|---|---|
primary |
本机内存 | 关系优先,连续模式 |
assistant |
能力模式 | 执行优先,结构化模式 |
两个配置文件都读/写到同一个SQLite数据库。在不丢失上下文的情况下在它们之间切换。
配置您自己的配置文件名称
通过API设置自定义名称或仅将其用作别名:
# The default profiles are "primary" and "assistant"
# You can switch using any registered alias
curl -X POST http://localhost:8787/v1/profiles/switch \
-H "Content-Type: application/json" \
-d '{"profile": "primary"}'
Docker部署
# Start with Docker Compose
docker compose up -d
# Or build manually
docker build -t memorycore .
docker run -p 8787:8787 -v memorycore-data:/app/runtime memorycore
配置
复制 .env.example 到 .env 并调整:
| 变量 | 默认值 | 描述 |
|---|---|---|
OPENCLAW_HOST |
127.0.0.1 |
服务器绑定地址 |
OPENCLAW_PORT |
8787 |
服务器端口 |
OPENCLAW_INSTANCE |
default |
实例标签(例如中心、项目-a) |
OPENCLAW_DB_PATH |
./runtime/openclaw.db |
SQLite数据库路径 |
OPENCLAW_DEFAULT_SCOPE |
general |
省略更新范围时使用的范围 |
OPENCLAW_ALLOWED_SCOPE_PREFIXES |
(空) | 逗号分隔的允许范围前缀 |
OPENCLAW_API_KEY |
(空) | 身份验证的API密钥(在生产中设置) |
OPENCLAW_CORS_ORIGIN |
* |
CORS允许的来源 |
API 参考
完整的OpenAPI文档可在 http://localhost:8787/docs 跑步时。
| 方法 | 端点 | 描述 |
|---|---|---|
GET |
/health |
健康检查+活动档案 |
GET |
/v1/profiles |
列出个人资料 |
POST |
/v1/profiles/switch |
切换活动配置文件 |
GET |
/v1/capabilities |
显示配置文件功能 |
GET |
/v1/memory |
列出内存事实 |
POST |
/v1/save |
保存内存+日记条目 |
GET |
/v1/diary/recent |
最近的日记条目 |
POST |
/v1/command |
运行命名命令 |
POST |
/v1/execute |
执行目标 |
功能模块
| 模块 | 状态 | 描述 |
|---|---|---|
| 回声记忆回忆 | ✅ 主动 | 语义记忆搜索和回忆 |
| LRU项目管理 | ✅ 活动 | 跟踪LRU驱逐的活动项目 |
| 基于时间的意识✅ 活动 | 时间感知上下文和提醒 | |
| 技能插件系统 | ✅ 活动 | 可扩展的AI助手技能插件 |
贡献
看 贡献.md 作为指导方针。问题和PR欢迎!
贡献者
许可证
麻省理工学院 --用它,叉它,运送它。
