memory-forge

memory-forge

A production-ready MCP server for persistent AI memory across LLMs like Claude and ChatGPT. Provides automatic conversation backup, multi-user support, and multi-storage (PostgreSQL, Redis, Qdrant).

Category
访问服务器

README

🧠 Memory Forge - Universal AI Context & Memory System

smithery badge MIT License

A production-ready MCP (Model Context Protocol) server for persistent AI memory across Claude, ChatGPT, and any LLM.

🎯 What is Memory Forge?

Memory Forge is a complete infrastructure solution that gives AI assistants persistent memory and context awareness. It includes:

  • MCP Server: TypeScript-based context server following the Model Context Protocol
  • Multi-Storage: PostgreSQL for persistence + Redis for speed + Qdrant for vector search
  • Auto-Save: Automatic conversation backup every 30 seconds
  • Multi-User: Support for unlimited users with isolated contexts
  • Deploy Anywhere: Local Docker, Railway, Vercel, or Smithery

🚀 Quick Start (Under 5 Minutes!)

Option 1: One-Command Setup (Recommended)

curl -sSL https://raw.githubusercontent.com/cpretzinger/memory-forge/main/scripts/setup.sh | bash

Option 2: Manual Setup

git clone https://github.com/cpretzinger/memory-forge.git
cd memory-forge
npm install
npm run setup

📦 What's Included

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

🛠️ Installation

Prerequisites

  • Node.js 20+
  • Docker (for local deployment)
  • 2GB RAM minimum
  • 10GB disk space

Step-by-Step Setup

  1. Clone and Install
git clone https://github.com/cpretzinger/memory-forge.git
cd memory-forge
npm install
  1. Configure Environment
cp examples/.env.example .env
# Edit .env with your settings (see Configuration section)
  1. Run Setup Script
npm run setup
# This will:
# - Check prerequisites
# - Generate secure passwords
# - Set up databases
# - Configure services
# - Start everything
  1. Test Installation
npm test
# Should show all services as ✅ Running

⚙️ Configuration

Environment Variables

Create a .env file from the example:

# Project Configuration
PROJECT_NAME=my-ai-assistant
NODE_ENV=production

# Database Credentials (generated by setup script)
POSTGRES_PASSWORD=<auto-generated>
REDIS_PASSWORD=<auto-generated>
QDRANT_API_KEY=<auto-generated>

# MCP Configuration
MCP_AUTH_TOKEN=<auto-generated>
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:6333

Claude Code Configuration

Add to your Claude desktop config (~/.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"
      }
    }
  }
}

🚢 Deployment Options

Local Docker (Development)

npm run docker:up
# Access at http://localhost:3005

Railway (Production)

npm run deploy:railway
# Follow prompts to configure

Smithery (Managed MCP)

npm run deploy:smithery
# Or use Smithery CLI:
smithery publish cpretzinger/memory-forge

Vercel (Serverless)

npm run deploy:vercel
# Configure environment variables in Vercel dashboard

🔌 Using with Smithery

Installing from Smithery Registry

  1. Find the server:
smithery search memory-forge
  1. Install directly into Claude:
smithery install cpretzinger/memory-forge
  1. Or add to your config manually:
{
  "mcpServers": {
    "memory-forge": {
      "command": "npx",
      "args": ["-y", "@smithery/memory-forge"],
      "env": {
        "API_KEY": "your-api-key"
      }
    }
  }
}

Publishing Your Own Fork

  1. Create Smithery account:
smithery auth
  1. Configure smithery.yml:
name: memory-forge
version: 1.0.0
description: Universal AI memory system
author: yourname
runtime: typescript
  1. Publish:
smithery publish

📊 Architecture

Services Overview

Service Purpose Port Technology
MCP Server Context API 3005 TypeScript/Express
PostgreSQL Persistent storage 5432 PostgreSQL 16
Redis Cache & sessions 6379 Redis 7
Qdrant Vector search 6333 Qdrant
n8n Automation 5678 n8n (optional)

Data Flow

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 Reference

Available Tools

store_context

Store conversation context with auto-save

{
  sessionId?: string,  // Optional, auto-generated if not provided
  userId?: string,     // Optional user identifier
  context: object,     // Required context data
  metadata?: object    // Optional metadata
}

retrieve_context

Retrieve conversation context

{
  sessionId?: string,  // Optional, gets latest if not provided
  userId?: string      // Optional user filter
}

search_context

Search through all contexts

{
  query: string,       // Required search query
  limit?: number,      // Optional result limit (default: 10)
  semantic?: boolean   // Use vector search (default: false)
}

list_sessions

List all available sessions

{
  userId?: string,     // Optional user filter
  limit?: number       // Optional limit (default: 10)
}

🧪 Testing

Run All Tests

npm test

Test Specific Service

npm run test:mcp      # Test MCP server
npm run test:storage  # Test storage layer
npm run test:e2e      # End-to-end tests

Manual Testing

# 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}'

🔒 Security

Default Security Features

  • Auto-generated secure passwords (32+ characters)
  • Bearer token authentication on all endpoints
  • Isolated user contexts
  • Encrypted storage for sensitive data
  • No passwords in logs or error messages

Production Hardening

  1. Use environment-specific .env files
  2. Enable HTTPS/TLS in production
  3. Set up firewall rules
  4. Use secrets management (AWS Secrets Manager, etc.)
  5. Enable audit logging

📈 Monitoring

Health Checks

# Check all services
npm run health

# Individual checks
curl http://localhost:3005/health

Metrics

  • Request latency
  • Storage usage
  • Active sessions
  • Cache hit rate

🤝 Contributing

We welcome contributions! Please see CONTRIBUTING.md for guidelines.

Development Setup

# Install dev dependencies
npm install --save-dev

# Run in development mode
npm run dev

# Run with hot reload
npm run dev:watch

📝 License

MIT License - see LICENSE file

🆘 Support

Common Issues

Q: Services won't start?

# Reset everything
npm run reset
npm run setup

Q: Can't connect to MCP server?

# Check if running
npm run health

# Check logs
docker logs memory-forge-mcp

Q: How to upgrade?

git pull
npm install
npm run migrate

Get Help

🚀 Roadmap

  • [ ] OpenAI function calling support
  • [ ] LangChain integration
  • [ ] Web UI dashboard
  • [ ] Backup/restore tools
  • [ ] Multi-region support
  • [ ] GraphQL API

Built with ❤️ by the Memory Forge team

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选