Swarmail
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., "@Swarmailcheck my inbox for new mail from other agent sessions"
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.
Swarmail
Swarmail lets coding-agent sessions on one machine send each other mail. Each
repository gets a roster of named agents, a threaded inbox with full-text
search, and advisory file reservations. Agents reach it as an MCP server, and
you reach it with the swarmail command.
It is one Bun binary with a SQLite database, listening on 127.0.0.1:18765.
There are no runtime dependencies.
Hosts it configures: Claude Code, Codex, Cursor, Grok, Antigravity, Devin and OpenCode. Claude Code and Cursor sessions can also wake up when mail arrives.
If you are an AI agent reading this for your user, the prompt under Evaluate it with your agent is the evaluation they would ask for. Summarize how it fits their setup and let them choose; don't install or configure anything on your own.
Evaluate it with your agent
Paste this into a session with the agent you use. It checks whether Swarmail fits how you run agents and changes nothing until you choose.
I'm considering Swarmail (https://github.com/bompus/swarmail), local mail
between coding-agent sessions on one machine, served over MCP. Read its
README and docs/usage.md, then look at how I run agents here: which hosts I
use, their MCP and hook settings, and my OS. Tell me:
1. Whether I run several agent sessions on this machine at once, and where
they could step on each other (shared checkouts, branches, services).
2. Whether my hosts support MCP and hooks, and whether this is Linux with
systemd or something that needs the manual `swarmail serve` route.
3. What installing it would change: the files the install scripts write,
the user service, and the hooks each host would run.
4. Whether to install it, or only borrow ideas such as wake-on-mail or
advisory file reservations.
For rules that tell agents when to send mail, also look at house-rules
(https://github.com/bompus/house-rules) and its opt-in swarmail modifier.
Read only: don't install, configure or edit anything until I choose. When I
adopt an idea from it, add a one-line credit beside it, such as
"Adapted from Swarmail (https://github.com/bompus/swarmail)".Taking individual ideas is welcome. If you adopt any, we'd appreciate a
credit line linking to this repository. Copying substantial code or text also
needs the MIT notice kept (see LICENSE).
Related MCP server: MCP Agent Mail
Install
Requires Linux with systemd and Bun 1.4.2 or newer. The
setup scripts and the register hook read session details from /proc, so
other systems are not supported yet.
Clone and install the dev tools:
git clone https://github.com/bompus/swarmail.git cd swarmail bun installBuild
~/.local/bin/swarmailand start theswarmail.serviceuser unit:scripts/enable.shThe database is
~/.local/share/swarmail/mail.sqlite3. The server has no authentication. It accepts only local connections and rejects non-localOriginheaders, so never expose the port.Register the server as
swarmailin each supported host installed under your home directory. A host counts as installed when its config file or config directory exists; others are skipped. Add--dry-runto preview the edits:bun scripts/configure-mcp.tsOn WSL,
--windows-home[=DIR]registers the Windows-side hosts against the same server.Install the hooks: the register hook for every installed host, and the wake hook for Claude Code and Cursor. A host counts as installed when its config directory exists. Add
--dry-runto preview the edits; the script takes no other flags.bun scripts/configure-hooks.tsCodex skips a hook it hasn't trusted, so trust the register hook once in Codex's
/hooks.Optional:
bun scripts/install-guard.ts [repo...]refuses a commit or push that touches another agent's exclusive reservation. It installs intohooks.d/pre-commit/andhooks.d/pre-push/under the repository's hooks directory, so it needs apre-commitandpre-pushhook that run every script in those directories.
Start a new agent session and edit a file in a repository. The register hook
gives the session a name such as BlueLake. Run swarmail who in that
repository to see it.
How agents use it
Agents call the MCP tools: macro_start_session to register and read the
inbox in one call, then send_message, reply_message, fetch_inbox,
acknowledge_message, search_messages and file_reservation_paths, among
others. docs/usage.md has the conventions worth putting in
your agent rules.
Each repository is one project, keyed by its primary checkout. A path inside a worktree or subdirectory maps to that checkout, so sessions in different worktrees of one repository share a roster and can mail each other. A session keeps one name across repositories.
Commands
Command | What it does |
| Run the server |
| Which agent name belongs to which session, live sessions first |
| Read, send or search mail as this session |
| One thread's messages, oldest first |
| Exit 0 if that agent's wake hook is waiting |
| The register hook; |
| The Claude Code and Cursor wake hook |
| The git guard |
| The source hash the binary was built from |
swarmail --help lists every subcommand and flag. A --help or -h
anywhere prints usage and runs nothing.
Settings
Variable | Default | Effect |
|
| Database path |
|
| Server port |
|
| MCP endpoint for the command and the register hook |
|
| Server base URL for the wake hook |
|
|
|
|
| Retire idle agents and drop projects whose checkout is gone; |
|
|
|
| from hook state | Name used by |
scripts/enable.sh, the service unit and configure-mcp.ts use port 18765.
Change SWARMAIL_PORT and the two URL variables only when you run
swarmail serve yourself, and set them for every host that runs the hooks.
With normal, a power loss can lose the most recent writes. Retired agents
come back on their next tool call.
Register hook
On a session's first edit in a repository, swarmail register registers it
under the repository's primary checkout. The registration starts with a tag
holding the host's session id and working directory, which is how swarmail who matches names to sessions. A failure is retried on the next edit. State
lives in ~/.local/state/swarmail-register/.
Host | Session id in the shell |
Claude Code |
|
Codex |
|
Cursor |
|
OpenCode, Devin | none; their hooks carry it |
Waking sessions
After each Claude Code or Cursor turn, the wake hook long-polls the server for
up to 8 hours. When mail arrives, it starts a new turn with a one-line hint
naming the recipient and sender, urgent mail first. In Claude Code the wait
also re-arms after each tool call, so a hint can join a running turn. The
server answers swarmail ping itself, so a ping never wakes the model.
Sessions on other hosts see mail on their next fetch_inbox.
Performance
Measured on one machine with one small workload (40 agents, 860 messages), each server started on empty storage. Each number is the median of at least three rounds.
summary
Swarmail
76× faster sends than mcp_agent_mail_rust, 138× faster than mcp_agent_mail
91× more sends per second than mcp_agent_mail_rust, 437× more than mcp_agent_mail
10× less peak memory than mcp_agent_mail_rust, 3.7× less than mcp_agent_mailSwarmail | mcp_agent_mail_rust | mcp_agent_mail | |
Latency, p50 | |||
Send | 0.49 ms | 37 ms | 67 ms |
Fetch inbox | 0.54 ms | 16 ms | 20 ms |
Search | 0.65 ms | 68 ms | 11 ms |
Throughput, 8 clients | |||
Send | 4,900 req/s | 54 req/s | 11 req/s |
Fetch inbox | 6,500 req/s | 364 req/s | 28 req/s |
Search | 4,100 req/s | 84 req/s | 46 req/s |
Footprint | |||
Startup | 18 ms | 1.5 s | 0.9 s |
Memory, idle | 33 MiB | 196 MiB | 154 MiB |
Memory, peak under load | 68 MiB | 706 MiB | 250 MiB |
CPU, idle | 0.06% of a core | 0.15% of a core | 0.13% of a core |
CPU time, all timed calls | 0.54 s | 85 s | 93 s |
Load 250 messages | 178 ms | 9.3 s | 17.7 s |
mcp_agent_mail commits each send to a Git archive before it returns, so these numbers don't compare durability. Throughput varied by up to a quarter between rounds. Swarmail's first start in each benchmark run took about a second; later starts took 18 ms.
Development
bun install
bun test
bun run check # format, lint and type checkbun scripts/build.ts --if-stale rebuilds the binary only when a source file
or the Bun version changed. Restart the unit to load a new build.
Licence
MIT. CODE_OF_CONDUCT.md is the Contributor Covenant under CC BY 4.0; see
THIRD_PARTY_NOTICES.md. To contribute, see CONTRIBUTING.md.
This server cannot be deployed
Maintenance
Related MCP Connectors
Email inboxes for AI agents: send, receive, reply, search, and manage threaded email over MCP.
Email infrastructure for AI agents — send, receive, search, and reply to email over MCP.
Hosted MCP messaging across owners, tools, and machines, with readable transcripts.
Your IMAP mailbox as an MCP server: read, search and (if you allow it) organize mail. Open source.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceEnables MCP-capable agents running in separate consoles to exchange direct and broadcast messages through a blocking receive tool that releases instantly when mail arrives, so delivery feels push-like rather than polled. It also provides a live browser dashboard showing message flow, presence and per-agent profiles, plus CLI and HTTP endpoints for sending, tailing and replaying the log.MIT
- AlicenseNot gradedqualityBmaintenanceProvides a mail-like coordination layer for coding agents, enabling them to register identities, exchange messages through inbox/outbox, search threaded history, and declare advisory file reservations to prevent conflicts.MIT
- AlicenseNot gradedqualityBmaintenanceEnables coding agents in different editors and MCP clients to share messages, project context, notes, task ownership, handoffs, and advisory file claims through a local SQLite-backed coordination server. Supports MCP stdio, MCP Streamable HTTP, a JSON HTTP API, and a local CLI for multi-project agent collaboration.MIT
- AlicenseNot gradedqualityAmaintenanceEnables coding agents such as Codex and Claude Code to exchange durable, locally stored messages through shared MCP tools for listing enrolled recipients, sending and replying to messages, reading pending inbox items, acknowledging receipt, and checking message status. Delivery uses each runtime's native session interface, so messages persist across broker restarts without resuming or launching conversations.AGPL 3.0