Skip to main content
Glama

shared-memory-mcp

让多个 Claude 窗口 / 账号共用一份记忆和一个交接信箱。零依赖、纯本地。 One shared notebook and mailbox for several Claude windows or accounts. Zero dependencies, fully local.

中文 · English


中文

它解决什么问题

同时开着好几个 Claude(多个桌面窗口、多个账号、桌面版加 Claude Code)时,它们互相看不到对方的对话。 换窗口就要重新交代一遍背景,上一个窗口做到哪、踩过什么坑,下一个窗口一无所知。

这个 MCP 服务器给它们一个共同的"笔记本"和"信箱":

  • 共享记忆:存下你的偏好、项目、决定,任何窗口都能搜到。

  • 交接信箱:窗口之间留言(不是即时推送,对方调用 msg_read 时才看到),按分类(交接、版本、任务……)归档,已读的也能随时翻出来。

  • 数据只是本机上的两个 JSONL 文本文件,不联网、不上传,你可以直接打开看、备份、删除。

安装

需要 Node.js 18+。

git clone <本仓库地址>
cd shared-memory-mcp
node bin/install.js --lang zh        # 写入 Claude 桌面版的配置(会先备份)

然后完全退出所有 Claude 桌面版(包括托盘图标)再重新打开。

常用选项:

选项

作用

--dir <目录>

记忆存放位置,默认 ~/.shared-memory-mcp

--config <文件>

指定某个 claude_desktop_config.json,可重复(多开的桌面版各有自己的配置)

--lang zh

工具描述用中文(默认英文)

--dry-run

只显示会改哪些文件,不真改

--undo

只移除本工具的那一项,其他设置不动

每个配置文件修改前都会备份为 *.bak-时间。配置文件格式有误时会跳过,不会强行改。

Claude Code:

claude mcp add shared-memory -e SHARED_MEMORY_DIR="$HOME/.shared-memory-mcp" -- node /path/to/shared-memory-mcp/src/server.js

多个窗口要共用同一份记忆,只要它们的 SHARED_MEMORY_DIR 指向同一个目录。

工具

工具

用途

memory_save

保存一条记忆(可带标签)

memory_search

搜索:空格分隔关键词,默认命中任意一个;match: "all" 要求全中;可按 tag 过滤、限制 limit 条

memory_delete

按编号删除

msg_send

给另一个窗口留言,可带分类

msg_read

读发给自己的未读留言并标记已读;all_history 看全部往来

msg_board

按分类翻信箱,不管发给谁、读没读过;list 查看分类和数量

让它真的被用起来

模型不会自己想起来调用工具。建议在 Claude 的偏好设置(Settings → Profile)里加几句,例如:

每次新对话开始时,先调用 memory_search 查有没有相关记忆,再调用 msg_read 看有没有给我的留言。用户说"记住"的内容一定要用 memory_save 存下来。我的名字叫 <窗口名>。

并发与限制

  • 所有写入都会先拿一个目录锁,多个窗口同时读写不会互相覆盖(有多进程压力测试)。崩溃留下的锁 30 秒后自动清理。

  • 锁依赖本地文件系统,不要把数据目录放在网盘同步目录或网络共享上同时用。

  • 记忆是明文保存的。不要让 Claude 把密码、API Key 之类存进去。

  • 搜索是简单的关键词匹配,不是语义搜索。

  • 没有任何认证:能读到这个目录的人,就能读到全部记忆。

开发

npm test      # 无依赖,使用 Node 自带的 node:test

从旧版升级

旧版配置里用 MEMORY_FILE=<目录>/memories.jsonl 的写法依然可用,已有的 memories.jsonl 和 messages.jsonl 不需要迁移。


Related MCP server: Claude Dialogue MCP

English

What it is

When you run several Claude windows or accounts at once (multiple desktop instances, or Desktop plus Claude Code), they cannot see each other's conversations. This MCP server gives them a shared notebook and a mailbox:

  • Shared memory – save preferences, projects and decisions; every window can search them.

  • Handoff mailbox – leave messages for another window (pull-based: the recipient sees them when it calls msg_read), filed by topic such as handoff / version / task, browsable later even after they were read.

  • Data is two plain JSONL files on your machine. No network, no upload. You can open, back up or delete them.

