agent-intercom
# agent-intercom
Let your coding agents talk to each other. agent-intercom is a small MCP
server that lets pi, Claude Code, Codex, and other MCP clients exchange 1:1
async messages on the same machine — like typing into each other's chat.
Messages are stored as plain JSON files under `~/.local/share/agent-intercom/`.
There is no daemon, no database, and no network traffic; everything stays on
your machine.
> This repository is vibe-coded: most of its code and docs are written by AI
> coding agents under human direction.
## Requirements
- Node.js >= 22
- At least one MCP-capable coding agent (pi, Claude Code, Codex, ...)
## Install
One command per tool:
```bash
# pi
pi mcp add agent-intercom -- npx --yes github:ryul99/agent-intercom
# Claude Code
claude mcp add --scope user agent-intercom -- npx --yes github:ryul99/agent-intercom
# Codex
codex mcp add agent-intercom -- npx --yes github:ryul99/agent-intercom
```
Verify with `pi mcp list`, `claude mcp list`, or `codex mcp list`; each should
show `agent-intercom` as connected.
## Use
Once registered, the agent can see the messages other sessions sent it. Try:
> "Send a message to my claude-code session saying the refactor is done and the API shape changed."
In the receiving session:
> "Check my agent-intercom inbox."
The agent calls the `inbox` tool to view unread messages and `mark_read` to
acknowledge them. Useful things to know:
- Address a specific session by **label**, id, or a unique prefix of either, or
by tool name (`pi`, `claude-code`, `codex`) when exactly one such session is
running.
- A session can rename itself with `set_label` — for example "frontend" — and
other sessions can then `send` to `frontend`.
- `unread_count` / `inbox` never consume messages; only `mark_read` marks them
read. Unread messages never expire.
- Your own queued messages are visible in both directions via `history`.
## How sessions find each other
Each agent that starts the MCP server registers a session (tool, label, cwd,
pid). `tool` is auto-detected from the MCP handshake; the label defaults to
`<tool>-<pid>` and can be changed anytime with `set_label`. The receiving side
usually sees messages on its next turn; nothing is pushed into a session that
is not running.
## How agents notice messages
The server publishes usage instructions to every connecting client (via the MCP
`instructions` field), so any MCP client knows when and how to check its inbox.
There is nothing to install per tool.
pi users can install the companion plugin from
[ryul99/ai-tools](https://github.com/ryul99/ai-tools), which registers this
MCP server automatically and injects unread messages into every prompt. Claude
Code and Codex users get the same one-install setup from the same package.
## Notes on trust and storage
- Anyone with local file access can read or spoof messages. This is a
same-machine, same-user trust model; do not pipe secrets through it.
- Message bodies enter the receiving model's context. Treat them as data from
another agent, not as instructions.
- Read messages are deleted after 30 days (`--read-ttl-days 0` keeps them
forever). Unread messages are never auto-deleted.
## Tools
| Tool | Purpose |
|---|---|
| `whoami` | Show this session's registration |
| `who` | List live sessions (pass `all: true` to include ended/stale ones) |
| `set_label` | Rename this session |
| `send` | Send a 1:1 message (`to`, `body`, optional `reply_to`) |
| `inbox` | Peek at unread (or all) messages; does not consume |
| `history` | Both directions of a conversation with a counterpart |
| `mark_read` | Mark messages as read |
| `unread_count` | Count unread messages, optionally by sender |
| `wait` | Block until a new unread arrives (default 30s, max 600s) |
`INTERCOM_HOME` overrides the storage directory; `INTERCOM_LABEL` sets a
session's initial label; `INTERCOM_TOOL` overrides auto-detection.
## Development
```bash
git clone https://github.com/ryul99/agent-intercom.git
cd agent-intercom
npm install
npm test # unit tests
npm run build # bundle to dist/server.mjs
```
Releases are consumed directly from GitHub (`github:ryul99/agent-intercom#v0.1.0`);
tag releases as needed.
## License
MIT
TDQS
Scored across 9 tools
Each tool targets a distinct operation, and descriptions clarify the trickier pairs (whoami = self vs who = all sessions; inbox = list vs unread_count = count vs history = two-way thread). Only minor overlap remains between inbox/unread_count/wait, but the descriptions make the intended selection clear.
The names are readable and thematically coherent, but conventions are mixed: bare verbs (send, wait, whoami, who), nouns (inbox, history), and verb_noun forms (set_label, mark_read) plus a noun_count form (unread_count). It works, but there is no single predictable pattern an agent could rely on when guessing a name.
Nine tools is well within the sweet spot and each one earns its place in a messaging workflow (identity, discovery, addressing, send, receive, read-state, wait). No tool feels redundant or bloated for a local agent-intercom server.
The core lifecycle — discover peers, label yourself, send, read inbox/history, mark read, count, and block for replies — is fully covered. Gaps are minor: no broadcast/multi-recipient send, no way to list sent-only messages, and no message/session cleanup, though none blocks typical workflows.