MCP Memory Server

Integrations

  • Powers the web application framework that implements the memory server's RESTful API endpoints for memory operations

  • Serves as the runtime environment for the memory server, enabling RESTful API endpoints and Server-Sent Events for real-time memory updates

  • Provides vector similarity search capabilities using pgvector extension for efficient storage and retrieval of memory embeddings

MCP内存服务器

该服务器使用 mem0 原理为 AI 助手实现长期记忆功能,由 PostgreSQL 和 pgvector 提供支持,可实现高效的向量相似性搜索。

特征

  • PostgreSQL 结合 pgvector 进行向量相似性搜索
  • 使用 BERT 自动生成嵌入
  • 用于内存操作的 RESTful API
  • 语义搜索功能
  • 支持不同类型的记忆(学习、经验等)
  • 基于标签的记忆检索
  • 记忆信心评分
  • 用于实时更新的服务器发送事件 (SSE)
  • 兼容 Cursor MCP 协议

先决条件

  1. 安装了 pgvector 扩展的 PostgreSQL 14+:
# In your PostgreSQL instance: CREATE EXTENSION vector;
  1. Node.js 16+

设置

  1. 安装依赖项:
npm install
  1. 配置环境变量:将.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
  1. 初始化数据库:
npm run prisma:migrate
  1. 启动服务器:
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 会在需要时自动启动服务器。您可以通过以下方式验证服务器是否正常工作:

  1. 打开光标
  2. Cursor 启动时,内存服务器将自动启动
  3. 您可以通过访问http://localhost:3333/mcp/v1/health检查服务器状态

可用的 MCP 端点

上交所连接

  • 端点GET /mcp/v1/sse
  • 查询参数
    • subscribe :要订阅的事件的逗号分隔列表(可选)
  • 活动
    • connected :初始连接时发送
    • memory.created :创建新记忆时发送
    • memory.updated :当现有记忆更新时发送

内存操作

  1. 创造记忆
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 }
  1. 搜索记忆
GET /mcp/v1/memory/search?query=web+frameworks&type=learning&tags=nodejs
  1. 列出回忆
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:内存最后更新时间
-
security - not tested
F
license - not found
-
quality - not tested

使用 PostgreSQL 和 pgvector 为 AI 助手实现长期记忆功能,实现高效的向量相似性搜索,从而实现对存储信息的语义检索。

  1. Features
    1. Prerequisites
      1. Setup
        1. Using with Cursor
          1. Adding the MCP Server in Cursor
          2. Available MCP Endpoints
          3. Health Check
          4. Response Format
        2. Memory Schema
          ID: qmd9wr90a7