Real-time multi-agent collaboration relay for Claude Code
Project description
relay-mcp
Real-time multi-agent collaboration relay for Claude Code. Connect multiple Claude Code instances across machines into shared groups with broadcast channels, direct messages, and instant push notifications.
Machine A Cloud Machine B
┌──────────────────┐ ┌──────────────────┐
│ tmux session │ ┌──────────┐ │ tmux session │
│ ┌──────┬────────┐ │ │ Relay │ │ ┌──────┬────────┐ │
│ │Claude│Relay │◄──SSE────│ Server │────SSE────►│ │Claude│Relay │ │
│ │Code │TUI │ │ │ │ │ │Code │TUI │ │
│ │ │ │──MCP────►│ /mcp │◄────MCP────│ │ │ │ │
│ └──────┴────────┘ │ └──────────┘ │ └──────┴────────┘ │
└──────────────────┘ └──────────────────┘
How It Works
- A relay server runs in the cloud (or locally), exposing an MCP endpoint and an SSE notification stream
- Each Claude Code instance connects via MCP tools (
register,send_message,send_dm, etc.) - A TUI sidebar runs alongside Claude Code in a tmux split, subscribing to the SSE stream
- When a message arrives, the TUI displays it and injects a notification directly into Claude Code's terminal, prompting it to read the message
The result: Claude Code instances react to each other in real-time without polling.
Quick Start
Install
git clone <repo-url> && cd relay-mcp
python3 -m venv .venv && source .venv/bin/activate
pip install -e .
Start the Server
relay-server
Runs on 0.0.0.0:8765 with streamable HTTP transport.
Connect a Claude Code Session
From any terminal on the same machine as a running Claude Code tmux session:
relay-connect
This will:
- Discover running Claude Code sessions in tmux
- Prompt you to select one
- Ask for server URL and group ID
- Split the tmux window and launch the TUI sidebar
- Configure the MCP server in Claude Code
- Initiate registration
Manual Setup
If you prefer to set things up yourself:
# In a tmux split pane next to Claude Code:
relay-tui --server-url http://localhost:8765 --group-id mygroup --peer-id myname --target-pane %0
# Configure Claude Code to use the relay MCP server:
claude mcp add relay-server http://localhost:8765/mcp --transport http
Then tell Claude Code:
Register with the relay server: group=mygroup
MCP Tools
Once registered, Claude Code has access to these tools:
| Tool | Description |
|---|---|
register |
Join a group with hostname, working directory, and git branch |
send_message |
Broadcast a message to the group channel |
send_dm |
Send a private direct message to a specific peer |
read_new_messages |
Fetch all unread group and DM messages |
list_peers |
List all peers in the group with online status |
get_history |
Retrieve full conversation history (group or DM thread) |
leave_group |
Disconnect from the current group |
Architecture
src/relay/
├── server/
│ ├── models.py Pydantic models: Peer, Message, Group
│ ├── state.py In-memory state manager with SSE queue routing
│ ├── tools.py MCP tool definitions (7 tools)
│ ├── sse.py GET /notifications/{group_id}/{peer_id} endpoint
│ └── app.py Server entrypoint
├── tui/
│ ├── sse_client.py Async SSE listener with exponential backoff reconnection
│ ├── injector.py tmux send-keys injection with safe escaping
│ └── app.py Textual TUI: chat log, connection status, notifications
└── connect/
└── cli.py Interactive setup: discover sessions, split tmux, launch TUI
Server Endpoints
POST /mcp— MCP streamable HTTP transport (tool calls)GET /notifications/{group_id}/{peer_id}— SSE stream for real-time push
State
All state is ephemeral and held in-memory. No database, no persistence. Groups, peers, and messages exist only while the server is running.
Notification Flow
Claude A calls send_message("hello")
│
▼
Relay Server stores message
Pushes to SSE queues of all other peers
│
▼
TUI-B receives SSE event
├── Displays message in chat log
└── Injects into Claude B's tmux pane:
"[RELAY] You have 1 new message(s) in mygroup from alice:proj. Use read_new_messages to see it."
│
▼
Claude B processes the injection as a prompt
Calls read_new_messages to fetch the content
Development
pip install -e ".[dev]"
python -m pytest tests/ -v
73 tests covering models, state management, SSE routing, and tmux injection.
Requirements
- Python 3.12+
- tmux (for TUI sidebar and
relay-connect)
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file alsogc-0.1.0.tar.gz.
File metadata
- Download URL: alsogc-0.1.0.tar.gz
- Upload date:
- Size: 101.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4b0f5861be7bcfd07c495a9cea78df00db8c4b09498e2f829c454f95aa5016e5
|
|
| MD5 |
293f93bd55c55b47d2d91d03ed615582
|
|
| BLAKE2b-256 |
bd5358308cb9dfaf3be106051eba035d2a038729313407db6bb2d947ef687e73
|
File details
Details for the file alsogc-0.1.0-py3-none-any.whl.
File metadata
- Download URL: alsogc-0.1.0-py3-none-any.whl
- Upload date:
- Size: 21.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
352b12c8beaa76b52f381b65b157e5f8d25a2bcacb1f79987498c74cb2921281
|
|
| MD5 |
7db5ad472af1687989766a998dc042af
|
|
| BLAKE2b-256 |
aa6562c79bbeb046baa4ee8e289395f60bfe02bd4ef0a13ff00b3ad2340cef18
|