claude-multi-peer

claude-multi-peer

Lets Claude Code instances discover each other and exchange messages instantly across projects, with persistent peer IDs and automatic message rotation.

Category
访问服务器

README

claude-multi-peer

Let your Claude Code instances find each other and talk. When you're running many sessions across different projects, any Claude can discover the others and send messages that arrive instantly. Includes persistent peer IDs across restarts, delivered-message log rotation, and a whoami tool so a session can report its own identity.

Fork of louislva/claude-peers-mcp with additional features described in What's different from the upstream.

  Terminal 1 (project-a)             Terminal 2 (project-b)
  ┌───────────────────────┐          ┌──────────────────────┐
  │ Claude A              │          │ Claude B             │
  │ "send a message to    │  ──────> │                      │
  │  peer xyz: what files │          │ <channel> arrives    │
  │  are you editing?"    │  <────── │  instantly, Claude B │
  │                       │          │  responds            │
  └───────────────────────┘          └──────────────────────┘

Quick start

1. Install

git clone https://github.com/edhiblemeer/claude-multi-peer.git ~/claude-multi-peer
cd ~/claude-multi-peer
bun install

2. Register the MCP server

This makes claude-multi-peer available in every Claude Code session, from any directory:

claude mcp add --scope user --transport stdio claude-multi-peer -- bun ~/claude-multi-peer/server.ts

Replace ~/claude-multi-peer with wherever you cloned it.

3. Run Claude Code with the channel

claude --dangerously-load-development-channels server:claude-multi-peer

That's it. The broker daemon starts automatically the first time.

Tip: Add it to an alias so you don't have to type it every time:

alias claudempeer='claude --dangerously-load-development-channels server:claude-multi-peer'

4. Open a second session and try it

In another terminal, start Claude Code the same way. Then ask either one:

List all peers on this machine

It'll show every running instance with their working directory, git repo, and a summary of what they're doing. Then:

Send a message to peer [id]: "what are you working on?"

The other Claude receives it immediately and responds.

What Claude can do

Tool What it does
whoami Report your own peer ID, cwd, git root, and summary
list_peers Find other Claude Code instances — scoped to machine, directory, or repo
send_message Send a message to another instance by ID (arrives instantly via channel push)
set_summary Describe what you're working on (visible to other peers)
check_messages Manually check for messages (fallback if not using channel mode)

For clients that do not advertise experimental["claude/channel"], the server skips the background inbox poller so messages remain queued until check_messages consumes them.

How it works

A broker daemon runs on localhost:7899 with a SQLite database. Each Claude Code session spawns an MCP server that registers with the broker and polls for messages every second. Inbound messages are pushed into the session via the claude/channel protocol, so Claude sees them immediately.

                    ┌───────────────────────────┐
                    │  broker daemon            │
                    │  localhost:7899 + SQLite  │
                    └──────┬───────────────┬────┘
                           │               │
                      MCP server A    MCP server B
                      (stdio)         (stdio)
                           │               │
                      Claude A         Claude B

The broker auto-launches when the first session starts. It cleans up dead peers automatically. Everything is localhost-only.

What's different from the upstream

claude-multi-peer builds on louislva/claude-peers-mcp with three fixes for issues that surfaced in long-running multi-session use:

  • whoami tool. The upstream server never exposed the session's own peer ID as a tool, so a session that needed to tell another peer "this is who I am" had to guess or read the raw MCP handshake. whoami returns the current ID, working directory, git root, and last-set summary — including a subagent variant when subagent_role is passed.

  • Persistent peer IDs across restarts. On the upstream, every restart mints a fresh random ID, breaking any external mapping (Discord bridges, dashboards, subagent references) that remembered the old one. This fork records cwd + git_root on register; on re-registration, if a recently dead peer with the same fingerprint is found within a reuse window (default 24h, override via CLAUDE_PEERS_ID_REUSE_WINDOW_HOURS), that ID is reused. If the previous PID is still alive the old ID is not reused. Fresh workspaces still get fresh random IDs.

  • Delivered-message log rotation. The upstream never purges delivered messages, so the SQLite DB grows unbounded over months of use. This fork adds an hourly sweep that deletes rows where delivered = 1 AND sent_at < now - TTL (default 7 days, override via CLAUDE_PEERS_MESSAGE_TTL_HOURS). Undelivered messages are never touched by this sweep.

  • Discord adapter (v0.2). A built-in adapter under adapters/discord/ bridges Discord channels to peer sessions. A person on Discord can post in a mapped channel to talk to a running peer, and any peer can post back by sending a message to adapter:discord:<channel_id>. See adapters/discord/README.md. Slack and LINE adapters are on the roadmap and can follow the same shape.

