使用说明
AI内存中心
通过模型上下文协议(MCP)为AI助手提供共享内存层。存储个人上下文、偏好和注释,任何兼容MCP的AI助手都可以访问,解决了在AI工具之间切换时丢失上下文的问题。
问题
每次你切换人工智能助手(Claude、ChatGPT、Copilot等)时,你都会失去你建立的所有上下文和偏好。你最终会不断地重复自己:
- “比起JavaScript,我更喜欢TypeScript”
- “我的项目使用PostgreSQL”
- “我正在开发一个React Native应用程序”
解决方案
AI Memory Hub提供了一个集中式存储层,该层:
- 坚持你的背景 在所有AI交互中
- 分享回忆 通过MCP在不同的AI助手之间进行交互
- 让您控制 AI助手对你了解多少
- 参考特定记忆 使用唯一ID
运作原理
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Claude Code │ │ ChatGPT │ │ Other AI │
│ │ │ │ │ │
└────────┬────────┘ └────────┬────────┘ └────────┬────────┘
│ │ │
│ MCP Protocol │ │
└───────────────────────┼───────────────────────┘
│
┌────────────▼────────────┐
│ AI Memory Hub │
│ │
│ - Personal preferences │
│ - Project context │
│ - Work notes │
│ - Any memory you want │
└─────────────────────────┘
特性
- 安全认证 -由Stytch提供技术支持,用于安全的用户身份验证
- MCP集成 -可与任何兼容MCP的AI助手配合使用
- CRUD操作 -通过web UI完全控制您的记忆
- 唯一内存ID -在对话中引用特定记忆
- 实时同步 -所有AI工具的变化都会立即反映出来
快速开始
先决条件
1.克隆存储库
git clone https://github.com/yourusername/ai-memory-hub.git
cd ai-memory-hub
2.后端设置
cd backend
# Install dependencies
uv sync
# Create .env file
cp .env.example .env
编辑 .env 使用您的Stytch凭据:
STYTCH_PROJECT_ID=project-test-xxxxxxxx
STYTCH_SECRET=secret-test-xxxxxxxx
STYTCH_DOMAIN=https://test.stytch.com/v1/public/project-test-xxxxxxxx
启动后端:
uv run python main.py
MCP服务器运行在 http://localhost:8000
3.前端设置
cd frontend
# Install dependencies
pnpm install
# Create .env file with your Stytch public token
echo "VITE_STYTCH_PUBLIC_TOKEN=public-token-test-xxxxxxxx" > .env
# Start development server
pnpm dev
web UI可在 http://localhost:5173
4.连接您的AI助手
看 连接AI助手 有关详细的设置说明,请参阅下面的部分。
连接AI助手
克劳德代码CLI
将AI Memory Hub添加到Claude Code的最简单方法:
# Add the MCP server (replace with your server URL)
claude mcp add --transport http ai-memory-hub http://localhost:8000/mcp
# For remote/deployed servers
claude mcp add --transport http ai-memory-hub https://your-server.com/mcp
添加后,当您首次使用内存工具时,Claude Code将提示您通过Stytch进行身份验证。
替代方案:手动配置
编辑您的Claude Code配置文件(~/.claude/settings.json 或通过 claude config):
{
"mcpServers": {
"ai-memory-hub": {
"command": "npx",
"args": ["-y", "mcp-remote", "http://localhost:8000/mcp"]
}
}
}
克劳德桌面
添加到您的Claude桌面配置(~/Library/Application Support/Claude/claude_desktop_config.json 在macOS上):
{
"mcpServers": {
"ai-memory-hub": {
"command": "npx",
"args": ["-y", "mcp-remote", "http://localhost:8000/mcp"]
}
}
}
添加配置后重新启动Claude Desktop。
其他MCP兼容客户端
对于任何兼容MCP的AI助手,请使用以下连接详细信息:
| 财产 | 价值 |
|---|---|
| 传输 | HTTP |
| 端点 | http://localhost:8000/mcp |
| Auth | OAuth 2.0(通过Stytch自动) |
MCP工具可用
| 工具 | 说明 |
|---|---|
get_my_memories |
检索已验证用户的所有内存 |
get_memory_by_id |
通过其唯一ID获取特定内存 |
add_memory |
存储新内存以备将来参考 |
使用示例
克劳德密码
You: What are my preferences?
AI: Let me check your memories...
[Calls get_my_memories]
Based on your memories, you prefer TypeScript, use VS Code, and are working on a React Native project.
You: Remember that I'm using PostgreSQL 15 for this project
AI: [Calls add_memory with "Using PostgreSQL 15 for current project"]
I've saved that to your memory hub.
You: Refer to memory #abc123 for my coding style
AI: [Calls get_memory_by_id with "abc123"]
Got it! I see your coding style preferences...
在Web UI中
- 登录地址:
http://localhost:5173 - 添加您希望AI助手知道的记忆
- 复制内存ID以在对话中引用
- 根据需要编辑或删除记忆
项目结构
ai-memory-hub/
├── backend/
│ ├── main.py # FastMCP server with MCP tools
│ ├── database.py # SQLAlchemy models and repository
│ └── .env # Environment variables
├── frontend/
│ ├── src/
│ │ ├── components/ # React components
│ │ ├── config/ # Configuration
│ │ └── App.jsx # Main app router
│ └── .env # Frontend environment
└── README.md
技术栈
- 后端:Python、FastMCP、SQLAlchemy、SQLite
- 前端:React、Vite、顺风CSS v4
- 认证:Stytch(密码+OAuth)
- 协议:模型上下文协议(MCP)
安全
- 所有API端点都需要身份验证
- 通过Stytch API验证的会话令牌
- MCP工具使用JWT承载身份验证
- 用户数据由User_id隔离
贡献
欢迎投稿!请打开问题或提交PR。