Memory MCP Server

Memory MCP Server

Enables agents to maintain persistent memory through three-tiered architecture: short-term session context with TTL, long-term user profiles and preferences, and searchable episodic event history with sentiment analysis. Provides comprehensive memory management for personalized AI interactions.

Category
访问服务器

README

Memory MCP Server

A production-ready Model Context Protocol server implementing three-tiered memory architecture for vertical agents.

Overview

The Memory MCP Server provides persistent and session-based memory capabilities through three specialized memory types:

  • Short-term Memory: Session context with configurable TTL (default: 30 minutes)
  • Long-term Memory: Persistent user profiles, preferences, and demographics
  • Episodic Memory: Searchable event history with sentiment analysis and tagging

Architecture

Memory Types

Type Persistence Use Case TTL
Short-term In-memory only Session context, temporary state Configurable (default 30m)
Long-term Disk storage User profiles, preferences, demographics Permanent
Episodic Disk storage Event history, experiences, interactions Permanent

Data Storage

memory-data/
├── long-term.json      # User profiles and preferences
└── episodic.json       # Event and experience logs

Installation

Prerequisites

  • Node.js 16.0 or higher
  • npm 7.0 or higher

Setup

  1. Clone and build

    git clone <repository-url>
    cd memory-server
    npm install
    npm run build
    
  2. Configure MCP

    Add to your MCP configuration (e.g., cline_mcp_settings.json):

    {
      "mcpServers": {
        "memory-server": {
          "command": "node",
          "args": ["./memory-server/build/index.js"],
          "settings": {
            "dataDirectory": "./memory-server/memory-data",
            "defaultTTLMinutes": 30
          }
        }
      }
    }
    

API Reference

Tools

Tool Description Required Parameters
set_short_term_memory Store session data with TTL sessionId, key, value
get_short_term_memory Retrieve session data sessionId
set_long_term_memory Store user profile data userId
get_long_term_memory Retrieve user profile userId
add_episodic_memory Record event/experience userId, event, context
get_episodic_memory Retrieve user events userId
search_episodic_memory Search event history userId, query

Resources

  • memory://long-term/{userId} - User profile data (JSON)
  • memory://episodic/{userId} - User event history (JSON)

Prompts

  • memory_summary - Generate comprehensive user memory summary
  • personalization_insights - Extract personalization opportunities

Usage Examples

User Profile Management

// Store user preferences
await server.set_long_term_memory({
  userId: "user-123",
  demographics: { age: 35, location: "New York" },
  preferences: { seating: "poolside", temperature: "cool" }
});

// Record interaction
await server.add_episodic_memory({
  userId: "user-123",
  event: "Guest requested poolside seating",
  context: "Arrived for dinner, asked for poolside table",
  outcome: "Seated at requested location",
  sentiment: "positive",
  tags: ["seating", "dinner"]
});

Session Context

// Store session state
await server.set_short_term_memory({
  sessionId: "session-456", 
  key: "current_order",
  value: { items: ["salad", "wine"], table: 12 },
  ttlMinutes: 45
});

Data Models

Long-term Memory Structure

{
  "userId": {
    "demographics": {
      "age": "number",
      "location": "string", 
      "occupation": "string"
    },
    "contact": {
      "email": "string",
      "phone": "string"
    },
    "preferences": {
      "seating": "string",
      "temperature": "string",
      "communicationStyle": "string"
    },
    "lastUpdated": "timestamp"
  }
}

Episodic Memory Structure

{
  "id": "episodic_{timestamp}_{randomId}",
  "userId": "string",
  "sessionId": "string",
  "event": "string",
  "context": "string", 
  "outcome": "string",
  "sentiment": "positive|negative|neutral",
  "timestamp": "number",
  "tags": ["string"]
}

Development

Commands

npm run build      # Build for production
npm run watch      # Development mode with file watching
npm run inspector  # Run MCP debugging tools

Testing

npm run build      # Build first
node test-memory.js  # Run functional tests

Production Considerations

Performance

  • Memory operations: <10ms
  • Disk operations: <50ms (SSD)
  • Search operations: <100ms (1000 memories)
  • Memory usage: Linear with data volume

Security

  • Input validation on all parameters
  • Atomic file operations preventing corruption
  • No external API dependencies
  • Local-only data storage

Reliability

  • Graceful degradation when storage unavailable
  • Automatic memory cleanup for expired sessions
  • Data persistence with automatic recovery
  • Comprehensive error handling

Monitoring

  • Structured logging for all operations
  • Error tracking with diagnostic information
  • Data integrity verification on startup
  • Performance metrics available

Troubleshooting

Common Issues

Server fails to start

  • Verify Node.js version >= 16.0
  • Run npm run build to compile TypeScript
  • Check file permissions on build/index.js

Data not persisting

  • Ensure memory-data/ directory is writable
  • Verify disk space availability
  • Check system logs for I/O errors

Memory not found

  • Validate userId/sessionId format
  • Check TTL expiration for short-term memory
  • Verify operation sequencing

Debug Mode

DEBUG=memory-server:* node build/index.js

License

MIT License - see LICENSE file for details.

Support

  • Issues: Create GitHub issue
  • Email: cbuntingde@gmail.com
  • Documentation: Refer to inline code comments

Enterprise-grade production implementation with comprehensive error handling, type safety, and operational reliability.

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选