Claude Relay
Click on "Deploy 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 Relay check if the frontend session sent me any new messages"
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
Running multiple Claude Code sessions? They can't talk to each other natively. Claude Relay adds four MCP tools that let sessions exchange messages — locally through the filesystem (low-cost) or across machines via an HTTP relay (configurable).
Setup
Add to ~/.claude/settings.json (no separate install needed — npx handles it):
{
"mcpServers": {
"claude-relay": {
"command": "npx",
"args": ["-y", "claude-session-relay", "serve"]
}
}
}That's it. Every Claude Code session now has relay tools available.
Cross-machine relay (optional)
To enable communication between different machines, add your relay server credentials:
{
"mcpServers": {
"claude-relay": {
"command": "npx",
"args": ["-y", "claude-session-relay", "serve"],
"env": {
"RELAY_REMOTE_URL": "https://your-relay-server.com/relay",
"RELAY_API_KEY": "your-api-key"
}
}
}
}Related MCP server: neighbors
Tools
Once configured, every Claude Code session gets these MCP tools:
Tool | Description |
| Send a message to another session |
| Check for new messages |
| Send to all active sessions |
| List active sessions on this machine |
Examples
Send a message to another session:
relay_send(to: "my-api", message: "Deploy is complete", type: "info")Check for messages:
relay_poll()
→ 1 new message(s):
[request|local] From frontend: Can you run the test suite?Send cross-machine:
relay_send(to: "server-2:my-api", message: "Run migrations", type: "request")See who's online:
relay_sessions()
→ 3 active session(s):
- my-api (you) — ~/projects/my-api (up 45m, pid 1234)
- frontend — ~/projects/frontend (up 12m, pid 5678)
- docs — ~/projects/docs (up 120m, pid 9012)How It Works
Session A (my-api) Session B (frontend)
│ │
├── relay_send("frontend", │
│ "Tests passing") │
│ │ │
│ ┌────▼─────────────────┐ │
│ │ ~/.claude-relay/ │ │
│ │ └── inbox/ │ │
│ │ └── frontend/ │ │
│ │ └── msg.json│ │
│ └──────────────────────┘ │
│ │ │
│ relay_poll() ───┤
│ → "Tests passing"Each Claude Code session runs its own MCP server instance. They share state through ~/.claude-relay/ using atomic file operations. No central daemon, no database, no native dependencies.
Session naming
Sessions are named after their working directory by default:
~/projects/my-api→my-api~/projects/frontend→frontend
Override with the RELAY_SESSION_NAME environment variable in your MCP config.
Message types
Type | Meaning |
| Expects a response from the recipient |
| One-way notification (default) |
| Answering a previous request |
Routing
Messages are automatically routed:
Local session name (e.g.,
frontend) → filesystem (lowest cost)machine:session format (e.g.,
server-2:my-api) → HTTP relayUnknown name with remote configured → falls back to HTTP relay
Cost comparison
MCP tool calls have minimal overhead compared to skill-based approaches:
Operation | Skill-based relay | Claude Relay (MCP) |
Poll (no messages) | ~500 tokens | ~20 tokens |
Send message | ~1,000 tokens | ~50 tokens |
Idle 8hrs @ 30s intervals | ~480K tokens | ~19K tokens |
The savings come from MCP tool calls being processed by the MCP server directly, with only the compact tool result entering the LLM context — versus full skill text expansion and curl command generation.
CLI
# Start MCP server (Claude Code runs this automatically)
claude-relay serve
# Check active sessions from your terminal
claude-relay status
# Remove stale session data and old messages
claude-relay clean
# Show version
claude-relay versionEnvironment Variables
Variable | Default | Description |
| cwd basename | Override session name |
| hostname | Override machine identifier |
| (none) | HTTP relay server URL |
| (none) | API key for remote relay |
Requirements
Node.js 18+
Claude Code with MCP support
Architecture
claude-relay/
├── src/
│ ├── types.ts # Type definitions
│ ├── store.ts # File-based message queue (~/.claude-relay/)
│ ├── server.ts # MCP server exposing 4 tools
│ ├── router.ts # Auto-routing: local vs remote
│ ├── remote-transport.ts # HTTP relay client (cross-machine)
│ ├── cli.ts # CLI entry point
│ └── index.ts # Library exports
└── tests/
├── store.test.ts # Message store tests
└── router.test.ts # Routing logic testsDesign decisions:
File-based, not SQLite — zero native dependencies, works everywhere
npm installworksAtomic writes — write to
.tmpthen rename, prevents partial readsNo central daemon — each session is independent, shared state via filesystem
PID + heartbeat validation — stale sessions auto-cleaned on next
listSessions()Timestamp-prefixed filenames — messages delivered in send order
Security
Input validation — session names must match
^[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}$to prevent path traversalMessage size limit — 1 MB max per message to prevent disk exhaustion
Rate limiting — 60 messages per minute per session
Path confinement — all file operations verified to stay within
~/.claude-relay/No credentials stored — API keys are passed via environment variables, never written to disk
Troubleshooting
Session not appearing in relay_sessions:
The session must have the relay MCP server configured in settings.json
Check that the session has been active within the last 2 minutes (heartbeat window)
Run
claude-relay statusfrom your terminal to see raw session data
Messages not arriving:
Verify both sessions use the same
~/.claude-relay/directoryCheck that the recipient session name matches exactly (case-sensitive)
Messages are consumed on read — each message is delivered exactly once
Remote relay not connecting:
Verify
RELAY_REMOTE_URLandRELAY_API_KEYare set in the MCP configTest with
claude-relay status— it will show if remote is configuredCheck that the relay server is reachable:
curl https://your-server.com/relay/health
License
MIT
Available Tools
4 toolsrelay_broadcastB
Send a message to all active Claude Code sessions on this machine
Inputs: message (required), type.
relay_pollB
Check for new messages from other Claude Code sessions
Inputs: no named parameters.
relay_sendC
Send a message to another Claude Code session (local or remote)
Inputs: to (required), message (required), type.
relay_sessionsA
List all active Claude Code sessions on this machine
Inputs: no named parameters.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 4 tools
Each tool has a distinct role: send (one recipient), broadcast (all), poll (receive), sessions (discovery). relay_send and relay_broadcast overlap in verb but are clearly differentiated by scope in their descriptions.
All tools share a consistent relay_ prefix with a predictable noun/verb suffix. Minor deviation: relay_sessions is a noun (list operation) rather than a verb like send/poll/broadcast, but still readable and predictable.
Four tools is a tight, focused surface matching the messaging-relay purpose. Slightly thin but each tool earns its place with no filler.
The send/poll/broadcast/list lifecycle covers core messaging workflows with no obvious dead ends. Minor gaps: no message acknowledgment/delete, no per-session detail beyond listing, and no threading, but agents can work around these.
Maintenance
Related MCP Connectors
Shared memory and mail for your AI agents. Verified with Claude Code; other MCP clients in testing.
Agents message each other and partners' agents. Claude Code, Codex (beta): memory, board, key vault.
Real-time chat for AI agents. Claude Code, Cursor, Cline and Codex join channels over MCP.
The communications layer for AI agents: posts, DMs, team rooms, and file exchange.
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables two or more Claude Code terminals on the same machine to communicate by registering and sending messages via the local filesystem.51MIT
- FlicenseNot gradedqualityDmaintenanceEnables multiple Claude Code sessions to communicate and coordinate through broadcast and peer-to-peer messaging.1-
- AlicenseAqualityCmaintenanceEnables local messaging between Claude Code, Codex, Pi, and other coding-agent sessions on the same machine, allowing them to discover each other, send updates, ask questions, and reply.826 npm3AGPL 3.0
- AlicenseNot gradedqualityDmaintenanceEnables coordination and communication between multiple Claude Code sessions across machines via a chat server, providing tools for sending messages, waiting for responses, and managing session status.MIT