MCP Agent Mail (Rust)
"It's like Gmail for your coding agents!"
A mail-like coordination layer for AI coding agents, exposed as an MCP server with 45 tools and 25 resources, Git-backed archive, SQLite indexing, an interactive 16-screen TUI, a server-rendered web UI, and an agent-first robot CLI. The Rust rewrite of the original Python project (1,700+ stars).
Supported agents: Claude Code, Codex CLI, Gemini CLI, Oh My Pi (OMP), GitHub Copilot CLI, and any MCP-compatible client.
Watch the 23-minute walkthrough to see seven AI coding agents send over 1,000 messages to each other while implementing a development plan over two days.
bashcurl -fsSL "https://raw.githubusercontent.com/Dicklesworthstone/mcp_agent_mail_rust/main/install.sh?$(date +%s)" | bash
Table of Contents
- TL;DR
- Why This Exists
- What People Are Saying
- Design Philosophy
- Rust vs. Python: Stress Test Results
- Installation
- Quick Start
- Agent Configuration
- Server Modes
- Operator CLI Surface
- The 45 MCP Tools
- TUI Operations Console
- Robot Mode (
am robot) - File Reservations
- Multi-Agent Coordination Workflows
- Web UI
- Deployment Validation
- Configuration
- Architecture
- ATC Learning Implementation Map
- Core Data Model
- How the System Works
- Search Architecture
- Coordination Algorithms and Safety Invariants
- Consistency and Recovery Model
- Comparison vs. Alternatives
- Development
- Performance and Benchmarking
- Mailbox Diagnostics (
am doctor) - Troubleshooting
- Limitations
- FAQ
- Appendix: Protocol Transcript
- Appendix: TUI vs. Web vs. Robot
- Documentation
- About Contributions
- License
TL;DR
The Problem: Modern projects often run multiple coding agents at once (backend, frontend, scripts, infra). Without a shared coordination fabric, agents overwrite each other's edits, miss critical context from parallel workstreams, and require humans to relay messages across tools and teams.
The Solution: Agent Mail gives every coding agent a persistent identity (e.g., GreenCastle), an inbox/outbox, searchable threaded conversations, and advisory file reservations (leases) to signal editing intent. Everything is backed by Git for human-auditable artifacts and SQLite for fast indexing and search.
Why Use Agent Mail?
| Feature | What It Does |
|---|---|
| Advisory File Reservations | Agents declare exclusive or shared leases on file globs before editing, preventing conflicts with a pre-commit guard |
| Asynchronous Messaging | Threaded inbox/outbox with subjects, CC/BCC, acknowledgments, and importance levels |
| Token-Efficient | Messages stored in a per-project archive, not in agent context windows |
| 25 MCP Resources | Read-only inbox, thread, reservation, tooling, identity, and attention views for cheap lookups |
| 45 MCP Tools | Infrastructure, identity, messaging, contacts, reservations, search, macros, product bus, and build slots |
| 16-Screen TUI | Live operator cockpit for messages, threads, agents, search, reservations, metrics, health, analytics, attachments, archive browsing, and ATC |
| Web UI | Server-rendered /mail/ routes for human oversight, unified inbox review, search, attachments, and overseer messaging |
| Robot Mode | 19 agent-optimized CLI subcommands with toon/json output (md for thread and message views) for non-interactive workflows |
| Git-Backed Archive | Every message, reservation, and agent profile stored as files in per-project Git repos |
| Hybrid Search | Search V3 via frankensearch. The lexical tier ships by default; semantic and hybrid routing are controlled by the hybrid feature flag (feature = "hybrid"). |
| Pre-Commit Guard | Git hook that blocks commits touching files reserved by other agents |
| Dual-Mode Interface | MCP server (mcp-agent-mail) and operator CLI (am) share tools but enforce strict surface separation |
Quick Example
bash# Install and start (auto-detects all installed coding agents) am # That's it. Server starts on 127.0.0.1:8765 with the interactive TUI. # Agents coordinate through MCP tools: # ensure_project(human_key="/abs/path") # register_agent(project_key="/abs/path", program="claude-code", model="opus-4.6") # file_reservation_paths(project_key="/abs/path", agent_name="BlueLake", paths=["src/**"], ttl_seconds=3600, exclusive=true) # send_message(project_key="/abs/path", sender_name="BlueLake", to=["GreenCastle"], subject="Starting refactor", body_md="Taking src/**", thread_id="FEAT-123") # fetch_inbox(project_key="/abs/path", agent_name="BlueLake") # Or use the robot CLI for non-interactive agent workflows: am robot status --project /abs/path --agent BlueLake am robot inbox --project /abs/path --agent BlueLake --urgent --format json am robot reservations --project /abs/path --agent BlueLake --conflicts
What Agent Conversations Look Like
Example exchange between two agents coordinating a refactor:
┌──────────────────────────────────────────────────────────────────────────────┐ │ Thread: FEAT-123 - Auth module refactor │ ├──────────────────────────────────────────────────────────────────────────────┤ │ │ │ ┌──────────────────────────────────────────────────────────────────────────┐ │ │ │ GreenCastle -> BlueLake 2026-02-16 10:03 │ │ │ │ Subject: Starting auth refactor │ │ │ ├──────────────────────────────────────────────────────────────────────────┤ │ │ │ I'm reserving src/auth/** for the next hour. Can you focus on the API │ │ │ │ tests in tests/api/** instead? │ │ │ │ [ack_required: true] │ │ │ └──────────────────────────────────────────────────────────────────────────┘ │ │ │ │ ┌──────────────────────────────────────────────────────────────────────────┐ │ │ │ BlueLake -> GreenCastle 2026-02-16 10:04 │ │ │ │ Subject: Re: Starting auth refactor │ │ │ ├──────────────────────────────────────────────────────────────────────────┤ │ │ │ Confirmed. Releasing my reservation on src/auth/** and taking │ │ │ │ tests/api/** exclusively. Will sync when I hit the auth middleware │ │ │ │ boundary. │ │ │ │ [ack: OK] │ │ │ └──────────────────────────────────────────────────────────────────────────┘ │ │ │ │ ┌──────────────────────────────────────────────────────────────────────────┐ │ │ │ BlueLake -> GreenCastle 2026-02-16 10:31 │ │ │ │ Subject: Re: Starting auth refactor │ │ │ ├──────────────────────────────────────────────────────────────────────────┤ │ │ │ Found a broken assertion in tests/api/auth_test.rs:142 -- the expected │ │ │ │ token format changed. Heads up if you're touching the JWT issuer. │ │ │ └──────────────────────────────────────────────────────────────────────────┘ │ │ │ │ ┌──────────────────────────────────────────────────────────────────────────┐ │ │ │ GreenCastle -> BlueLake 2026-02-16 10:33 │ │ │ │ Subject: Re: Starting auth refactor │ │ │ ├──────────────────────────────────────────────────────────────────────────┤ │ │ │ Good catch. I just changed the claims struct. Updated the test fixture │ │ │ │ in my commit. Releasing src/auth/** now -- all yours if you need it. │ │ │ └──────────────────────────────────────────────────────────────────────────┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘
No human relay needed. Agents negotiate file ownership, flag breaking changes in real time, and hand off work through structured, threaded messages stored in Git.
Why This Exists
Modern projects often run multiple coding agents at once (backend, frontend, scripts, infra). Without a shared coordination fabric, agents overwrite each other's edits, miss critical context from parallel workstreams, and require humans to relay messages across tools and teams.
Agent Mail has been available since October 2025 and was designed around real multi-agent coding workloads across providers such as Claude Code, Codex CLI, and Gemini CLI. The adjacent Beads and bv tools make it more useful as a full coordination stack: Beads tracks work, bv helps pick the right next work, and Agent Mail carries the coordination traffic.
The Footguns Agent Mail Avoids
No "broadcast to all" mode. Given the option, many agents will overuse broadcast-style messaging. That is the equivalent of default reply-all in email: lots of irrelevant noise and wasted context.
Carefully refined API ergonomics. Bad MCP documentation and poor agent ergonomics quietly wreck reliability. Agent Mail's 45 tool definitions have gone through repeated real-world iteration so they work predictably without wasting tokens.
No git worktrees. Worktrees can slow development velocity and create reconciliation debt when agents diverge. Agent Mail takes the opposite approach: keep agents in one shared space, surface conflicts quickly, and give them tools to coordinate through them.
Advisory file reservations instead of hard locks. For this problem, advisory reservations fit better than hard locks. Agents can temporarily claim files while they work, reservations expire automatically, and stale claims can be reclaimed. That makes the system robust to crashed or reset agents; hard locks would not.
Semi-persistent identity. An identity that can last for the duration of a discrete task (for the purpose of coordination), but one that can also vanish without a trace and not break things. You don't want ringleader agents whose death takes down the whole system. Agent Mail identities are memorable (e.g., GreenCastle), but ephemeral by design.
Graph-aware task selection. If you have 200-500 tasks, you don't want agents randomly choosing them or wasting context communicating about what to do. There's usually a "right answer" for what each agent should work on, and that right answer comes from the dependency structure of the tasks. That's what bv computes using graph theory, like a compass that tells each agent which direction will unlock the most work overall.
What Agent Mail Gives You
- Prevents conflicts: Explicit file reservations (leases) for files/globs prevent agents from overwriting each other
- Reduces human relay work: Agents send messages directly to each other with threaded conversations, acknowledgments, and priority levels
- Keeps communication off the token budget: Messages stored in per-project Git archive, not consuming agent context windows
- Offers quick reads:
resource://inbox/{Agent}?project=<abs-path>,resource://thread/{id}?project=<abs-path>, and 23 other MCP resources - Provides full audit trails: Every instruction, lease, message, and attachment is in Git for human review
- Scales across repos: Frontend and backend agents in different repos coordinate through the product bus and contact system
Typical Use Cases
- Multiple agents splitting a large refactor across services while staying in sync
- Frontend and backend agent teams coordinating thread-by-thread across repositories
- Protecting critical migrations with exclusive file reservations and pre-commit guards
- Searching and summarizing long technical discussions as threads evolve
- Running agent swarms with Beads task tracking for dependency-aware work selection
Productivity Math
Parallel agent work changes the economics of supervision. One human operator can spend an hour steering several agents while those agents produce many hours of implementation work in parallel. The exact multiplier depends on the task and on how disciplined the workflow is, but the point is straightforward: coordination overhead matters, and Agent Mail is built to keep that overhead low.
What People Are Saying
"Agent Mail and Beads feel like the first 'agent-native' tooling." — @jefftangx
"Agent mail is a truly brain-melting experience the first time. Thanks for building it." — @quastora
"Between Claude Code, Codex CLI, and Gemini; Beads; and Agent Mail — basically already 80% the way to the autonomous corporation. It blows my mind this all works now!" — @curious_vii
"Use it with agent mail == holy grail." — @metapog
"The only correct answer to this is mcp agent mail." — @skillcreatorai
"GPT 5.2 suggesting beads + agent mail for agent co-ordination (of course, I am already using them)." — @jjpcodes
Design Philosophy
Mail metaphor, not chat. Agents send discrete messages with subjects, recipients, and thread IDs. Work coordination is structured communication with clear intent, not a firehose. Imagine if your email system at work defaulted to reply-all every time; that's what chat-based coordination does, and it burns context fast.
SQLite for live state, Git for the durable ledger. The accepted write path mutates SQLite first so inboxes, resources, TUI, web, and robot views see one fresh operational state. The same write then emits human-readable message, profile, and reservation artifacts into the per-project Git archive for audit and recovery.
Advisory, not mandatory. File reservations are advisory leases, not hard locks. The pre-commit guard enforces them at commit time, but agents can override if needed. Acquiring a reservation reports conflicts instead of waiting for another agent to release its lease. Reservations expire on a TTL; they do not prevent deadlocks in the storage or runtime layers.
Resilient to agent death. Agents die all the time: context windows overflow, sessions crash, memory gets wiped. Any agent can vanish without breaking the system. No ringleader agents, no single points of failure. Semi-persistent identities exist for coordination but don't create hard dependencies.
Dual persistence. Human-readable Markdown in Git for auditability; SQLite for live indexing plus Search V3 for fast lexical/semantic retrieval. Both stay in sync through the write pipeline.
Structured concurrency, no Tokio. The entire async stack uses asupersync with Cx-threaded structured concurrency. No orphan tasks, cancel-correct channels, and deterministic testing with virtual time.
Rust vs. Python: Stress Test Results
The Python implementation had three recurring failure modes under real multi-agent workloads: Git lock file contention from concurrent writes, SQLite pool exhaustion under sustained load, and cascading failures when many agents hit the server simultaneously. The Rust rewrite addresses these through batching, bounded pools, and backpressure. The measurements below are retained results from the original stress campaign, not a passing verdict for the current release candidate or a guarantee for every workload.
The 10-Test Gauntlet
| Test | Result | Key Metrics |
|---|---|---|
| 30-agent message pipeline | PASS | 150/150 success, p99=6.8s, 0 errors |
| 10-project concurrent ops | PASS | 150/150 success, 0 errors |
| Commit coalescer batching | PASS | 9.1x batching ratio (100 writes → 11 commits) |
| Stale git lock recovery | PASS | Lock detected, cleaned, writes resumed |
| Mixed reservations + messages | PASS | 80+80 ops, 0 errors |
| WBQ saturation | PASS | 2000/2000 enqueued, 0 errors, 0 fallbacks |
| Pool exhaustion (60 threads, pool=15) | PASS | 600/600 success, 0 timeouts, 24 ops/sec |
| Sustained 30s mixed workload | PASS | 1494 ops, ~49 RPS, p99=2.6s, 0 errors |
| Thundering herd (50 threads, 1 agent) | PASS | All 50 got same ID, 0 errors |
| Inbox reads during message storm | PASS | 150 sends + 300 reads, 0 errors |
Python Problem → Rust Fix
| Python Failure Mode | What the Rust Tests Exercise | Result |
|---|---|---|
| Git lock file contention | Commit coalescer batching (100 concurrent writes → 11 commits, 9.1x reduction), stale lock recovery, multi-project isolation | 0 lock errors |
| SQLite pool exhaustion | 60 threads on pool of 15, sustained 50 RPS for 30s, thundering herd (50 threads → 1 agent) | 0 timeouts, 0 DB errors |
| Overloading with many agents | 30 agents × 5 messages, 10 projects × 5 agents, 2000 WBQ operations, mixed reservation+message workload | 0 errors across all |
What Makes the Difference
- Fewer Git lock acquisitions. The commit coalescer batches rapid-fire writes into fewer git commits (9.1x reduction in the recorded run). Git plumbing commits avoid
index.lockin the normal archive path; other Git operations can still contend. - Pool exhaustion handled gracefully. Even with 4x more threads than pool connections (60 vs 15), all 600 operations succeeded with 0 timeouts. WAL mode + a bounded 20s
busy_timeoutlets writers queue rather than fail (and give up before the 30s client deadline). - Stale lock recovery works. Crashed-process lock files are detected via PID checking and cleaned up automatically, so a dead agent never holds the archive hostage.
- Write-behind queue backpressure is clean. 2000 rapid-fire enqueues from 20 threads — all accepted with 0 fallbacks or errors.
- Read/write concurrency is solid. Concurrent inbox reads and message writes produce 0 errors. WAL mode allows unlimited readers alongside writers.
The stress tests live in crates/mcp-agent-mail-storage/tests/stress_pipeline.rs (Rust unit tests targeting the DB+Git pipeline) and tests/e2e/test_stress_load.sh (HTTP E2E tests hammering a live server through the full network→server→DB→git pipeline).
Installation
One-Liner (recommended)
bashcurl -fsSL "https://raw.githubusercontent.com/Dicklesworthstone/mcp_agent_mail_rust/main/install.sh?$(date +%s)" | bash
Downloads the right binary for your platform, installs to ~/.local/bin, optionally updates your PATH, and auto-configures detected Codex CLI configs for HTTP MCP URL mode. Downloaded release archives are verified before extraction by default. The requested version is normalized to the release tag vX.Y.Z (or vX.Y.Z-prerelease), and the trust model depends on the release generation:
- Releases v0.3.31 and later (the current model): releases are built and published by the maintainer's own release infrastructure rather than GitHub Actions, and every release ships a
SHA256SUMSmanifest plus a detached minisign signature (SHA256SUMS.minisig) made with the maintainer-held release key (id1BBD79B28BF718D0; the public key is pinned inside the installer). The installer verifies the signature over the exact manifest bytes withminisign, then verifies the archive's SHA-256 against the authenticated manifest. A missingminisignexecutable, manifest, signature, or checksum entry aborts the install;cosignis not required or consulted for these releases. This replaced the earlier keyless GitHub-Actions Sigstore requirement, which had become unsatisfiable once releases stopped being built by Actions — the trust anchor is now a key the maintainer controls (the same model as the maintainer's other released tools), and verification remains fail-closed.am self-updateapplies the same model with a built-in minisign verifier (the release public key is embedded in the binary; nominisignexecutable is needed) and refuses unsigned or tampered manifests. See SECURITY.md. - Releases before v0.3.31 (legacy): the installer requires a SHA-256 witness plus a non-empty modern Sigstore bundle that
cosignvalidates against the literal workflow identityhttps://github.com/Dicklesworthstone/mcp_agent_mail_rust/.github/workflows/dist.yml@refs/tags/<requested-tag>and OIDC issuerhttps://token.actions.githubusercontent.com, so a valid archive and bundle from any other tag are rejected. A stablecosignv3.1.3 or newer in the v3 line must be onPATH; older versions are rejected because of GHSA-fx35-mq7g-6g98, and v4 is not accepted until its verifier contract is reviewed. Verification forces the modern bundle parser and ignores caller-suppliedSIGSTORE_ROOT_FILE,SIGSTORE_REKOR_PUBLIC_KEY, andSIGSTORE_CT_LOG_PUBLIC_KEY_FILEoverrides.
In both models, a missing checksum, SHA-256 implementation, signature witness, or required verifier executable—and any malformed or mismatched signature evidence—aborts the install.
Options: --version vX.Y.Z, --dest DIR, --system (installs to /usr/local/bin), --from-source, --verify (run an additional post-install self-test), --no-verify (unsafe explicit escape that skips the checksum and signature checks), --easy-mode (auto-update PATH), --force, --no-service (never install/modify/restart the background service; also implied automatically by a non-default --dest), --uninstall, --yes, --purge. --no-verify allows unauthenticated downloaded binaries to execute during mandatory version probes before installation; malicious archive bytes can therefore run arbitrary code as the installer user. Archive verification applies to downloaded release archives, not source builds. Every downloaded archive must still contain exactly the two expected flat, non-empty regular-file members, and both staged binaries and both installed binaries must report the exact requested version. Those member/version checks are mandatory even with --no-verify; the flag also does not disable the optional broader --verify post-install self-test. A failed archive download never silently changes into a source build. Explicit --from-source checks out the exact requested tag, obtains immutable sibling revisions from that tag's release workflow, builds with cargo --locked, and subjects the staged and installed pair to the same exact-version and byte-preserving transactional replacement gates.
A successful source install prints the path of a mode-private source-receipt retained inside its committed transaction-history directory. The hash-witnessed receipt binds the normalized release tag, the exact Agent Mail/frankensearch/fast_cmaes/beads_rust commits, and both installed binary SHA-256 digests. On current source, the Beads commit records an additional installer checkout; the compiled beads_rust package comes from the registry version and checksum in Cargo.lock. Release tags that predate the immutable dependency-pin record fail closed rather than building mutable sibling branches. Interrupted or rolled-back transactions retain their evidence under an explicitly non-committed history name and are never reported as installed source provenance.
Windows One-Liner (PowerShell)
powershelliwr -useb "https://raw.githubusercontent.com/Dicklesworthstone/mcp_agent_mail_rust/main/install.ps1?$(Get-Random)" | iex
PowerShell enforces the same per-release trust contract before Expand-Archive: for releases v0.3.31 and later it verifies the minisign-signed SHA256SUMS manifest with the same pinned maintainer key (a minisign executable on PATH is required; cosign is not consulted), and for older releases it requires the same stable cosign v3.1.3-or-newer-in-v3 verifier, forces modern-bundle parsing, and isolates verification from the three custom Sigstore trust environment variables named above. The ZIP must contain exactly flat am.exe and mcp-agent-mail.exe, and their staged and post-install version lines must exactly match the requested release. Both executables are replaced under one per-destination installer mutex and rollback domain; backups remain until byte-for-byte installed-digest and version checks pass. Options: -Version vX.Y.Z, -Dest PATH, -Force, -Verify (explicitly request the already-default cryptographic checks), and -NoVerify (the unsafe escape that skips only those checksum and signature checks). Archive-member and exact-version checks still run with -NoVerify, which means unauthenticated downloaded executables run during version probes and may execute arbitrary code as the installer user.
From Source
bashgit clone https://github.com/Dicklesworthstone/mcp_agent_mail_rust cd mcp_agent_mail_rust ./install-local.sh # builds release, installs to ~/.local/bin # DEST=/usr/local/bin ./install-local.sh # custom destination
The script resolves the correct Cargo target directory via cargo metadata, so the
installed binary always matches the freshly-built artifact regardless of
CARGO_TARGET_DIR overrides or workspace settings. Do not manually copy from
target/release/am -- if CARGO_TARGET_DIR is set, that path may be stale.
Requires Rust nightly (see rust-toolchain.toml). On current main, Cargo fetches FrankenSearch at the full git revision recorded in Cargo.toml and Cargo.lock, aligned with FRANKENSEARCH_COMMIT in .github/workflows/dist.yml. A manual build needs no FrankenSearch, fast_cmaes, or Beads sibling checkout. Use cargo build --locked to retain the checked-in dependency graph. Earlier release tags may still require the gated ../frankensearch-rel-0332 and ../fast_cmaes checkouts; install.sh --from-source provisions their recorded revisions. The installer and container recipes retain those additional checkouts for provenance compatibility, while current Cargo builds consume the pinned git source. The mailbox uses FrankenSQLite 0.4.4 through SQLModel 0.5.0 on Asupersync 0.5.0, with an immutable engine revision retaining SQL binding and schema-prefix fixes omitted from the release. FastMCP 0.10.0 remains pinned to an immutable revision preserving protocol negotiation. Registry beads_rust =0.6.0 retains its separate, patched FrankenSQLite 0.3.18 dependency, with default features disabled.
The current engine pin also includes NOCASE consistency, INSERT ... SELECT
UPSERT parameter binding, and Linux retained-descriptor fixes. See
UPGRADE_LOG.md for qualification results and remaining
release gates; these changes are not part of the published v0.3.36 binaries.
Platforms
| Platform | Architecture | Binary |
|---|---|---|
| Linux | x86_64 | mcp-agent-mail-x86_64-unknown-linux-gnu |
| Linux | aarch64 | mcp-agent-mail-aarch64-unknown-linux-gnu |
| macOS | x86_64 | mcp-agent-mail-x86_64-apple-darwin |
| macOS | Apple Silicon | mcp-agent-mail-aarch64-apple-darwin |
| Windows | x86_64 | mcp-agent-mail-x86_64-pc-windows-msvc.zip |
Quick Start
1. Start the server
basham
Auto-detects all installed coding agents (Claude Code, Codex CLI, Gemini CLI, OMP, etc.), refreshes their MCP connections as needed, and starts the HTTP server on 127.0.0.1:8765 with the interactive TUI.
2. Agents register and coordinate
Once the server is running, agents use MCP tools to coordinate:
Terminology note: ensure_project takes a human_key, which must be the absolute repo path. Most follow-on tools take project_key, which can be that same absolute path or the project's computed slug.
# Register identity ensure_project(human_key="/abs/path/to/repo") register_agent(project_key="/abs/path/to/repo", program="claude-code", model="opus-4.6") # Reserve files before editing file_reservation_paths(project_key="/abs/path/to/repo", agent_name="GreenCastle", paths=["src/**"], ttl_seconds=3600, exclusive=true) # Send a message send_message(project_key="/abs/path/to/repo", sender_name="GreenCastle", to=["BlueLake"], subject="Starting auth refactor", body_md="Taking src/auth/**", thread_id="FEAT-123", ack_required=true) # Check inbox fetch_inbox(project_key="/abs/path/to/repo", agent_name="BlueLake") acknowledge_message(project_key="/abs/path/to/repo", agent_name="BlueLake", message_id=123)
3. Use macros for common flows
# Boot a full session (ensure project + register agent + reserve files + fetch inbox) macro_start_session(human_key="/abs/path/to/repo", program="claude-code", model="opus-4.6") # Prepare for a thread (fetch context + recent messages) macro_prepare_thread(project_key="/abs/path/to/repo", thread_id="FEAT-123", program="claude-code", model="opus-4.6") # Reserve, work, release cycle macro_file_reservation_cycle(project_key="/abs/path/to/repo", agent_name="GreenCastle", paths=["src/auth/**"], ttl_seconds=3600, auto_release=true) # Contact handshake between agents in different projects macro_contact_handshake(project_key="/abs/path/to/repo", requester="GreenCastle", target="BlueLake", to_project="/abs/path/to/other/repo", auto_accept=true, welcome_subject="Coordination channel", welcome_body="Use thread FEAT-123 for the cutover")
Agent Configuration
The installer and am command auto-detect installed agents and write their configs in HTTP URL mode. The examples below are the manual fallback.
Claude Code
Add to your project's .mcp.json or ~/.claude/settings.json:
json{ "mcpServers": { "agent-mail": { "command": "mcp-agent-mail", "args": [] } } }
Or for HTTP transport (when the server is already running):
json{ "mcpServers": { "agent-mail": { "type": "url", "url": "http://127.0.0.1:8765/mcp/" } } }
Codex CLI
The curl installer writes this automatically for detected Codex CLI installs. For source installs, manual setup, or custom endpoint overrides, add this to ~/.codex/config.toml:
toml[mcp_servers.mcp_agent_mail] url = "http://127.0.0.1:8765/mcp/" # Add this when HTTP bearer auth is enabled: http_headers = { Authorization = "Bearer <HTTP_BEARER_TOKEN>" }
Gemini CLI
Add to ~/.gemini/settings.json:
json{ "mcpServers": { "agent-mail": { "command": "mcp-agent-mail", "args": [] } } }
For a project-local Gemini setup plus Agent Mail identity registration:
bashscripts/register_gemini.sh /abs/path/to/repo AGENT_NAME=BlueLake AGENT_MODEL=gemini-2.5-pro scripts/register_gemini.sh /abs/path/to/repo
Oh My Pi (OMP)
am setup run --agent omp writes OMP's native project config at .omp/mcp.json
and the active profile's user config. The default profile uses
~/.omp/agent/mcp.json; named profiles selected through OMP_PROFILE (or the
legacy PI_PROFILE) use ~/.omp/profiles/<name>/agent/mcp.json. Profile names
must use OMP's lowercase [a-z0-9][a-z0-9._-]{0,63} syntax; an invalid
explicit profile fails closed instead of redirecting setup to the default.
Setup also honors OMP's PI_CONFIG_DIR and default-profile PI_CODING_AGENT_DIR
overrides, with a stricter path-safety contract: neither may contain ..
components. PI_CONFIG_DIR is rooted beneath the user's home directory;
a relative PI_CODING_AGENT_DIR is resolved against the working directory,
and an absolute path is accepted. For example, use agent instead of
foo/../agent. Invalid overrides cause setup to fail before writing config
files; setup also refuses symlink traversal when accessing those files.
The project config is profile-independent and applies under every named OMP
profile.
am setup run --agent omp --no-user-config leaves active-user bytes untouched,
but setup and status still read the authorities that decide whether the
project entry can run. They check the active canonical mcp.json
disabledServers list against all three accepted Agent Mail aliases
(mcp-agent-mail, mcp_agent_mail, and agent-mail). OMP also discovers the
read-only .mcp.json sibling after mcp.json in both project and active-user
scopes. An exact repeated server name is shadowed by the earlier source, while a
different Agent Mail alias remains a separate MCP key; setup status reports and
fingerprints that conflict without mirror-writing the secondary file. Status
also evaluates
mcp.enableProjectConfig with OMP's persistent settings precedence: the active
profile's config.yml (falling back to config.yaml only when it is absent).
When both main YAML names are absent, an existing legacy settings.json or
agent.db remains a migration authority and setup fails closed until OMP has
migrated it or an operator has inspected it. Project settings providers then
merge in runtime order: .omp/settings.json,
.omp/config.yml, .claude/settings.json, .codex/config.toml,
.gemini/settings.json, project-root opencode.json and opencode.jsonc,
.opencode/opencode.json and .opencode/opencode.jsonc, and
.cursor/settings.json. Ordered ambient PI_CONFIG_FILES overlays apply last.
Foreign-provider parse failures are skipped as OMP skips them. Unsafe or
unreadable paths still fail closed: OMP may follow a symlink or otherwise read
bytes that Agent Mail deliberately refuses to trust, so treating that authority
as absent could produce a false-green verdict. The active-profile YAML, native
.omp/config.yml, and explicit overlays are also strict authorities. An
effective false, an unsupported authority, or a missing explicit overlay is
reported as runtime-relevant drift instead of success. OpenCode {env:...} and
{file:...} substitutions are also reported
unsupported because their external dependencies cannot be proven by a cache of
the config bytes alone. Remediation deliberately omits --no-user-config,
because a project-only write cannot overcome an authority that excludes every
project MCP source.
This check is bound to the persistent files and the PI_CONFIG_FILES value in
the am process environment. A one-shot OMP --config argument or a
programmatic runtime settings override is launch-specific and is outside this
static setup/status boundary; run am setup status under the same ambient
overlay environment used to launch OMP.
To configure it manually:
json{ "mcpServers": { "mcp-agent-mail": { "type": "http", "url": "http://127.0.0.1:8765/mcp/" } } }
When HTTP bearer authentication is enabled, add an Authorization entry under
headers; am setup run does this automatically and adds .omp/mcp.json to
the project .gitignore so the credential is not committed.
Any MCP-Compatible Client
Agent Mail supports both stdio and HTTP transports:
- stdio: Run
mcp-agent-mailas a subprocess (the default for most MCP clients) - HTTP: Connect to
http://127.0.0.1:8765/mcp/when the server is running viaamormcp-agent-mail serve - Examples: Token-free client templates live under
docs/examples/mcp/
Server Modes
MCP Server (default)
bashmcp-agent-mail # stdio transport (for MCP client integration) mcp-agent-mail serve # HTTP server with TUI (default 127.0.0.1:8765) mcp-agent-mail serve --no-tui # Headless server (CI/daemon mode) mcp-agent-mail serve --reuse-running # Reuse existing server on same port
CLI Operator Tool
basham # Start server + TUI (non-interactive: robot status) am serve-http --port 9000 # Different port am serve-http --setup # Explicitly update detected MCP clients before serving am serve-http --host 0.0.0.0 # Bind to all interfaces am serve-http --no-auth # Skip authentication (local dev) am serve-http --path api # Use /api/ transport instead of /mcp/ am --help # Full operator CLI
Server startup preserves existing MCP client configuration by default, including
project and user-level URLs. Use am setup run to configure clients separately,
or am serve-http --setup to update detected clients to that launch's endpoint.
The setup flag can rewrite existing entries; omit it for temporary test servers.
For CLI deployments that require an explicitly supplied sending credential, set
AGENT_MAIL_REQUIRE_EXPLICIT_SENDER_TOKEN=1. am mail send then requires
--sender-token, --sender-token-file, or AGENT_MAIL_SENDER_TOKEN; it refuses
to borrow a token from persisted agent identity state. The same resolver applies
to queued-send replay and contact handshakes (use the environment variable where
the command has no token flag). The default retains automatic token reuse.
This controls CLI token selection; it does not establish MCP session ownership
or isolate hostile processes sharing the same OS account. Server-side verified
send enforcement remains MESSAGING_FAIL_CLOSED_SEND_PROFILE=true.
When an interactive am finds a healthy Agent Mail service already serving the
configured endpoint, it attaches a read-only terminal view to that service's
/mail/ws-state snapshot. It does not stop or restart the service, acquire a
mutation lock, or run service-control commands. --takeover remains the
explicit opt-in for a local replacement.
Dual-Mode Interface
This project keeps MCP server and CLI command surfaces separate:
| Use case | Entry point | Notes |
|---|---|---|
| MCP server (default) | mcp-agent-mail | Default: MCP stdio transport. HTTP: serve. |
| CLI (operator + agent-first) | am | Recommended CLI entry point. |
| CLI via single binary | AM_INTERFACE_MODE=cli mcp-agent-mail | Same CLI surface, one binary. |
Running CLI-only commands via the MCP binary produces a deterministic denial on stderr with exit code 2, and vice versa, preventing accidental mode confusion in automated workflows.
Operator CLI Surface
am is more than a launcher. It is the operator surface for runtime control, diagnostics, migration, exports, benchmarking, and agent-facing non-interactive workflows. In non-interactive contexts, bare am automatically falls back to robot output instead of trying to launch a blocking TUI.
Command Families
| Surface | Subcommands / form | What it is for |
|---|---|---|
| Runtime | serve-http, serve-stdio, `service install | status |
| Quality gates | ci, verify, lint, typecheck, bench | Run the native quality pipeline, build-slot-protected verification lanes, and CLI/perf baselines |
| E2E and determinism | `e2e list | run |
| Share and deploy | `share export | update |
| Archive and recovery | `archive save | list |
| Coordination data | agents ..., mail ..., contacts ..., macros ..., file_reservations ..., acks ..., list-acks | Operate directly on the same concepts the MCP tools expose |
| Project and product routing | projects ..., products ..., list-projects, beads ... | Manage project identity, cross-project product groupings, and task-tracker views |
| Platform and setup | `setup run | status, config set-port |
| Migration and lifecycle | `legacy detect | import |
| Break-glass admin | clear-and-reset-everything | Fully reset local state after optional archival. Use sparingly. |
Setup Drift Reports
am setup status is read-only. It inventories supported MCP clients, reports the
current redacted server entry beside the expected entry, and labels drift such
as missing_file, legacy_stdio, stale_http_path, wrong_bearer_header,
wrong_startup_timeout, duplicate_server_entries, and unsupported_config.
Use the reported remediation in two steps:
basham setup status --format json am setup run --dry-run --project-dir "$PWD" --format toon am setup run --yes --project-dir "$PWD" --format toon
For bearer-header checks, pass --token to am setup status or expose the
expected token through HTTP_BEARER_TOKEN / config.env; status output redacts
token values.
Family Detail
| Family | Current subcommands / modes |
|---|---|
share | export, update, preview, verify, decrypt, wizard, static-export, deploy validate, deploy tooling, deploy verify, deploy verify-live |
archive | save, list, restore |
guard | install, uninstall, status, check |
file_reservations | list, active, soon, reserve, renew, release, conflicts |
acks | pending, remind, overdue |
projects | mark-identity, discovery-init, adopt |
mail | status, send, reply, inbox, read, ack, search, summarize-thread, replay-queued, discard-queued |
products | ensure, link, status, search, inbox, summarize-thread |
doctor (28 verbs) | check, health, triage, locks, drain, fix, undo, ls, explain, fixers, capabilities, robot-docs, artifacts, reclaim, selftest, mcp-selftest, write-selftest, support-bundle, repair, reconstruct, backups, restore, archive-scan, archive-verify, archive-normalize, fix-orphan-refs, pack-archive, vacuum (vacuum is on main and unreleased as of 2026-09-01) |
agents | register, create, list, show, detect, reap, resolve-pane |
tooling | directory, schemas, metrics, metrics-core, diagnostics, locks, decommission-fts |
macros | start-session, prepare-thread, file-reservation-cycle, contact-handshake |
contacts | request, respond, list, policy |
beads | ready, list, show, status |
setup | run, status |
golden | capture, verify, list |
flake-triage | scan, reproduce, detect |
robot | status, inbox, timeline, overview, thread, search, message, navigate, reservations, metrics, health, analytics, agents, contacts, projects, attachments, atc, handoff, tui-dump |
verify | cargo-fmt, cargo-check, cargo-clippy, cargo-test, e2e-list, e2e-stdio, bench-quick, reliability-coverage |
legacy | detect, import, status |
service | install, uninstall, status, logs, restart |
Durable Inbox Event Cursors
am inbox-events is the CLI for restart-safe inbox monitors. It reads
append-only, body-free delivery events oldest first; its --after value is a
delivery cursor, never a message ID. Persist next_cursor only after the
corresponding events have been processed.
bash# Establish a durable starting position without consuming events. am inbox-events --project /abs/path --agent BlueLake --position-now --format json # Resume from the last processed delivery cursor. am inbox-events --project /abs/path --agent BlueLake --after 42 --limit 100 --format json
Each page includes events, next_cursor, has_more,
oldest_available_cursor, and tail_cursor. A cursor below retained history
returns CURSOR_EXPIRED; a cursor beyond the tail returns CURSOR_AHEAD.
The 45 MCP Tools
9 Clusters
| Cluster | Count | Tools |
|---|---|---|
| Infrastructure | 4 | health_check, ensure_project, install_precommit_guard, uninstall_precommit_guard |
| Identity | 9 | register_agent, create_agent_identity, retire_agent, unretire_agent, deregister_agent, whois, resolve_pane_identity, cleanup_pane_identities, list_agents |
| Messaging | 9 | send_message, reply_message, fetch_inbox, fetch_topic, fetch_inbox_events, get_message_delivery_receipt, acknowledge_message, mark_message_read, mark_all_read |
| Contacts | 4 | request_contact, respond_contact, list_contacts, set_contact_policy |
| File Reservations | 5 | check_file_reservation_conflicts, file_reservation_paths, renew_file_reservations, release_file_reservations, force_release_file_reservation |
| Search | 2 | search_messages, summarize_thread |
| Macros | 4 | macro_start_session, macro_prepare_thread, macro_contact_handshake, macro_file_reservation_cycle |
| Product Bus | 5 | ensure_product, products_link, search_messages_product, fetch_inbox_product, summarize_thread_product |
| Build Slots | 3 | acquire_build_slot, renew_build_slot, release_build_slot |
fetch_inbox_events is the MCP equivalent of am inbox-events: it is a
durable, recipient-scoped delivery feed for monitors, not a replacement for
message-body inbox reads.
file_reservation_paths accepts an optional idempotency_key for an exact
retry after a timeout. The same key and normalized request replay the original
grant without a second lease or archive write and mark the response
idempotent_replay: true. Reusing a key with different arguments returns
IDEMPOTENCY_KEY_CONFLICT. Keys are scoped to (project, tool), expire after
the configured retention window, and are optional; this is not a blanket
idempotency claim for every mutating tool.
25 MCP Resources
Read-only resources span environment/config inspection, project and agent discovery, inbox and thread views, reservation views, and tooling diagnostics. They are there so agents can fetch state cheaply without mutating anything.
resource://inbox/{Agent}?project=<abs-path>&limit=20 resource://thread/{id}?project=<abs-path>&include_bodies=true resource://mailbox/{Agent}?project=<abs-path> resource://views/ack-overdue/{Agent}?project=<abs-path> resource://agents/<project-slug> resource://file_reservations/<project-slug>?active_only=true resource://tooling/metrics resource://config/environment
resource://agents/... and resource://file_reservations/... take the project in the path segment. Inbox, mailbox, thread, and message resources put the agent or thread in the path and the project in the query string.
Macros vs. Granular Tools
- Prefer macros when you want speed or are on a smaller model:
macro_start_session,macro_prepare_thread,macro_file_reservation_cycle,macro_contact_handshake - Use granular tools when you need control:
register_agent,file_reservation_paths,send_message,fetch_inbox, `




