MCP Memory Server
MCP内存服务器
该服务器使用 mem0 原理为 AI 助手实现长期记忆功能,由 PostgreSQL 和 pgvector 提供支持,可实现高效的向量相似性搜索。
特征
PostgreSQL 结合 pgvector 进行向量相似性搜索
使用 BERT 自动生成嵌入
用于内存操作的 RESTful API
语义搜索功能
支持不同类型的记忆(学习、经验等)
基于标签的记忆检索
记忆信心评分
用于实时更新的服务器发送事件 (SSE)
兼容 Cursor MCP 协议
Related MCP server: MCPMem
先决条件
安装了 pgvector 扩展的 PostgreSQL 14+:
# In your PostgreSQL instance:
CREATE EXTENSION vector;Node.js 16+
设置
安装依赖项:
npm install配置环境变量:将
.env.sample复制到.env并调整值:
cp .env.sample .env.env配置示例:
# With username/password
DATABASE_URL="postgresql://username:password@localhost:5432/mcp_memory"
PORT=3333
# Local development with peer authentication
DATABASE_URL="postgresql:///mcp_memory"
PORT=3333初始化数据库:
npm run prisma:migrate启动服务器:
npm start对于自动重新加载的开发:
npm run dev与游标一起使用
在 Cursor 中添加 MCP 服务器
要将内存服务器添加到 Cursor,您需要修改位于~/.cursor/mcp.json MCP 配置文件。将以下配置添加到mcpServers对象:
{
"mcpServers": {
"memory": {
"command": "node",
"args": [
"/path/to/your/memory/src/server.js"
]
}
}
}将/path/to/your/memory替换为内存服务器安装的实际路径。
例如,如果您将存储库克隆到/Users/username/workspace/memory ,则您的配置将如下所示:
{
"mcpServers": {
"memory": {
"command": "node",
"args": [
"/Users/username/workspace/memory/src/server.js"
]
}
}
}Cursor 会在需要时自动启动服务器。您可以通过以下方式验证服务器是否正常工作:
打开光标
Cursor 启动时,内存服务器将自动启动
您可以通过访问
http://localhost:3333/mcp/v1/health检查服务器状态
可用的 MCP 端点
上交所连接
端点:
GET /mcp/v1/sse查询参数:
subscribe:要订阅的事件的逗号分隔列表(可选)
活动:
connected:初始连接时发送memory.created:创建新记忆时发送memory.updated:当现有记忆更新时发送
内存操作
创造记忆
POST /mcp/v1/memory
Content-Type: application/json
{
"type": "learning",
"content": {
"topic": "Express.js",
"details": "Express.js is a web application framework for Node.js"
},
"source": "documentation",
"tags": ["nodejs", "web-framework"],
"confidence": 0.95
}搜索记忆
GET /mcp/v1/memory/search?query=web+frameworks&type=learning&tags=nodejs列出回忆
GET /mcp/v1/memory?type=learning&tags=nodejs,web-framework健康检查
GET /mcp/v1/health响应格式
所有 API 响应均遵循标准 MCP 格式:
{
"status": "success",
"data": {
// Response data
}
}或者对于错误:
{
"status": "error",
"error": "Error message"
}记忆图式
id:唯一标识符
类型:记忆的类型(学习、经验等)
content:实际内存内容(JSON)
来源:记忆从何而来
嵌入:内容的向量表示(384 维)
tags:相关标签的数组
信心:信心得分(0-1)
createdAt:内存创建时间
updatedAt:内存最后更新时间
This server cannot be deployed
Maintenance
Related MCP Connectors
- memoryOAuthcom.leapmemory
Long-term memory for AI assistants. Isolated per-user storage, recall across conversations.
Shared cross-LLM long-term memory over MCP: semantic recall, sessions, and media (pgvector).
Persistent memory for AI assistants: store, search, and connect knowledge across conversations.
Memory system for AI agents with semantic search. Store and recall memories with ease.
Related MCP Servers
- -licenseNot gradedqualityNot gradedmaintenanceEnables AI assistants to store and retrieve long-term memories using PostgreSQL with vector similarity search. Supports semantic memory operations, tagging, and real-time updates for persistent learning across conversations.-
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to store and retrieve memories with semantic search capabilities using vector embeddings. Provides persistent memory storage with SQLite backend for context retention across conversations.48 npm1MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to store, retrieve, and manage contextual knowledge across sessions using semantic search with PostgreSQL and vector embeddings. Supports memory relationships, clustering, multi-agent isolation, and intelligent caching for persistent conversational context.17 npm49MIT
- AlicenseNot gradedqualityBmaintenancePersistent semantic memory for AI agents using PostgreSQL and vector embeddings, enabling cross-session continuity and semantic search.AGPL 3.0