Claude Relay
Enables real-time communication between Claude Code instances across multiple machines via WebSocket, allowing context sharing, task handoffs, and coordination between sessions.
README
Claude Relay
Real-time communication between Claude Code instances across multiple machines via WebSocket + MCP.
What This Does
Enables Claude Code sessions on different machines to send messages to each other in real-time. Useful for:
- Context sharing - Share findings, file contents, or investigation results between sessions
- Task handoffs - Start a task on one machine, continue on another
- Coordination - Let one Claude Code instance know what another is doing
Architecture
Machine A Machine B (Server Host)
┌─────────────────┐ ┌─────────────────┐
│ Claude Code │ │ Claude Code │
│ ↓ │ │ ↓ │
│ MCP Server │ │ MCP Server │
│ ↓ │ │ ↓ │
│ WebSocket ────┼── SSH Tunnel ─────┼─→ Relay Server │
│ (localhost) │ or direct │ (port 9999) │
└─────────────────┘ └─────────────────┘
Installation
git clone https://github.com/gvorwaller/claude-relay.git
cd claude-relay
npm install
Quick Start
1. Start the Relay Server (on one machine)
node server.js
# [Claude Relay] Ready! Listening on ws://localhost:9999
2. Configure Claude Code (on each machine)
Add to your Claude Code MCP configuration:
{
"mcpServers": {
"claude-relay": {
"command": "node",
"args": ["/path/to/claude-relay/mcp-server.js"],
"env": {
"RELAY_CLIENT_ID": "MACHINE_A",
"RELAY_URL": "ws://localhost:9999"
}
}
}
}
Set a unique RELAY_CLIENT_ID for each machine (e.g., "LAPTOP", "DESKTOP", "M1", "M2").
3. Connect Remote Machines via SSH Tunnel
If machines aren't on the same network, use SSH port forwarding:
# On the remote machine, tunnel to the server host
ssh -N -L 9999:localhost:9999 server-host &
# Or use autossh for auto-reconnecting
autossh -M 0 -N -L 9999:localhost:9999 server-host &
MCP Tools
Once configured, Claude Code will have these tools:
| Tool | Description |
|---|---|
relay_send |
Send a message to peer Claude Code instance(s) |
relay_receive |
Get recent messages from peers |
relay_peers |
List currently connected instances |
relay_status |
Check connection health |
Example Usage
Send a message:
Use relay_send to tell MACHINE_B: "Found the bug - it's in auth.js line 42"
Check for messages:
Use relay_receive to see if there are any messages from peers
See who's online:
Use relay_peers to list connected instances
macOS Auto-Start (LaunchAgent)
Relay Server (on server host)
# Copy the LaunchAgent
cp com.claude-relay.plist ~/Library/LaunchAgents/
# Edit the plist to fix paths for your system:
# - Update /usr/local/bin/node to your node path (use `which node`)
# - Update /Users/yourname/claude-relay to your install path
# Load it
launchctl load ~/Library/LaunchAgents/com.claude-relay.plist
SSH Tunnel (on remote machines)
# Install autossh
brew install autossh
# Copy and edit the tunnel LaunchAgent
cp com.claude-relay-tunnel.plist ~/Library/LaunchAgents/
# Edit to set your server hostname and paths
# Load it
launchctl load ~/Library/LaunchAgents/com.claude-relay-tunnel.plist
Testing
Use the interactive test client:
# Terminal 1: Start server
node server.js
# Terminal 2: Connect as client A
node test-client.js MACHINE_A
# Terminal 3: Connect as client B
node test-client.js MACHINE_B
# In either client:
send Hello from here!
peers
history
Configuration
Environment Variables
| Variable | Default | Description |
|---|---|---|
RELAY_PORT |
9999 |
Port for relay server |
RELAY_CLIENT_ID |
hostname | Identifier for this instance |
RELAY_URL |
ws://localhost:9999 |
Relay server WebSocket URL |
Command Line Arguments
# Server
node server.js [port]
node server.js 8888
# MCP Server
node mcp-server.js --client-id=LAPTOP --relay-url=ws://192.168.1.100:9999
Files
| File | Description |
|---|---|
server.js |
WebSocket relay server |
mcp-server.js |
MCP protocol server for Claude Code |
test-client.js |
Interactive test client |
com.claude-relay.plist |
macOS LaunchAgent for relay server |
com.claude-relay-tunnel.plist |
macOS LaunchAgent for SSH tunnel |
Troubleshooting
Connection refused:
- Ensure relay server is running:
lsof -i :9999 - If using SSH tunnel, verify it's active:
ps aux | grep ssh
MCP tools not appearing:
- Restart Claude Code after adding MCP config
- Check MCP server is connecting: look for "Connected!" in logs
Messages not arriving:
- Use
relay_peersto verify both instances are connected - Check message history with
relay_receive
Security Notes
- The relay server has no authentication by default
- Designed for trusted local networks or SSH tunnels
- All traffic over SSH tunnel is encrypted
- Don't expose port 9999 to the internet without adding authentication
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。