内容
<div align="center">
# MCP内存服务器
[](https://sonarcloud.io/summary/new_code?id=revisium_mcp-memory) [](https://sonarcloud.io/summary/new_code?id=revisium_mcp-memory) [](https://github.com/revisium/mcp-memory/blob/master/LICENSE) [](https://github.com/revisium/mcp-memory/releases)
**状态:开发中**
MCP服务器,为任何AI编码助手提供持久化、结构化的内存,由 [Revisium](https://revisium.io) 支持,具有版本控制、分支、回滚和用于审查的可视化管理界面。
与Claude Code、Cursor、Windsurf、Copilot、Cline等任何MCP兼容客户端配合使用。
</div>
## 功能特点
- **结构化内存** — 将事实、事件和配置存储为表格中的类型化行
- **版本控制** — 提交、回滚和查看内存更改的历史记录
- **分支** — 为A/B测试代理配置创建分支
- **人工审查** — 通过Revisium管理界面检查和批准内存更改
- **搜索** — 按字段值或行ID筛选和查询内存条目
- **多项目** — 将内存组织成具有模板的独立项目
- **零配置** — 在首次使用时自动创建项目和表格
## 快速入门
### 1. 启动Revisium
```bash
npx @revisium/standalone --port 9222
```
### 2. 配置您的IDE
**Claude Code** (`~/.claude/settings.json`):
```json
{
"mcpServers": {
"memory": {
"command": "npx",
"args": ["@revisium/mcp-memory"],
"env": {
"REVISIUM_URL": "http://localhost:9222"
}
}
}
}
```
**Cursor** (`.cursor/mcp.json`):
```json
{
"mcpServers": {
"memory": {
"command": "npx",
"args": ["@revisium/mcp-memory"],
"env": {
"REVISIUM_URL": "http://localhost:9222"
}
}
}
}
```
**Windsurf** (`.windsurf/mcp.json`):
```json
{
"mcpServers": {
"memory": {
"command": "npx",
"args": ["@revisium/mcp-memory"],
"env": {
"REVISIUM_URL": "http://localhost:9222"
}
}
}
}
```
### 3. 使用它
代理现在有17种内存工具可用。在第一次`memory_store`调用时,会自动创建一个具有`facts`、`episodes`和`config`表格的项目。
## 工具
### 一级 — 核心(零配置)
| 工具 | 描述 |
|------|-------------|
| `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`) |
### memory_store
```typescript
// 存储事实
await memory_store({
table: 'facts',
id: 'user-preference-theme',
data: { topic: 'preferences', content: 'User prefers dark theme', confidence: 0.95 },
});
// 更新现有事实
await memory_store({
table: 'facts',
id: 'user-preference-theme',
data: { topic: 'preferences', content: 'User switched to light theme', confidence: 0.99 },
});
```
### memory_search
```typescript
// 按字段值搜索(字符串包含)
await memory_search({
table: 'facts',
field: 'topic',
value: 'preferences',
limit: 20,
});
// 按行ID关键字搜索
await memory_search({ table: 'facts', query: 'theme' });
// 跨所有表格搜索
await memory_search({ limit: 50 });
```
### memory_commit
```typescript
// 提交待处理更改
await memory_commit({ message: 'Updated user preferences' });
```
### memory_branch
```typescript
// 创建分支
await memory_branch({ name: 'experiment-v2' });
// 切换到另一个分支
await memory_switch_branch({ name: 'experiment-v2' });
// 列出分支
await memory_branches({});
```
## 模板
项目使用模板创建,模板定义表格架构:
- **agent-memory** (默认)— `facts`、`episodes`、`config` 表格
- **bookmarks** — `bookmarks` 表格,带有标签和阅读状态
- **contacts** — `contacts`、`interactions` 表格
- **expenses** — `expenses`、`budgets` 表格
- **job-search** — `applications`、`contacts` 表格
- **research** — `findings`、`decisions` 表格
- **tasks** — `tasks`、`notes` 表格
## 环境变量
| 变量 | 是否必需 | 默认值 | 描述 |
|----------|----------|---------|-------------|
| `REVISIUM_URL` | 否 | `http://localhost:9222` | Revisium服务器URL |
| `REVISIUM_USERNAME` | 否 | — | 登录用户名 |
| `REVISIUM_PASSWORD` | 否 | — | 登录密码 |
| `REVISIUM_TOKEN` | 否 | — | JWT令牌(凭证替代) |
| `REVISIUM_PROJECT` | 否 | `memory` | 默认项目名称 |
| `REVISIUM_BRANCH` | 否 | `master` | 默认分支名称 |
| `REVISIUM_ORG` | 否 | username | 组织ID |
| `REVISIUM_AUTO_COMMIT` | 否 | `false` | 在`memory_store`和`memory_delete`后自动提交 |
当Revisium独立运行带有`--no-auth`(默认)时,不需要凭证。
## 程序化使用
```typescript
import { createServer } from '@revisium/mcp-memory';
const { server, session } = createServer({
url: 'http://localhost:9222',
});
// 连接到任何MCP传输
await server.connect(transport);
```
## 开发
```bash
npm install
npm run tsc # TypeScript检查
npm run lint:ci # ESLint
npm test # 单元测试
npm run build # 构建CJS + ESM + .d.ts
```
### 集成测试
```bash
npm run test:integration:up # 启动Revisium独立版
npm run test:integration # 运行集成测试
npm run test:integration:down # 停止Revisium
```
## 许可证
MIT