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_delete

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

ParametersJSON Schema
NameRequiredDescriptionDefault
idYesThe id shown in square brackets in search results
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.

ParametersJSON Schema
NameRequiredDescriptionDefault
tagsNoOptional tags, e.g. project, preference
contentYesWhat to remember

TDQS

A3.6/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description must carry the behavioral burden. It does disclose a meaningful trait — the fact lands in a *shared* memory readable by all connected Claude windows — but omits whether saves append or overwrite, whether there are size/count limits, and how the entry is later identified for deletion.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Three sentences, front-loaded with what/where, then when, then how. Little waste; 'Write it clearly and specifically' is mild instruction fluff but still earns its place as content guidance.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple two-parameter write tool with no output schema and no annotations, the description covers purpose, trigger, granularity and visibility well enough to call it correctly. Only the append-vs-overwrite and post-save identification details are missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so both parameters are already documented in the schema and the baseline applies. The description adds only the granularity hint ('one important fact') and encourages specificity in the content, which is marginal beyond structured data.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb+resource ('Save one important fact ... to the shared memory') and bounds scope with examples (preferences, projects, decisions), plus the cross-window visibility detail. It does not explicitly name or distinguish itself from siblings like memory_search/memory_delete, but the write verb makes the distinction inferable.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives a concrete trigger: 'Use when the user says "remember this" or states something worth keeping.' No exclusions or when-not guidance are offered, and it never routes the agent to memory_search for deduplication, so it stops short of the top band.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

msg_board

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.

ParametersJSON Schema
NameRequiredDescriptionDefault
limitNoMax messages (default 30, newest kept)
topicYesCategory name, or "list"
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.

ParametersJSON Schema
NameRequiredDescriptionDefault
meYesYour own name
topicNoOnly this category
all_historyNoInclude read messages and ones you sent

TDQS

A4.1/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full behavioral burden and does disclose the critical side effect: unread messages are 'marked read' as a result of the call. It omits permissions, concurrency, or rate-limit details, but the mutation disclosure is the most important trait and it is present.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Three tight sentences with zero filler, leading with purpose and side effect before usage timing. Every clause earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a small read tool with no output schema and no annotations, the description covers purpose, default behavior, the state-changing side effect, and call timing. Return format is unspecified but not essential for correct invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so baseline would be 3, but the description adds real meaning: it explains the default read-unread behavior and clarifies that all_history=true 'lists the whole exchange,' which sharpens that parameter beyond the schema's wording. Only the topic parameter is left without added semantics.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource: 'Read messages addressed to you (and broadcasts).' This clearly distinguishes it from write-oriented siblings like msg_send, though it never names msg_board or explains how it differs from that read-like sibling, keeping it short of a 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives concrete timing guidance ('Call before starting work and after finishing a chunk') plus the key default-vs-history mode. It does not name an alternative sibling or an exclusion condition, so it is clear context without full routing.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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.

ParametersJSON Schema
NameRequiredDescriptionDefault
toYesRecipient name, or "all"
fromYesYour own name
textYesThe message: what the other side should do, where the files are
topicNoOptional category, e.g. handoff, version, task, chat. Handoff and version notes can be browsed later with msg_board.

TDQS

A4.1/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations to lean on, the description still discloses the non-obvious behavioral trait that governs this tool: delivery is pull-only, so the recipient will not be notified. It omits return-value behavior, failure modes (e.g. unknown recipient), and whether messages can be edited or recalled.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Three tight sentences with the purpose front-loaded and delivery semantics before addressing details. The final sentence largely repeats the schema's own "to" description, costing a little efficiency.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple messaging tool with no annotations and no output schema, the description covers purpose, delivery model, and addressing adequately. It leaves minor gaps around return value and recipient-existence behavior that an agent might want.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so all four parameters are already documented, including the "to" = name or "all" convention. The description merely restates the "to" semantics and adds no syntax, format, or constraint beyond the schema, so the baseline 3 applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb+resource ('Leave a message for another Claude window (shared mailbox)') and immediately distinguishes itself from the pull-based siblings by noting the recipient only sees it via msg_read. An agent can tell this apart from msg_read/msg_board without opening any schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Clearly frames the asynchronous delivery model ('nothing is pushed') and explains the addressing convention, which tells the agent when this communication channel is appropriate. It stops short of explicit when-not guidance or naming msg_board as the alternative for browsable notes (that hint lives only in the schema).

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

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

  1. 6 tool updatesv0.2.0
    • First observedmemory_delete
    • First observedmemory_save
    • First observedmemory_search
    • First observedmsg_board
    • First observedmsg_read
    • First observedmsg_send

TDQS

Score is being calculated.

Maintenance

ActivityMaintained
ResponsivenessNo 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
    11 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.
    30 npm
    MIT