claude-peers-mcp
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chineseclaude-peers-mcp
claude-peers-mcp
Skill by ara.so — Daily 2026 Skills collection.
claude-peers is an MCP server that lets multiple Claude Code instances running on the same machine discover each other and exchange messages in real-time. A local broker daemon (SQLite + HTTP on ) handles peer registration and message routing; each session's MCP server pushes inbound messages directly into the Claude channel so they appear instantly.
localhost:7899由ara.so开发的Skill — 2026每日技能合集。
claude-peers是一个MCP服务器,可让同一台机器上运行的多个Claude Code实例互相发现并实时交换消息。本地代理守护进程(SQLite + HTTP,运行在)处理节点注册和消息路由;每个会话的MCP服务器会将入站消息直接推送到Claude频道,使其即时显示。
localhost:7899Installation
安装
1. Clone and install dependencies
1. 克隆仓库并安装依赖
bash
git clone https://github.com/louislva/claude-peers-mcp.git ~/claude-peers-mcp
cd ~/claude-peers-mcp
bun installbash
git clone https://github.com/louislva/claude-peers-mcp.git ~/claude-peers-mcp
cd ~/claude-peers-mcp
bun install2. Register as a global MCP server
2. 注册为全局MCP服务器
bash
claude mcp add --scope user --transport stdio claude-peers -- bun ~/claude-peers-mcp/server.tsAdjust the path if you cloned elsewhere.
bash
claude mcp add --scope user --transport stdio claude-peers -- bun ~/claude-peers-mcp/server.ts如果克隆到了其他路径,请调整上述路径。
3. Launch Claude Code with the channel enabled
3. 启用频道功能启动Claude Code
bash
claude --dangerously-skip-permissions --dangerously-load-development-channels server:claude-peersAdd a shell alias to avoid typing it every time:
bash
undefinedbash
claude --dangerously-skip-permissions --dangerously-load-development-channels server:claude-peers可以添加Shell别名,避免每次重复输入:
bash
undefined~/.bashrc or ~/.zshrc
~/.bashrc 或 ~/.zshrc
alias claudepeers='claude --dangerously-load-development-channels server:claude-peers'
The broker daemon starts automatically on first use. No manual daemon management needed.alias claudepeers='claude --dangerously-load-development-channels server:claude-peers'
代理守护进程会在首次使用时自动启动,无需手动管理。Requirements
环境要求
- Bun runtime
- Claude Code v2.1.80+
- claude.ai login (channels require it — API key auth does not work)
- Bun 运行时
- Claude Code v2.1.80+
- claude.ai登录(频道功能需要该登录方式,API密钥认证无法使用)
Architecture
架构
┌───────────────────────────┐
│ broker daemon │
│ localhost:7899 + SQLite │
└──────┬───────────────┬────┘
│ │
MCP server A MCP server B
(stdio) (stdio)
│ │
Claude A Claude B- Each Claude Code session spawns its own MCP process over stdio
server.ts - MCP servers register with the broker and poll every second
- Inbound messages are pushed via the protocol for instant delivery
claude/channel - The broker auto-cleans dead peers and is localhost-only
┌───────────────────────────┐
│ broker daemon │
│ localhost:7899 + SQLite │
└──────┬───────────────┬────┘
│ │
MCP server A MCP server B
(stdio) (stdio)
│ │
Claude A Claude B- 每个Claude Code会话都会通过stdio启动自己的MCP进程
server.ts - MCP服务器会向代理注册,并每秒轮询一次
- 入站消息通过协议推送,实现即时送达
claude/channel - 代理会自动清理失效节点,且仅在本地主机运行
MCP Tools Reference
MCP工具参考
| Tool | Description |
|---|---|
| Discover other Claude Code instances; scope: |
| Send a message to a peer by ID — delivered instantly via channel push |
| Set a description of what this instance is working on |
| Manually poll for messages (fallback without channel mode) |
| 工具 | 描述 |
|---|---|
| 发现其他Claude Code实例;范围可选: |
| 通过ID向指定节点发送消息 — 频道推送实现即时送达 |
| 设置当前实例的工作描述 |
| 手动轮询消息(无频道模式时的备选方案) |
Example prompts to Claude
向Claude发送的示例提示
List all peers on this machineSend a message to peer abc123: "what files are you editing right now?"Set your summary to: "refactoring the authentication module"Check for any new messages from peers列出这台机器上的所有节点向节点abc123发送消息:"你现在正在编辑哪些文件?"将你的工作描述设置为:"重构认证模块"检查是否有来自其他节点的新消息CLI Usage
CLI使用方法
Inspect and interact with the broker directly from the terminal:
bash
cd ~/claude-peers-mcp直接从终端检查并与代理交互:
bash
cd ~/claude-peers-mcpShow broker status and all registered peers
查看代理状态和所有已注册节点
bun cli.ts status
bun cli.ts status
List peers in a table
以表格形式列出节点
bun cli.ts peers
bun cli.ts peers
Send a message into a specific Claude session
向特定Claude会话发送消息
bun cli.ts send <peer-id> "your message here"
bun cli.ts send <peer-id> "你的消息内容"
Stop the broker daemon
停止代理守护进程
bun cli.ts kill-broker
undefinedbun cli.ts kill-broker
undefinedConfiguration
配置
Set these environment variables before starting Claude Code:
| Variable | Default | Description |
|---|---|---|
| | Port the broker listens on |
| | Path to the SQLite database |
| — | Enables auto-summary via |
bash
export CLAUDE_PEERS_PORT=7899
export CLAUDE_PEERS_DB=~/.claude-peers.db
export OPENAI_API_KEY=$OPENAI_API_KEY # optional — enables auto-summary启动Claude Code前设置以下环境变量:
| 变量 | 默认值 | 描述 |
|---|---|---|
| | 代理监听的端口 |
| | SQLite数据库的路径 |
| — | 启用启动时通过 |
bash
export CLAUDE_PEERS_PORT=7899
export CLAUDE_PEERS_DB=~/.claude-peers.db
export OPENAI_API_KEY=$OPENAI_API_KEY # 可选 — 启用自动摘要功能Auto-Summary Feature
自动摘要功能
With set, each instance generates a brief summary on startup describing what you're likely working on (based on working directory, git branch, recent files). Other peers see this in output. Without the key, Claude sets its own summary via .
OPENAI_API_KEYlist_peersset_summary设置后,每个实例在启动时会生成一个简短摘要,描述你当前可能正在进行的工作(基于工作目录、Git分支、最近操作的文件)。其他节点可在的输出中看到该摘要。如果未设置密钥,可通过让Claude自行设置摘要。
OPENAI_API_KEYlist_peersset_summaryCommon Patterns
常见使用场景
Cross-project coordination
跨项目协作
Start two sessions in different project directories:
bash
undefined在不同项目目录中启动两个会话:
bash
undefinedTerminal 1 — in ~/projects/backend
终端1 — 位于~/projects/backend
claudepeers
claudepeers
Terminal 2 — in ~/projects/frontend
终端2 — 位于~/projects/frontend
claudepeers
Ask Claude in Terminal 1:List peers scoped to machine, then ask the peer in the frontend project what API endpoints it needs
undefinedclaudepeers
在终端1中询问Claude:列出机器范围内的所有节点,然后询问前端项目中的节点需要哪些API接口
undefinedScope-filtered peer discovery
范围过滤的节点发现
List peers scoped to repoShows only instances running in the same git repository — useful when you have worktrees or split terminals on the same codebase.
列出仓库范围内的节点仅显示在同一Git仓库中运行的实例 — 当你在同一代码库中使用工作树或拆分终端时非常有用。
Scripted message injection via CLI
通过CLI脚本注入消息
bash
undefinedbash
undefinedInject a task into a running Claude session from a shell script
从Shell脚本向运行中的Claude会话注入任务
PEER_ID=$(bun ~/claude-peers-mcp/cli.ts peers | grep 'backend' | awk '{print $1}')
bun ~/claude-peers-mcp/cli.ts send "$PEER_ID" "run the test suite and report failures"
undefinedPEER_ID=$(bun ~/claude-peers-mcp/cli.ts peers | grep 'backend' | awk '{print $1}')
bun ~/claude-peers-mcp/cli.ts send "$PEER_ID" "运行测试套件并报告失败情况"
undefinedPolling fallback (no channel mode)
轮询备选方案(无频道模式)
If you launch without , Claude can still receive messages by calling explicitly:
--dangerously-load-development-channelscheck_messagesCheck for any new peer messages如果启动时未添加参数,Claude仍可通过显式调用来接收消息:
--dangerously-load-development-channelscheck_messages检查是否有新的节点消息Troubleshooting
故障排除
Broker not starting
bash
undefined代理无法启动
bash
undefinedCheck if something is already on port 7899
检查端口7899是否被占用
lsof -i :7899
lsof -i :7899
Kill a stuck broker and restart
终止卡住的代理并重启
bun ~/claude-peers-mcp/cli.ts kill-broker
bun ~/claude-peers-mcp/cli.ts kill-broker
Then relaunch Claude Code
然后重新启动Claude Code
**Peers not appearing in `list_peers`**
- Ensure both sessions were started with `--dangerously-load-development-channels server:claude-peers`
- Confirm both use the same `CLAUDE_PEERS_PORT` (default `7899`)
- Run `bun cli.ts status` to verify the broker sees both registrations
**Messages not arriving instantly**
- Channel push requires claude.ai login; API key auth won't work
- Fall back to `check_messages` tool if channels are unavailable
**Auto-summary not generating**
- Verify `OPENAI_API_KEY` is exported in the shell where Claude Code was launched: `echo $OPENAI_API_KEY`
- The feature uses `gpt-4o-mini`; confirm your key has access
**Database issues**
```bash
**`list_peers`中看不到节点**
- 确保两个会话都使用`--dangerously-load-development-channels server:claude-peers`启动
- 确认两者使用相同的`CLAUDE_PEERS_PORT`(默认7899)
- 运行`bun cli.ts status`验证代理是否已注册两个实例
**消息无法即时送达**
- 频道推送需要claude.ai登录;API密钥认证无效
- 如果频道不可用,可使用`check_messages`工具作为备选
**自动摘要无法生成**
- 验证启动Claude Code的Shell中是否已导出`OPENAI_API_KEY`:`echo $OPENAI_API_KEY`
- 该功能使用`gpt-4o-mini`;请确认你的密钥有权限访问该模型
**数据库问题**
```bashReset the database entirely (all peers/messages lost)
完全重置数据库(所有节点/消息将丢失)
rm ~/.claude-peers.db
bun ~/claude-peers-mcp/cli.ts kill-broker
**MCP server not found after registration**
```bashrm ~/.claude-peers.db
bun ~/claude-peers-mcp/cli.ts kill-broker
**注册后找不到MCP服务器**
```bashVerify registration
验证注册状态
claude mcp list
claude mcp list
Re-register if missing
如果丢失则重新注册
claude mcp add --scope user --transport stdio claude-peers -- bun ~/claude-peers-mcp/server.ts
undefinedclaude mcp add --scope user --transport stdio claude-peers -- bun ~/claude-peers-mcp/server.ts
undefined