Install

Requires Node.js 18+.

git clone <this repo>
cd shared-memory-mcp
node bin/install.js           # edits Claude Desktop config(s), backing them up first

Fully quit and reopen Claude Desktop afterwards. Options: --dir, --config (repeatable, one per Desktop profile), --lang zh, --dry-run, --undo (removes only this server's entry).

Claude Code:

claude mcp add shared-memory -e SHARED_MEMORY_DIR="$HOME/.shared-memory-mcp" -- node /path/to/shared-memory-mcp/src/server.js

Windows that should share memory simply point SHARED_MEMORY_DIR at the same folder.

Tools

memory_save, memory_search (any/all keywords, tag filter, limit), memory_delete, msg_send, msg_read, msg_board.

Getting the model to use it

Models do not call tools on their own initiative. Add a line to your Claude preferences such as: "At the start of every conversation call memory_search, then msg_read. Save anything I ask you to remember with memory_save. My window name is ."

Concurrency and limits

  • Every write takes a directory lock, so several processes can share the files safely (covered by multi-process stress tests). Stale locks from crashed processes are cleaned up after 30 s.

  • The lock relies on a local filesystem: do not put the data directory on a synced cloud folder or network share that several machines use at the same time.

  • Memories are stored in plain text. Do not ask Claude to store passwords or API keys.

  • Search is plain keyword matching, not semantic search.

  • There is no authentication: anyone who can read the directory can read every memory.

Development

npm test      # zero dependencies, uses Node's built-in test runner

Upgrading from the first version

Old configs using MEMORY_FILE=<dir>/memories.jsonl keep working, and existing memories.jsonl / messages.jsonl files need no migration.

License

MIT. Copyright holder in LICENSE is a placeholder; fill in your name before publishing.

Available Tools

6 tools
memory_deleteA

Delete one memory by id. Only when the user asks to forget something.

Inputs: id (required).

memory_saveA

Save one important fact about the user (preferences, projects, decisions) to the shared memory that all connected Claude windows can read. Use when the user says "remember this" or states something worth keeping. Write it clearly and specifically.

Inputs: content (required), tags.

msg_boardA

Browse every message of a category regardless of recipient or read state (does not mark anything read). Use topic "list" to see categories and counts.

Inputs: topic (required), limit.

msg_readA

Read messages addressed to you (and broadcasts). By default only unread ones, which are then marked read; all_history=true lists the whole exchange. Call before starting work and after finishing a chunk.

Inputs: me (required), topic, all_history.

msg_sendA

Leave a message for another Claude window (shared mailbox). The recipient sees it only when it calls msg_read; nothing is pushed. "to" is the recipient's name, or "all" for everyone.

Inputs: to (required), from (required), text (required), topic.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4/5.0

    Scored across 6 tools

    Disambiguation4/5

    The three memory_* tools are clearly distinct (save/search/delete on different operations). msg_read and msg_board both read messages and could be confused, but the descriptions draw a clear line: msg_read is personal unread inbox that marks read, msg_board is a category browser that doesn't mark read.

    Naming Consistency5/5

    Clean verb_noun snake_case throughout, organized into two predictable prefixes (memory_* and msg_*). No stylistic deviations.

    Tool Count5/5

    Six tools cleanly cover two small domains (persistent memory and inter-window messaging) with no filler. Well-scoped for the stated purpose.

    Completeness4/5

    Core lifecycle is covered: save/search/delete for memory and send/read/browse for messages. Minor gaps exist—no memory update/edit and no way to delete or reply to messages—but agents can work around these.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      B
      maintenance
      Enables a shared persistent knowledge vault for Claude Desktop, allowing notes to be saved, retrieved, searched, updated, and deleted across Chat and Code tabs.
      5
      63 npm
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI sessions like Claude, Cowork, and Claude Code to pass tasks and replies between each other through per-session mailboxes, and to keep a shared knowledge base of notes that every session can read, search, and update. Runs as a self-hosted Cloudflare Worker with D1 storage, so all data stays in the user's own account.
      48 npm
      MIT