AI编码助手持久化内存服务

为AI编码助手提供结构化、版本控制的持久化内存服务,支持多项目管理、分支测试和人工审核。

  • by revisium
  • TypeScript
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 revisium/mcp-memory

使用说明

@revisium/mcp存储器

状态:开发中

MCP服务器,为任何AI编码助手提供持久的结构化内存,由 审查 --具有版本控制、分支、回滚和用于查看的可视化管理UI。

适用于Claude Code、Cursor、Windsurf、Copilot、Cline和任何兼容MCP的客户端。

特性

  • 结构化存储器 --将事实、情节和配置存储为表中的键入行
  • 版本控制 --提交、回滚和查看内存更改的历史记录
  • 分支 --为A/B测试代理配置创建分支
  • 人工审核 --通过Revisium管理UI检查和批准内存更改
  • 搜索 --按字段值或行ID过滤和查询内存条目
  • 多项目 --使用模板将内存组织到单独的项目中
  • 零配置 --首次使用时自动创建项目和表

快速开始

1.开始修订

npx @revisium/standalone --port 9222

2.配置IDE

克劳德代码 (~/.claude/settings.json):

{
  "mcpServers": {
    "memory": {
      "command": "npx",
      "args": ["@revisium/mcp-memory"],
      "env": {
        "REVISIUM_URL": "http://localhost:9222"
      }
    }
  }
}

光标 (.cursor/mcp.json):

{
  "mcpServers": {
    "memory": {
      "command": "npx",
      "args": ["@revisium/mcp-memory"],
      "env": {
        "REVISIUM_URL": "http://localhost:9222"
      }
    }
  }
}

帆板运动 (.windsurf/mcp.json):

{
  "mcpServers": {
    "memory": {
      "command": "npx",
      "args": ["@revisium/mcp-memory"],
      "env": {
        "REVISIUM_URL": "http://localhost:9222"
      }
    }
  }
}

3.使用它

该代理现在有17个可用的内存工具。首先 memory_store 呼叫,一个项目 facts, episodes,以及 config 表是自动创建的。

工具

1级——核心(零配置)

工具 说明
memory_store 存储事实/事件/配置--创建或更新行
memory_search 按表、字段值或行ID关键字搜索
memory_recall 按表和ID获取特定条目
memory_delete 删除内存条目
memory_config 获取/设置/列出代理配置条目
memory_commit 提交待处理的更改(如 git commit)
memory_diff 显示待处理的更改(如 git diff)
memory_rollback 丢弃未提交的更改(如 git checkout -- .)
memory_status 显示连接、项目、分支和挂起的更改

第二级——多项目

工具 说明
memory_projects 列出所有内存项目
memory_create_project 从模板创建项目
memory_switch_project 切换活动项目

第三级——分支

工具 说明
memory_branch 创建一个新分支(如 git branch)
memory_switch_branch 切换到其他分支
memory_branches 列出所有分支
memory_history 显示修订历史记录(如 git log)

记忆库

// Store a fact
await memory_store({
  table: 'facts',
  id: 'user-preference-theme',
  data: { topic: 'preferences', content: 'User prefers dark theme', confidence: 0.95 },
});

// Update an existing fact
await memory_store({
  table: 'facts',
  id: 'user-preference-theme',
  data: { topic: 'preferences', content: 'User switched to light theme', confidence: 0.99 },
});

记忆搜索

// Search by field value (string contains)
await memory_search({
  table: 'facts',
  field: 'topic',
  value: 'preferences',
  limit: 20,
});

// Search by row ID keyword
await memory_search({ table: 'facts', query: 'theme' });

// Search across all tables
await memory_search({ limit: 50 });

记忆限制

// Commit pending changes
await memory_commit({ message: 'Updated user preferences' });

memory_branch

// Create a branch
await memory_branch({ name: 'experiment-v2' });

// Switch to another branch
await memory_switch_branch({ name: 'experiment-v2' });

// List branches
await memory_branches({});

模板

项目是使用定义表模式的模板创建的:

  • 代理存储器 (默认)-- facts, episodes, config 表格
  • 书签 — bookmarks 带有标签和读取状态的表
  • 联系人 — contacts, interactions 表格
  • 开支 — expenses, budgets 表格
  • 求职 — applications, contacts 表格
  • 研究 — findings, decisions 表格
  • 任务 — tasks, notes 表格

环境变量

变量 必填 默认 描述
REVISIUM_URL 没有 http://localhost:9222 修订服务器URL
REVISIUM_USERNAME 否 -- 登录用户名
REVISIUM_PASSWORD 否 -- 登录密码
REVISIUM_TOKEN 无 -- JWT令牌(凭据的替代方案)
REVISIUM_PROJECT 没有 memory 默认项目名称
REVISIUM_BRANCH 没有 master 默认分支名称
REVISIUM_ORG 否 用户名 组织ID
REVISIUM_AUTO_COMMIT 没有 false 自动提交后 memory_store 和 memory_delete

当Revisium独立运行时 --no-auth (默认),不需要凭据。

编程式用法

import { createServer } from '@revisium/mcp-memory';

const { server, session } = createServer({
  url: 'http://localhost:9222',
});

// Connect to any MCP transport
await server.connect(transport);

发展

npm install
npm run tsc          # TypeScript check
npm run lint:ci      # ESLint
npm test             # Unit tests
npm run build        # Build CJS + ESM + .d.ts

集成测试

npm run test:integration:up    # Start Revisium standalone
npm run test:integration       # Run integration tests
npm run test:integration:down  # Stop Revisium

许可证

麻省理工学院