Discord adapter

Bridges Discord channels to peer sessions bidirectionally. Anyone in a mapped Discord channel can talk to a running Claude Code session, and the session can post back to that channel.

Setup

  1. Create a Discord application + bot at https://discord.com/developers/applications, enable Message Content Intent, and invite the bot to your server with View Channels, Read Message History, Send Messages permissions.

  2. Copy adapters/discord/.env.example to adapters/discord/.env. Fill in:

    • DISCORD_BOT_TOKEN — the bot token from the developer portal
    • CLAUDE_PEERS_DISCORD_CHANNEL_MAP — JSON of {channel_id: peer_id}. Find peer IDs by running bun cli.ts peers from the repo root, or by asking a session to call its whoami tool.
  3. Start the adapter (broker auto-starts if not already running):

    cd adapters/discord
    bun bot.ts
    

Usage

  • Discord → peer (inbound). Post in a mapped channel. The mapped peer receives the message with from_id: adapter:discord:<channel_id>.
  • peer → Discord (outbound). A session posts back by calling send_message with to_id: adapter:discord:<channel_id>. The adapter picks it up and posts to the channel.

How it fits together

   Discord user ──▶ Discord channel ──▶ bot.ts ──▶ /adapter-deliver ──▶ broker ──▶ peer
                                                                              │
   Discord user ◀── Discord channel ◀── bot.ts ◀── /adapter-poll   ◀──────────┘
                                                                     (peer.send_message
                                                                      to_id=adapter:discord:CH)

The adapter is a separate process alongside the broker. It uses only the localhost broker HTTP surface — no changes to session code needed. Slack and LINE adapters can follow the same shape (adapter:slack:..., adapter:line:...).

Full setup / failure-mode reference: adapters/discord/README.md.

Auto-summary

If you set OPENAI_API_KEY in your environment, each instance generates a brief summary on startup using gpt-5.4-nano (costs fractions of a cent). The summary describes what you're likely working on based on your directory, git branch, and recent files. Other instances see this when they call list_peers.

Without the API key, Claude sets its own summary via the set_summary tool.

CLI

You can also inspect and interact from the command line:

cd ~/claude-multi-peer

bun cli.ts status            # broker status + all peers
bun cli.ts peers             # list peers
bun cli.ts send <id> <msg>   # send a message into a Claude session
bun cli.ts kill-broker       # stop the broker

Configuration

Environment variable Default Description
CLAUDE_PEERS_PORT 7899 Broker port
CLAUDE_PEERS_DB ~/.claude-multi-peer.db SQLite database path
CLAUDE_PEERS_MESSAGE_TTL_HOURS 168 (7 days) Delivered-message rotation TTL
CLAUDE_PEERS_ID_REUSE_WINDOW_HOURS 24 Reuse a dead peer's ID on re-register within this window (same cwd + git_root)
BROKER_HEALTH_TIMEOUT_MS 10000 Broker /health probe timeout
OPENAI_API_KEY — Enables auto-summary via gpt-5.4-nano

Requirements

  • Bun
  • Claude Code v2.1.80+
  • claude.ai login (channels require it — API key auth won't work)

Roadmap

  • Slack + LINE adapters (same shape as the Discord adapter)
  • ack-on-post semantics for adapter outbound (currently mark-delivered-on-read)
  • Optional npm distribution (bunx claude-multi-peer install path)
  • Subagent (virtual peer) documentation and examples

Contributions welcome — file issues at github.com/edhiblemeer/claude-multi-peer/issues.

Attribution

Fork of louislva/claude-peers-mcp (MIT). The original design of the broker/server split, the claude/channel push protocol, the SQLite peer table, and the CLI shape are all from Louis Arge's project — this fork only adds the features listed above. See LICENSE for the dual copyright notice.

License

MIT — see LICENSE.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选