๐ก claude-intercom
Real-time messaging between Claude Code instances. When one agent sends a message, the others get it instantly โ no polling, no manual checks.
Built as an MCP server + filesystem watcher that wakes idle agents automatically via asyncRewake.
How it works
Terminal 1 Terminal 2
โโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโ
โ claude (agent sgup) โ โ claude (agent 4jov) โ
โ โ โ โ
โ > send("4jov", โ โโJSONโโโถ โ ๐ฌ sgup: tu touches โ
โ "tu touches โ file โ auth.ts ? โ
โ auth.ts ?") โ โ โ
โ โ โโโJSONโโ โ > reply("Non, โ
โ ๐ฌ 4jov: Non, โ file โ je suis sur โ
โ je suis sur billingโ โ billing") โ
โโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโ
- Each instance gets a unique 4-char code (e.g.
x7k2) on startup - Messages are JSON files in a shared
store/directory - A
fs.watchwatcher detects new files instantly and wakes the receiving agent - Dead agents are auto-cleaned via PID checking
Install
# Clone
git clone https://github.com/sanztheo/claude-intercom.git ~/.claude/mcp-intercom
# Install deps
cd ~/.claude/mcp-intercom && bun install
1. Register the MCP server
Add to ~/.mcp.json:
{
"mcpServers": {
"intercom": {
"type": "stdio",
"command": "bun",
"args": ["~/.claude/mcp-intercom/src/server.ts"]
}
}
}
2. Add the auto-notification hooks
Add to ~/.claude/settings.json under "hooks":
{
"hooks": {
"PreToolUse": [
{
"hooks": [
{
"type": "command",
"command": "bun ~/.claude/mcp-intercom/src/hook.ts",
"timeout": 3000
}
]
}
],
"Stop": [
{
"hooks": [
{
"type": "command",
"command": "bun ~/.claude/mcp-intercom/src/watcher.ts",
"asyncRewake": true,
"timeout": 300000
}
]
}
],
"SessionStart": [
{
"hooks": [
{
"type": "command",
"command": "bun ~/.claude/mcp-intercom/src/watcher.ts",
"asyncRewake": true,
"timeout": 300000
}
]
}
]
}
}
3. (Optional) Add the skill
Copy skill/SKILL.md to ~/.claude/skills/intercom/SKILL.md so agents proactively coordinate.
MCP Tools
| Tool | Description |
|---|---|
who |
List active agents (filtered by project by default) |
send |
Send a message to an agent or broadcast to "all" |
reply |
Reply to a message (auto-acks the original) |
peek |
Check inbox for unread messages |
ack |
Acknowledge and delete a message |
ack_all |
Clear entire inbox |
Auto-notification
Three layers ensure agents never miss a message:
| Layer | When | How |
|---|---|---|
Watcher (SessionStart + Stop) |
Agent is idle | fs.watch on inbox dir โ exit(2) โ asyncRewake wakes the model |
Hook (PreToolUse) |
Agent is working | Checks inbox before every tool call |
| Skill (always active) | Agent makes decisions | Guides agent to announce work and check messages |
Architecture
~/.claude/mcp-intercom/
โโโ src/
โ โโโ server.ts # MCP server โ 6 tools, auto-generated agent codes
โ โโโ store.ts # Filesystem store โ presence, messages, sessions
โ โโโ hook.ts # PreToolUse hook โ checks inbox on every tool call
โ โโโ watcher.ts # fs.watch โ instant detection, asyncRewake push
โโโ skill/
โ โโโ SKILL.md # Always-active skill for proactive coordination
โโโ store/ # Runtime data (gitignored)
โโโ presence/ # {code}.json โ agent registration + PID
โโโ messages/ # {code}/*.json โ per-agent inboxes
โโโ sessions/ # {pid}.code โ PID-to-agent-code mapping
Session linking (how the hook finds "its" agent)
The MCP server and hooks both run as children of the same Claude Code process. On startup, the server writes its agent code to sessions/{pid}.code for each PID in its ancestor chain. The hook walks up its own ancestor chain and matches against these files โ the common ancestor (Claude Code) is the link.
Requirements
- Bun runtime
- Claude Code v2.1+
- macOS or Linux
License
MIT