Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Claude Relaysend to DESKTOP: I found the bug in auth.js line 42"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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
Components
Component | Description |
| WebSocket relay server (runs via launchd) |
| MCP server spawned by Claude Code instances |
| Session identity registry for human-readable IDs |
Installation
Quick Start
1. Start the Relay Server (on one machine)
2. Configure Claude Code (on each machine)
Add to your Claude Code MCP configuration (~/.claude.json):
3. Connect Remote Machines via SSH Tunnel
If machines aren't on the same network, use SSH port forwarding:
Session Identity System
Assign human-readable IDs to Claude sessions (CC-1, CC-2, CODEX, etc.) for easier coordination.
Setup Shell Aliases
Add to your ~/.zshrc or ~/.bashrc:
Usage
Register a session (in terminal before starting Claude Code):
List all registered sessions:
Session ID Priority
The MCP server determines client ID in this order:
CLAUDE_RELAY_SESSION_ID- Shell alias sets this--client-idcommand line argumentRELAY_CLIENT_IDenvironment variableAuto-generated:
hostname-pid
Session Registry
Sessions are tracked in ~/claude-relay/sessions/registry.json so all AI instances can see each other.
MCP Tools
Once configured, Claude Code will have these tools:
Tool | Description |
| Send a message to peer Claude Code instance(s) |
| Get recent messages from peers |
| List currently connected instances |
| Check connection health |
| List all registered sessions (including offline) |
Example Usage
Send a message:
Check for messages:
See who's online:
View all registered sessions:
macOS Auto-Start (LaunchAgent)
Relay Server (on server host)
Verify it's running:
SSH Tunnel (on remote machines)
Testing
Use the interactive test client:
Configuration
Environment Variables
Variable | Default | Description |
|
| Port for relay server |
| (none) | Human-readable session ID |
|
| Relay server WebSocket URL |
Command Line Arguments
File Structure
Troubleshooting
Connection refused:
Ensure relay server is running:
lsof -i :9999If 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 connectedCheck message history with
relay_receive
Orphaned MCP processes:
The MCP server includes a parent process watchdog
If Claude Code exits unexpectedly, MCP servers self-terminate within 10 seconds
To manually clean up:
pkill -f "claude-relay/mcp-server.js"
Session not showing correct ID:
Ensure you ran
claude-session CC-1BEFORE starting Claude CodeCheck with:
echo $CLAUDE_RELAY_SESSION_IDThe session ID is inherited from the shell environment
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