myAI Memory Sync
一个 MCP 工具,可以在多个 Claude 界面之间同步用户偏好、个人信息和代码标准,从而让用户无需重复操作,即可保持一致的个性化 AI 交互体验。
README
myAI 记忆同步
是否厌倦了每次开始新的聊天都要向 Claude 重复说明? myAI 记忆同步是一个改变游戏规则的 MCP 工具,它可以无缝地同步您在所有 Claude 界面上的偏好、个人详细信息和代码标准!只需更新一次,您的更改就会立即出现在所有地方 - 从 Claude Desktop 到 Claude Code、Windsurf 和 Claude.ai 网页。借助我们先进的缓存系统,与记忆相关的查询速度提高了 2000 倍!停止在重复的指令上浪费 tokens,享受真正个性化的 AI 体验。
myAImemory-mcp 与其他记忆工具的比较
虽然 AI 系统已经存在一些优秀的记忆工具,但 myAImemory-mcp 作为模型上下文协议 (MCP) 工具,具有特定的用途:
| 工具 | 主要关注点 | 隐私模型 | 集成 | 独特优势 |
|---|---|---|---|---|
| myAImemory-mcp | 用户在 Claude 界面上的偏好 | 本地优先,不向外部服务器发送数据 | Claude 专用 MCP | 跨平台同步,具有高性能缓存 |
| Graphiti | 时序知识图谱 | 依赖数据库 | 通用代理框架 | 知识表示中的时间感知 |
| Letta/MemGPT | 有状态代理框架 | 基于服务器 | 多模型支持 | 完整的代理架构 |
| Mem0 | 个性化 AI 交互 | 基于 API | 多平台 | 多级记忆层次结构 |
| Memary | 代理的人类式记忆 | 图数据库 | 以代理为中心 | 人类记忆模拟 |
| Cognee | AI 应用的可靠记忆 | 多种存储选项 | 以数据管道为中心 | 广泛的数据源集成 |
myAImemory-mcp 的主要优势:
- 隐私优先:所有数据都保留在您的设备上,不会将个人信息发送到外部服务器
- 性能:利用 Claude 的缓存功能,显著提高速度
- 简单性:跨所有 Claude 界面以自然语言更新您的偏好
- MCP 集成:专门构建为 Claude MCP,实现无缝集成
🚀 快速开始
# 克隆仓库
git clone https://github.com/Jktfe/myaimemory-mcp.git
cd myaimemory-mcp
# 安装依赖
npm install
# 构建 TypeScript 代码
npm run build
# 启动 MCP 服务器(使用 stdio 传输)
npm start
# 或者使用 HTTP 传输启动
npm run start:http
🧠 服务器选项
统一的服务器脚本支持多个选项:
# 使用 stdio 传输启动(默认)
./start-server.sh
# 使用 HTTP 传输启动
./start-server.sh --http
# 使用 HTTP 传输在自定义端口上启动
./start-server.sh --http --port=8080
# 使用直接实现启动(不使用 SDK)
./start-server.sh --direct
# 使用直接实现和 HTTP 传输启动
./start-server.sh --direct --http
# 启用调试模式
./start-server.sh --debug
🔄 直接同步方法(简单的替代方案)
对于不需要运行 MCP 服务器的更简单方法,您可以使用统一的 CLI:
# 一次性同步所有记忆文件
npm run sync
# 或者用于紧急同步(修复权限)
npm run sync:emergency
此脚本将:
- 从您的 "myAI Master.md" 文件中读取
- 更新您项目中的所有 CLAUDE.md 文件
- 更新您的 Windsurf 记忆设置
- 所有这些都不会在 git 仓库中存储敏感信息
🔒 隐私和安全
- 包含您个人信息的 "myAI Master.md" 文件已从 git 跟踪中排除
- 所有 CLAUDE.md 文件也被排除以保护您的隐私
- 使用包含的
.gitignore来确保敏感文件保持私密
🗣️ 支持的自然语言命令
您可以使用以下自然语言模式与 myAI Memory 交互:
| 命令模式 | 示例 | 目的 |
|---|---|---|
Use myAI Memory to remember [信息] |
"Use myAI Memory to remember I prefer TypeScript over JavaScript" | 根据内容将信息添加到适当的部分 |
Remember that [信息] |
"Remember that I live in London" | 添加信息到记忆的较短替代方案 |
Add to my memory that [信息] |
"Add to my memory that I have two cars" | 添加信息到记忆的另一种方式 |
Use myAI Memory to add to [部分] [信息] |
"Use myAI Memory to add to Coding Preferences I prefer dark mode" | 将信息添加到特定部分 |
Update my [部分] to include that [信息] |
"Update my User Information to include that my birthday is March 29" | 使用新信息更新特定部分 |
注意:要在所有平台上执行完全同步,请使用命令行:node sync-memory.js
你: Use myAI Memory to remember I prefer TypeScript over JavaScript
Claude: ✅ Added to your Coding Preferences! I'll remember you prefer TypeScript over JavaScript.
📋 安装选项
选项 1:直接安装(推荐)
从 npm 安装:
npm install -g myai-memory-sync
启动服务器:
# 使用 stdio 传输启动(默认)
myai
# 使用 HTTP 传输启动
myai server --transport http
# 处理记忆命令
myai remember "I prefer dark mode"
# 跨平台同步
myai sync
选项 2:从源代码运行
从源代码克隆和构建:
git clone https://github.com/Jktfe/myaimemory-mcp.git
cd myaimemory-mcp
npm install
npm run build
npm start # 使用 stdio 传输启动
# 或者
npm run start:http # 使用 HTTP 传输启动
选项 3:Docker
使用 Docker 构建和运行:
docker build -t myai-memory-sync .
docker run -v myai-memory:/app/data -p 3000:3000 myai-memory-sync
🔌 MCP 配置
Claude Desktop 配置
将此添加到您的 claude_desktop_config.json:
{
"mcpServers": {
"myai-memory-sync": {
"command": "npx",
"args": [
"-y",
"myai"
],
"env": {
"TEMPLATE_PATH": "/path/to/custom/template.md",
"ENABLE_ANTHROPIC": "true",
"ANTHROPIC_API_KEY": "your-api-key-here"
}
}
}
}
Claude.ai 与 Smithery
- 访问 Smithery.ai
- 添加 myAI 记忆同步 MCP:
@Jktfe/myaimemory-mcp - 在 Smithery 设置中使用您的 API 密钥进行配置
Windsurf 集成
在 Windsurf 中,添加到您的 .codeium/config.json:
{
"mcp": {
"servers": {
"myai-memory-sync": {
"command": "npx",
"args": [
"-y",
"myai"
]
}
}
}
}
HTTP 服务器模式
对于 HTTP 传输而不是 stdio:
# 使用 npm 脚本:
npm run start:http
# 使用统一的 CLI:
myai server --transport http
# 使用 shell 脚本和自定义端口:
./start-server.sh --http --port=8080
# 使用环境变量:
PORT=8080 npm run start:http
环境变量
创建一个包含以下选项的 .env 文件:
# 基本配置
DEBUG=true # 启用调试日志
TEMPLATE_PATH=./data/template.md # 自定义模板位置
PORT=3000 # HTTP 传输的端口(默认:3000)
USE_DIRECT=true # 使用直接实现(不使用 SDK)
# 平台特定路径
WINDSURF_MEMORY_PATH=~/.codeium/windsurf/memories/global_rules.md
CLAUDE_PROJECTS_PATH=~/CascadeProjects
# 性能优化
ENABLE_ANTHROPIC=true # 启用 Anthropic API 集成
ANTHROPIC_API_KEY=your-api-key # 您的 Anthropic API 密钥
ENABLE_PROMPT_CACHE=true # 启用提示缓存系统
CACHE_TTL=300000 # 缓存 TTL,以毫秒为单位(5 分钟)
# Claude web 同步(可选)
CLAUDE_WEB_SYNC_ENABLED=false # 启用 Claude.ai web 同步
CLAUDE_WEB_EMAIL=you@email.com # 您的 Claude.ai 电子邮件
CLAUDE_WEB_HEADLESS=true # 在无头模式下运行浏览器
🧙♂️ 系统提示集成
为了获得最佳效果,请将此添加到您的 Claude 系统提示中:
Memory Integration Instructions:
When you receive a command that starts with "use myAI Memory to", you should:
1. Process the rest of the instruction as a memory management command
2. Try to determine the appropriate section to update based on the content
3. Use the myAI Memory Sync MCP to update your memory
4. Confirm the update with a brief acknowledgment
For example:
"use myAI Memory to remember I prefer dark mode"
→ Update the preferences section with dark mode preference
When asked questions about preferences or personal information, first check your memory via the myAI Memory Sync MCP. Always reference information from memory rather than making assumptions.
✨ 功能
- 🔄 跨平台同步:更新一次,随处同步
- ⚡ 闪电般快速的回忆:缓存系统,性能提升高达 2000 倍
- 🗣️ 自然语言界面:只需自然地交谈即可更新您的偏好
- 🧩 多个人物配置文件:轻松切换不同的预设
- 🔐 以安全为中心:本地存储,具有 .gitignore 保护
- 🛠️ 对开发者友好:完整的 TypeScript 实现,具有全面的 API
🧩 核心架构
myAI 记忆同步使用模块化架构,包含以下关键组件:
- 模板解析器:结构化记忆对象和 markdown 之间的双向转换
- 模板存储:具有内存和文件系统缓存的持久存储
- 平台同步器:为每个目标平台实现
PlatformSyncer接口 - 自然语言处理器:从自然语言记忆命令中提取结构化数据
- 记忆缓存服务:通过多级缓存策略优化性能
🔍 详细功能
跨平台同步
- ClaudeCodeSyncer:更新所有仓库中的 CLAUDE.md 文件
- WindsurfSyncer:管理 Windsurf 环境中的 global_rules.md
- ClaudeWebSyncer:可选的基于 Puppeteer 的与 Claude.ai web 界面的同步
智能记忆管理
- 基于模式的提取:将自然语言转换为结构化的键值对
- 部分检测算法:自动确定新记忆的适当部分
- 记忆模板格式:基于 Markdown 的结构,包含部分、描述和键值项
- 上下文保留:更新记忆部分,同时保留其他模板内容
性能优化
- 多级缓存:在模板和部分级别进行内存缓存
- 基于 TTL 的缓存管理:可配置的缓存内容生存时间 (Time-To-Live)
- 预热:模板更新后预先填充缓存
- 可选的 Anthropic API 集成:将与记忆相关的查询速度提高高达 2000 倍
安全
- 本地优先架构:所有数据都保留在您的设备上
- Gitignore 管理:自动将 CLAUDE.md 添加到所有仓库中的 .gitignore
- 文件权限处理:修复权限问题以实现最大兼容性
- 加密存储:与加密文件系统兼容
📋 记忆模板格式
系统使用结构化的 markdown 格式来组织您的偏好:
# myAI Memory
# User Information
## Use this information if you need to reference them directly
-~- Name: Your Name
-~- Location: Your Location
-~- Likes: Reading, Hiking, Technology
# General Response Style
## Use this in every response
-~- Style: Friendly and concise
-~- Use UK English Spellings: true
-~- Include emojis when appropriate: true
# Coding Preferences
## General Preference when responding to coding questions
-~- I prefer TypeScript over JavaScript
-~- Show step-by-step explanations
🛠️ 技术实现
MemoryTemplate Schema
interface MemoryTemplate {
sections: TemplateSection[];
}
interface TemplateSection {
title: string;
description: string;
items: TemplateItem[];
}
interface TemplateItem {
key: string;
value: string;
}
Platform Synchronization Interface
interface PlatformSyncer {
sync(templateContent: string): Promise<SyncStatus>;
}
type PlatformType = 'claude-web' | 'claude-code' | 'windsurf' | 'master';
interface SyncStatus {
platform: PlatformType;
success: boolean;
message: string;
}
🔌 MCP 集成 API
myAI 记忆同步工具使用以下函数实现模型上下文协议 (MCP):
| 函数 | 描述 | 参数 |
|---|---|---|
get_template |
检索完整的记忆模板 | 无 |
get_section |
检索特定部分 | sectionName: string |
update_section |
更新特定部分 | sectionName: string, content: string |
update_template |
替换整个模板 | content: string |
list_presets |
列出可用的预设 | 无 |
load_preset |
加载特定预设 | presetName: string |
create_preset |
创建新预设 | presetName: string |
sync_platforms |
跨平台同步 | platform?: string |
list_platforms |
列出可用的平台 | 无 |
自然语言界面
用户可以通过自然语言命令与系统交互:
你: Use myAI Memory to remember I prefer TypeScript over JavaScript
Claude: ✅ Added to your Coding Preferences! I'll remember you prefer TypeScript over JavaScript.
你: Use myAI Memory to load preset developer
Claude: ✅ Loaded developer preset! I'll now use your developer preferences.
🧙♂️ 高级用法
记忆预设
轻松切换不同的人物角色:
你: Use myAI Memory to list presets
Claude: Available presets: personal, work, developer
你: Use myAI Memory to load preset developer
Claude: ✅ Loaded developer preset!
紧急同步
当您需要修复所有平台上的同步问题时:
# 立即同步所有内容
./emergency-sync.sh
命令行界面
# 查看所有可用命令
node dist/cli.js --help
# 直接处理记忆命令
node dist/cli.js --remember "remember I prefer dark mode"
# 启动用于 SSE 传输的 HTTP 服务器
npm run start:http
# 启动用于 MCP 传输的 stdio 服务器
npm run start
开发工作流程
# 在开发模式下运行,具有自动重新加载
npm run dev
# 在开发模式下运行,具有 HTTP 服务器
npm run dev:http
# 监视 TypeScript 编译
npm run build:watch
# 运行测试
npm test
# 运行特定测试
npm test -- -t "platformSync"
# Lint 代码
npm run lint
# 类型检查,不发出文件
npm run typecheck
⚡ 性能基准
我们的缓存系统提供令人难以置信的性能改进:
| 操作 | 无缓存 | 有缓存 | 改进 |
|---|---|---|---|
| 记忆查询 | ~2000ms | ~1ms | 2000x |
| 部分查找 | ~1600ms | ~0.8ms | 2000x |
| 模板解析 | ~120ms | ~0.1ms | 1200x |
| 平台同步 | ~850ms | ~350ms | 2.4x |
🔒 安全与隐私
我们认真对待您的隐私:
- 所有数据都保留在您的设备本地
- CLAUDE.md 文件会自动添加到 .gitignore
- 不会将数据发送到外部服务器(除非使用可选的 Anthropic API 集成)
- 与加密文件系统配合使用,以实现最大安全性
🛠️ 故障排除
常见问题
-
CLAUDE.md 未更新
- 使用
ls -la CLAUDE.md检查文件权限 - 尝试使用
./emergency-sync.sh进行紧急同步 - 验证您的
.env文件中的平台路径
- 使用
-
MCP 连接失败
- 确保 MCP 服务器正在运行,使用
ps aux | grep myai-memory - 检查 Claude Desktop 日志中的 MCP 错误
- 验证您的 Claude Desktop 配置文件
- 确保 MCP 服务器正在运行,使用
-
缓存问题
- 使用
node dist/cli.js --clear-cache清除缓存 - 验证 Anthropic API 密钥是否已正确设置
- 使用
node dist/cli.js --validate检查记忆文件完整性
- 使用
-
自然语言命令不起作用
- 确保使用完全支持的命令模式之一(请参阅支持的自然语言命令部分)
- 如果 Claude 无法识别您的命令,请尝试其他模式
- 对于跨所有平台的同步,请使用直接脚本:
node sync-memory.js
手动同步
如果您在使用自然语言命令或 MCP 服务器时遇到问题:
# 直接同步方法(最可靠)
cd /path/to/myAImemory
node sync-memory.js
# 替代的紧急同步(如果需要修复权限)
cd /path/to/myAImemory
./safe-memory.sh sync
这些方法直接从您的主文件读取并更新所有平台,而无需依赖 MCP 服务器或自然语言处理。
日志和调试
启用调试模式以查看详细日志:
DEBUG=true npm run start
日志文件存储在:
- Linux/macOS:
~/.local/share/myai-memory/logs/ - Windows:
%APPDATA%\myai-memory\logs\
🤝 贡献
欢迎贡献!请随时提交 Pull Request。
- Fork 仓库
- 创建您的功能分支 (
git checkout -b feature/amazing-feature) - 提交您的更改 (
git commit -m 'Add some amazing feature') - 推送到分支 (
git push origin feature/amazing-feature) - 打开 Pull Request
我们遵循标准的 Git 工作流程和 CI 流程:
- 所有 PR 都需要通过测试和 linting
- 新功能应包含测试
- 重大更改应更新文档
- 遵循现有的代码风格和模式
📚 文档
有关更详细的文档,请参阅 Wiki。
API 文档位于 /docs 目录中:
# 生成 API 文档
npm run docs
📄 许可证
该项目已获得 MIT 许可证的许可 - 有关详细信息,请参阅 LICENSE 文件。
📬 联系方式
项目链接:https://github.com/Jktfe/myaimemory-mcp
<p align="center"> 用 ❤️ 为 AI 社区制作 </p>
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。