Give every local AI agent its own mailbox — one MCP server, register once, message any agent on this machine.
pip install agent-mailbox==0.7.2 Copy PIP instructions
Mailbox + Wake system for agent teams — agents that wake up, route, and collaborate. One stdio MCP server. One JSON file per message. Plus a built-in task board: cards wake their assignee when they move, and a zero-dependency web kanban for the human.
📊 Production-proven: 1,676 messages across 5 agents (Claude Code, Hermes, Codex-based, webhook wake) in 18 days of daily multi-agent software development — ~93 messages/day, zero data loss.
Other docs: 中文 · Español · Português · Français · Русский
The gap agent-mailbox fills: agents on different CLIs, on the same machine, messaging each other asynchronously — with delivery guarantees and a human-visible board — without a single dependency.
🆕 v0.7.x — the wake-up upgrade: sampling wake — the server pings the recipient's host over its own MCP connection (sampling/createMessage) the moment a letter lands, with per-agent wake-policy injection (identity template, forbidden hard constraints, per-agent execution lock — one clone in flight at a time) — plus the local-command wake adapter for CLI-only agents (codex et al., argv-only + env-injected + killpg timeout) and a wake run --adapter override for shared wake.json / per-agent plists. Sampling is an accelerator, never a delivery guarantee: MCP deprecated it on 2026-07-28 (SEP-2577), so v0.7.2 adds a per-agent kill switch ("sampling": {"enabled": false} in wake.json) while the fallback chain (wake-daemon / webhook / next check) keeps the mail-arrival iron law. 13 MCP tools. Previous: Wake daemon
Run several AI agents on one machine — Claude Code, Hermes, your own scripts — and they have no way to leave each other messages. Agents overlap, wait on each other, or you end up copy-pasting between their windows like a human switchboard.
A mailbox is a directory of plain JSON files:
~/.agent-mail/ registry.json agent_id → {owner, description, created_at} inbox/HS/20260905-….json one file per message archive/HS/… tasks.json the task board ({"next A mailbox is a directory of plain JSON files: ~/.agent-mail/ registry.json agent_id → {owner, description, created_at} inbox/HS/20260905-….json one file per message archive/HS/… tasks.json the task board ({"next_id", "tasks": {id: card}})
Agents read and write it through a small stdio MCP server. No broker process, no ports, no database, no network by default. Any number of MCP host processes share one mail root safely (file-lock guarded).  ## Quick start **Prerequisites** — one-time: install [uv](https://docs.astral.sh/uv/) (`curl -LsSf https://astral.sh/uv/install.sh | sh` on macOS/Linux, or `powershell -c "irm https://astral.sh/uv/install.ps1 | iex"` on Windows). `uvx` runs everything else; nothing else to install. ### 1 · Register the server with your MCP host Claude Code: ```bash claude mcp add agent-mailbox -- uvx --from git+https://github.com/polaris-smart/agent-mailbox agent-mailbox Any MCP host (generic JSON):
{ "mcpServers": { "agent-mailbox": { "command": "uvx", "args": ["--from", "git+https://github.com/polaris-smart/agent-mailbox", "agent-mailbox"] } } } Tip: set AGENT_MAIL_ID=HS (or whichever id) in the agent's environment and every tool becomes self-addressed — no need to pass agent_id on each call.
{ "tool": "mailbox_register", "arguments": { "agent_id": "HS", "owner": "Hermes", "description": "PM & QA" } } Registration is idempotent. Every registered agent is immediately addressable by everyone — including a human boss id you can read yourself.
{ "tool": "mailbox_send", "arguments": { "to": "HS", "subject": "deploy ready", "body": "v0.1.0 is staged, please verify." } } { "tool": "mailbox_check", "arguments": {} } { "tool": "mailbox_reply", "arguments": { "msg_id": "20260905-…-hs", "body": "verified, marked done." } } mailbox_check fetches pending messages and marks them acked. Lifecycle: pending → acked → done, then optionally archived. A message is one JSON file you can cat — the boss reads the inbox directly.
mailbox_wait blocks (long-poll) until a message arrives — call it as the last action of a turn:
{ "tool": "mailbox_wait", "arguments": { "timeout_seconds": 25 } } Task board Task cards live in /tasks.json (plain JSON, same file lock as the mail). The state machine is strict: todo→doing→review→done, non-adjacent moves rejected unless force=True; done is terminal. Creating or moving a card sends the assignee a normal mailbox message ([task#t-12 → review] …) — so board motion wakes the owning agent through the existing inbox, no polling, no webhooks. Self-assigned moves stay silent, and notify=False opts out.
Web board (for the human). agent-mailbox --web 8643 serves a zero-dependency kanban (stdlib http.server + one embedded HTML page, no framework) on 127.0.0.1. Four lanes mirror the state machine; drag a card between adjacent lanes to move it, or create cards from the form; one toggle switches light/dark themes. Auth is a bearer token — set AGENT_MAIL_WEB_TOKEN for a stable one, or a fresh token is printed at boot (open http://127.0.0.1:8643/?token=…). The board acts as agent boss: every card you create or drag still auto-messages the assignee, so even human drag-and-drop wakes the right agent. The page auto-refreshes every 5 seconds.
If you are an AI agent reading this because your user said "install agent-mailbox": do exactly this, no questions needed.
Read English even if your user speaks another language — the commands are identical everywhere.
Anything that speaks MCP stdio can host a mailbox — which is all of them. Register per your CLI's config:
Then set AGENT_MAIL_ID for that CLI's sessions and mailbox_register once. Agents on the same machine can now message each other across different CLIs — a Claude Code agent and a Gemini CLI agent share the same mail root with zero extra setup.
If the receiving agent isn't even running, mailbox_send itself can POST every new message to a webhook the moment it lands — no daemon, no polling, no extra process:
// ~/.agent-mail/webhook.json (chmod 600) { "url": "http://localhost:8644/webhooks/agent-mailbox", "secret": "…" } Generate the secret yourself once: openssl rand -hex 32. Omit it for unsigned posts (fine for local testing; your receiver decides whether to require it).
{ "event": "agent_mailbox_new_message", "event_type": "agent_mailbox_new_message", "message": { "id": "…", "from": "ZC", "to": "HS", "subject": "…", "body": "…" } } …wakes the agent, and the agent calls mailbox_check on arrival. That is the whole integration.
The webhook above needs a gateway that is already listening. The wake daemon closes the other half: the recipient side, where an agent's harness must actually be pulled into a session when mail lands. One command installs it:
agent-mailbox wake install --agent ZC # uses webhook.json for the POST target agent-mailbox wake install --agent ALICE --adapter claude-code # bell + desktop toast agent-mailbox wake install --agent BOB --adapter generic-webhook --webhook-url https://… --webhook-secret … agent-mailbox wake status / uninstall ZC How it fires: launchd WatchPaths (macOS) / systemd PathChanged= path units (Linux) watch ~/.agent-mail/inbox/ /; every change launches one drain round (python -m agent_mailbox.wake run --once). Adapters: hermes (POST the gateway webhook; signature style auto-adapts github/generic/slack), generic-webhook (your URL + secret), claude-code (terminal bell + desktop notification; richer hooks reserved). Unknown values fall back to hermes — waking beats silence. Reliability trio (2026-09-22 incident review, productized): a failed POST retries 5× at 60s inside one round, then leaves the letter unmarked so the next file-watcher trigger re-drains it — mail is never dropped by the wake side; a wake entry in the letter's handled_log makes every letter wake at most once (idempotent); count semantics v2 wakes on all pending plus acked letters older than 600s (a handler died mid-turn) while freshly-acked mail stays quiet. Fail-open iron law: the daemon is a separate process that only reads letter files and appends through the store's locked APIs. If wake dies, mail still lands and the next mailbox_check still delivers — nothing in the send path depends on it. Jev router (optional, default OFF): set "jev": {"enabled": true, "api_key": …, "endpoint": …} in /wake.json (or wake install --jev --jev-api-key …). Mail is scored asynchronously (Noul: does anyone need to act now? Score: urgency 0–10, below the threshold gets batched for a daily digest) without blocking the wake path; any Jev timeout/error falls back to "wake on any mail" immediately. Decisions are logged with their scores to /wake-jev.log; the api_key never appears in logs. Pure stdlib — pip install agent-mailbox[jev] works today and reserves the extra for a native client later. ⚠️ macOS install writes ~/Library/LaunchAgents/com.polaris-smart.agent-mailbox-wake- .plist and runs launchctl load; Linux writes user units under ~/.config/systemd/user and enables the path unit. Use --no-activate to generate files without loading them.
Every letter now carries a thread_id: fresh sends mint one, replies inherit the original's, and mailbox_thread(thread) replays the whole conversation oldest-first across every agent (inbox + archive). mailbox_list accepts a thread filter. Legacy letters are grouped heuristically by normalized subject (stacked Re:/Fwd: stripped) — a 12-deep "Re: Re: …" chain resolves to one thread; unmatchable singles stay null so gaps stay visible. When a thread accumulates more than 5 open (non-done) letters, mailbox_check returns a ghost_warning — the acked-sinking failure mode, surfaced before it eats a thread.
A notification whose sender equals its target (self-echo, from == to) is not delivered by default: the letter still lands on disk, mailbox_list / mailbox_check are unaffected — the sender just isn't woken by its own send. The drop is audited in sent.log as echo_suppressed: true, so "there was a notification but no mail"-style disputes stay one grep away. Set notify_self_echo: true in the mail root's config.json (or env AGENT_MAIL_NOTIFY_SELF_ECHO) to restore delivery — restored self-echo notifications carry an [echo] subject prefix (the stored letter keeps its original subject, so the prefix is regex-strippable).
Every letter stores a semantic_hash — sha256(norm(subject) + "\0" + norm(prose) + "\0" + code_regions.join("\0")). Prose is NFKC/NFC normalized with whitespace folded; fenced ``` code regions are lifted out first and hashed raw, in their original order (zero folding — reordering code must not collapse to one hash). Legacy letters without the field never match (old mail is never back-filled).
mailbox_send / mailbox_broadcast dedupe by default: if the target inbox already holds a same-hash letter in a non-terminal state (pending/acked) inside the dedup window, no new mail is created. How callers notice: that recipient's entry in the result carries "deduped": true and "existing_id" — nothing lands on disk, nothing is appended to sent.log, and no webhook fires (zero side effects). "count" counts only letters that actually landed. Pass dedupe: false to exempt a send; replies (mailbox_reply) are exempt by design. Only inboxes are consulted, never archives — a same-hash letter that is done or archived never blocks a re-send.
An agent that claims mail (check → acked) and dies leaves it invisible to a pending-only drain. v0.5 closes the loop three ways:
Identity: pass agent_id explicitly, or set AGENT_MAIL_ID once per agent.
A companion watcher prints every new message as a JSON line and fires desktop notifications (macOS / Linux / Windows). It is never on the agent wake-up path — agents don't need it:
uvx --from git+https://github.com/polaris-smart/agent-mailbox agent-mailbox-watch --notify boss Run it as a service on your platform:
python -m agent_mailbox.cleanup --dry-run # list only (the default behaviour) python -m agent_mailbox.cleanup --dry-run --root ~/.agent-mail python -m agent_mailbox.cleanup --yes # actually delete: explicit --yes + interactive confirmation Scans the mail root and lists suspected test residue: agent inbox/ / archive/ directories missing from registry.json, NEWBIE / WBTEST-style test-named directories, and orphan letters (stray files directly under inbox/ / archive/, unparseable JSON, *.tmp left by an interrupted atomic write). Each finding prints path + size + reason; --dry-run (and the flagless default) deletes nothing; --yes deletes for real but requires typing yes to confirm. Registered-but-test-named directories are reported as review-only and never deleted. The --yes capability shipped with v0.4.0 — actually running it against a production mail root remains an explicit operator (boss) approval, separate from the release.
git clone https://github.com/polaris-smart/agent-mailbox && cd agent-mailbox uv venv && uv pip install -e ".[dev]" pytest Upgrading Upgrade with uv tool upgrade agent-mailbox (or re-pull however you installed it).
⚠️ Restart your agent session (or reconnect the MCP client) after upgrading — MCP tool lists are enumerated at session start, so new tools (13 now, was 9) only appear after a restart. No config changes needed; tasks.json is created automatically on first use.
agent local-first mailbox mcp message multi-agent
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.




