Skip to main content

Cross-IDE shared memory MCP Server for AI Agents. Supports Kiro, Cursor, Windsurf, Trae and more.

Project description

shared-memory-mcp

跨 IDE 共享记忆的 MCP Server。支持 Kiro、Cursor、Windsurf、Trae 等多终端间的会话记忆共享。

Agent 自动判断写入时机,无需人工干预。使用 SQLite + FTS5,零外部依赖。

安装

# 方式一:uvx 直接运行(推荐,无需安装)
uvx shared-memory-mcp

# 方式二:pip 安装
pip install shared-memory-mcp

配置 MCP

方式一:uvx(推荐)

发布到 PyPI 后,在各 IDE 的 MCP 配置中添加:

{
  "mcpServers": {
    "shared-memory": {
      "command": "uvx",
      "args": ["shared-memory-mcp"],
      "disabled": false,
      "autoApprove": ["memory_write", "memory_read", "memory_list", "memory_delete"]
    }
  }
}

方式二:本地源码运行

{
  "mcpServers": {
    "shared-memory": {
      "command": "python",
      "args": ["-m", "shared_memory_mcp.server"],
      "env": {
        "PYTHONPATH": "D:\\github\\mcp-sharedMemory\\shared-memory-mcp\\src"
      },
      "disabled": false,
      "autoApprove": ["memory_write", "memory_read", "memory_list", "memory_delete"]
    }
  }
}

各 IDE 配置文件位置

IDE 项目级配置 全局配置
Kiro .kiro/settings/mcp.json ~/.kiro/settings/mcp.json
Cursor .cursor/mcp.json ~/.cursor/mcp.json
Windsurf 对应 MCP 配置位置 对应全局配置
Trae 对应 MCP 配置位置 对应全局配置

配置 Steering 规则

在各 IDE 的全局规则中添加以下内容,让 Agent 自动读写记忆:

## 共享记忆规则

### 项目标识
- project 参数使用「父级文件夹/当前文件夹」拼接,如果父级是磁盘根目录则只用当前文件夹名
  - 例:D:\github\my-app → project="github/my-app"
  - 例:D:\my-app → project="my-app"

### 会话开始
- 自动调用 memory_list(project="<当前项目名>") 获取记忆索引
- 如有相关记忆,调用 memory_read 获取最近关键记忆的摘要

### 自动写入时机
当你做出以下行为时,自动调用 memory_write 写入共享记忆:
- 架构决策(type="decision")
- 阶段完成(type="milestone")
- 重要结论(type="conclusion")
- 项目上下文(type="context")
- 问题方案(type="issue")

### 用户手动触发
- "记住:..." / "记录:..." — 直接写入
- "记录上面的关键点" / "总结记录一下" — 回顾对话提取关键内容写入
- "记录上一轮对话" — 仅回顾上一个来回

### 不记录
- 简单问答、闲聊、临时调试等低价值信息

各 IDE 规则文件位置

IDE 全局规则路径
Kiro ~/.kiro/steering/shared-memory.md
Cursor Cursor Settings → Rules → User Rules

工具说明

工具 说明 Token 消耗
memory_write 写入记忆,返回仅 id+status 极低
memory_read 读取记忆,默认只返回摘要
memory_list 极简索引,每条一行 最低
memory_delete 删除过时记忆 极低

发布到 PyPI

前置条件

  1. 注册 PyPI 账号
  2. 安装构建工具:
pip install build twine

构建与发布

# 进入项目目录
cd shared-memory-mcp

# 构建
python -m build

# 上传到 TestPyPI(先测试)
twine upload --repository testpypi dist/*

# 从 TestPyPI 测试安装
pip install --index-url https://test.pypi.org/simple/ shared-memory-mcp

# 确认无误后,上传到正式 PyPI
twine upload dist/*

发布后验证

# uvx 直接运行(无需安装)
uvx shared-memory-mcp

# 或 pip 安装后运行
pip install shared-memory-mcp
shared-memory-mcp

数据存储

  • 数据库文件:~/.shared-memory-mcp/memories.db
  • 所有 IDE 共享同一个 SQLite 数据库
  • 使用 WAL 模式支持并发读取
  • FTS5 全文搜索索引

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

shared_memory_mcp-0.3.0.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

shared_memory_mcp-0.3.0-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file shared_memory_mcp-0.3.0.tar.gz.

File metadata

  • Download URL: shared_memory_mcp-0.3.0.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for shared_memory_mcp-0.3.0.tar.gz
Algorithm Hash digest
SHA256 e085449cfae62de493ab36c8b3ce4cd2c26fbc9230d03d661be35e6b1954799f
MD5 14607b942b141ce2c55a9e432a707a89
BLAKE2b-256 df18e155063e1728a924b2d975a16ade6bc462a44be0ba6b1a2a2e46d109494c

See more details on using hashes here.

File details

Details for the file shared_memory_mcp-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for shared_memory_mcp-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 62ad7978509bd0b999d9ac8c61a8a3c21ab885cb9f7b7102ea7ccc687be4a1d5
MD5 eb1163e894d2f83dba5ffe629d372b39
BLAKE2b-256 26e6529f75b291a2bd557eb1671af1f45297d007b43b3886a5f90a2db4d7eed8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page