🧠 Memory Forge-通用AI上下文和存储系统
](https://smithery.ai/server/@cpretzinger/ai-assistant-simple) 
一个生产就绪的MCP(模型上下文协议)服务器,用于跨Claude、ChatGPT和任何LLM的持久AI内存。
🎯 什么是记忆锻造?
Memory Forge是一个完整的基础设施解决方案,为AI助手提供持久的内存和上下文感知。它包括:
- MCP服务器:遵循模型上下文协议的基于TypeScript的上下文服务器
- 多存储:PostgreSQL用于持久化+Redis用于速度+Qdrant用于向量搜索
- 自动保存:每30秒自动备份一次对话
- 多用户:支持具有孤立上下文的无限用户
- 随时随地部署:当地Docker、铁路、Vercel或Smithery
🚀 快速入门(不到5分钟!)
选项1:一个命令设置(推荐)
curl -sSL https://raw.githubusercontent.com/cpretzinger/memory-forge/main/scripts/setup.sh | bash选项2:手动设置
git clone https://github.com/cpretzinger/memory-forge.git
cd memory-forge
npm install
npm run setup📦 包含什么
memory-forge/
├── src/ # TypeScript source code
│ ├── server.ts # Main MCP server
│ ├── handlers/ # Request handlers
│ ├── storage/ # Storage adapters
│ └── types/ # TypeScript definitions
├── docs/ # Documentation
│ ├── SERVICES.md # Service architecture
│ ├── DOCKER.md # Docker setup guide
│ ├── RAILWAY.md # Railway deployment
│ └── SMITHERY.md # Smithery deployment
├── scripts/ # Setup & deployment scripts
│ ├── setup.sh # Universal setup script
│ ├── deploy.ts # Deployment helper
│ └── test.ts # System test script
├── config/ # Configuration files
│ ├── docker-compose.yml
│ ├── railway.toml
│ └── smithery.yml
└── examples/ # Example implementations
├── .env.example # Environment template
└── claude-config.json
🛠️ 安装
先决条件
- Node.js 20+
- Docker(用于本地部署)
- 最低2GB RAM
- 10GB磁盘空间
逐步设置
- 克隆并安装
git clone https://github.com/cpretzinger/memory-forge.git
cd memory-forge
npm install- 配置环境
cp examples/.env.example .env
# Edit .env with your settings (see Configuration section)- 运行安装脚本
npm run setup
# This will:
# - Check prerequisites
# - Generate secure passwords
# - Set up databases
# - Configure services
# - Start everything- 试验装置
npm test
# Should show all services as ✅ Running⚙️ 配置
环境变量
创建一个 .env 示例中的文件:
# Project Configuration
PROJECT_NAME=my-ai-assistant
NODE_ENV=production
# Database Credentials (generated by setup script)
POSTGRES_PASSWORD=
REDIS_PASSWORD=
QDRANT_API_KEY=
# MCP Configuration
MCP_AUTH_TOKEN=
MCP_PORT=3005
# API Keys (optional - add your own)
OPENAI_API_KEY=sk-...
ANTHROPIC_API_KEY=sk-ant-...
# Service URLs (for production)
DATABASE_URL=postgresql://user:pass@host:5432/dbname
REDIS_URL=redis://:password@host:6379
QDRANT_URL=http://host:6333Claude代码配置
添加到您的Claude桌面配置(~/.config/claude/claude_desktop_config.json):
{
"mcpServers": {
"memory-forge": {
"command": "node",
"args": ["/path/to/memory-forge/dist/bridge.js"],
"env": {
"MCP_SERVER_URL": "http://localhost:3005/mcp",
"MCP_AUTH_TOKEN": "your-token-here",
"AUTO_SAVE": "true"
}
}
}
}🚢 部署选项
本地Docker(开发)
npm run docker:up
# Access at http://localhost:3005铁路(生产)
npm run deploy:railway
# Follow prompts to configureSmithery(管理MCP)
npm run deploy:smithery
# Or use Smithery CLI:
smithery publish cpretzinger/memory-forgeVercel(无服务器)
npm run deploy:vercel
# Configure environment variables in Vercel dashboard🔌 与Smithery一起使用
从Smithery注册表安装
- 查找服务器:
smithery search memory-forge- 直接安装到Claude中:
smithery install cpretzinger/memory-forge- 或者手动添加到配置中:
{
"mcpServers": {
"memory-forge": {
"command": "npx",
"args": ["-y", "@smithery/memory-forge"],
"env": {
"API_KEY": "your-api-key"
}
}
}
}发布你自己的叉子
- 创建Smithery帐户:
smithery auth- 配置smithery.yml:
name: memory-forge
version: 1.0.0
description: Universal AI memory system
author: yourname
runtime: typescript- 发布:
smithery publish📊 建筑
服务概述
| 服务 | 目的 | 港口 | 技术 |
|---|---|---|---|
| MCP服务器 | 上下文API | 3005 | TypeScript/Express |
| PostgreSQL | 持久存储 | 5432 | PostgreSQL 16 |
| Redis缓存和会话6379 Redis 7 | |||
| Qdrant | 矢量搜索 | 6333 | Qdrant |
| n8n | 自动化 | 5678 | n8n(可选) |
数据流
graph LR
A[Claude/LLM] -->|MCP Protocol| B[MCP Server]
B --> C[Redis Cache]
B --> D[PostgreSQL]
B --> E[Qdrant Vectors]
C -->|Fast Read| B
D -->|Persistent| B
E -->|Semantic Search| B🔧 api参考
可用工具
store_context
使用自动保存功能存储对话上下文
{
sessionId?: string, // Optional, auto-generated if not provided
userId?: string, // Optional user identifier
context: object, // Required context data
metadata?: object // Optional metadata
}retrieve_context
检索对话上下文
{
sessionId?: string, // Optional, gets latest if not provided
userId?: string // Optional user filter
}search_context
搜索所有上下文
{
query: string, // Required search query
limit?: number, // Optional result limit (default: 10)
semantic?: boolean // Use vector search (default: false)
}list_sessions
列出所有可用会话
{
userId?: string, // Optional user filter
limit?: number // Optional limit (default: 10)
}🧪 测试
运行所有测试
npm test测试特定服务
npm run test:mcp # Test MCP server
npm run test:storage # Test storage layer
npm run test:e2e # End-to-end tests手动测试
# Test MCP endpoint
curl -X POST http://localhost:3005/mcp \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"tools/list","id":1}'🔒 安全
默认安全功能
- 自动生成的安全密码(32+个字符)
- 所有端点上的承载令牌身份验证
- 孤立的用户上下文
- 敏感数据的加密存储
- 日志或错误消息中没有密码
生产硬化
- 使用环境特定
.env文件 - 在生产环境中启用HTTPS/TLS
- 设置防火墙规则
- 使用机密管理(AWS机密管理器等)
- 启用审核日志记录
📈 监控
健康检查
# Check all services
npm run health
# Individual checks
curl http://localhost:3005/health指标
- 请求延迟
- 存储使用情况
- 活动会话
- 缓存命中率
🤝 贡献
我们欢迎捐款!请看 贡献.md 作为指导方针。
开发设置
# Install dev dependencies
npm install --save-dev
# Run in development mode
npm run dev
# Run with hot reload
npm run dev:watch📝 许可证
MIT许可证-请参阅 许可证 文件
🆘 支持
常见问题
Q: 服务无法启动?
# Reset everything
npm run reset
npm run setupQ: 无法连接到MCP服务器?
# Check if running
npm run health
# Check logs
docker logs memory-forge-mcpQ: 如何升级?
git pull
npm install
npm run migrate获得帮助
- 📧 电子邮件:support@memory-forge.ai
- 💬 不一致: 加入我们的服务器
- 🐛 问题:
🚀 路线图
- \[\]OpenAI函数调用支持
- \[\]LangChain集成
- \[\]Web UI仪表板
- \[\]备份/恢复工具
- \[\]多区域支持
- \[\]GraphQL API
______________________________________________________________________
内置于❤️ 由Memory Forge团队提供
