agent-mail
MCP Agent Mail - Mail-like coordination layer for multi-agent workflows. Identities, inbox/outbox, file reservations, contact policies, threaded messaging, pre-commit guard, Human Overseer, static exports, disaster recovery. Git+SQLite backed. Python/FastMCP.
What this skill does
# MCP Agent Mail
A mail-like coordination layer for coding agents exposed as an HTTP-only FastMCP server. Provides memorable identities, inbox/outbox, file reservation leases, contact policies, searchable message history, and Human Overseer messaging. Backed by Git (human-auditable artifacts) and SQLite (fast queries with FTS5).
## Why This Exists
Without coordination, multiple agents:
- Overwrite each other's edits or panic on unexpected diffs
- Miss critical context from parallel workstreams
- Require humans to relay messages between tools
Agent Mail solves this with:
- Memorable identities (adjective+noun names like "GreenCastle")
- Advisory file reservations to signal editing intent
- Threaded messaging with importance levels and acknowledgments
- Pre-commit guard to enforce reservations at commit time
- Human Overseer for direct human-to-agent communication
## Starting the Server
```bash
# Quickest way (alias added during install)
am
# Or manually
cd ~/projects/mcp_agent_mail
./scripts/run_server_with_token.sh
```
Default: `http://127.0.0.1:8765`
Web UI for humans: `http://127.0.0.1:8765/mail`
## Core Concepts
### Projects
Each working directory (absolute path) is a project. Agents in the same directory share a project namespace. Use the same `project_key` for agents that need to coordinate.
### Agent Identity
Agents register with adjective+noun names (GreenCastle, BlueLake). Names are unique per project, memorable, and appear in inboxes, commit logs, and the web UI.
### File Reservations (Leases)
Advisory locks on file paths or globs. Before editing files, reserve them to signal intent. Other agents see the reservation and can choose different work. The optional pre-commit guard blocks commits that conflict with others' exclusive reservations.
### Contact Policies
Per-agent policies control who can message whom:
| Policy | Behavior |
|--------|----------|
| `open` | Accept any message in the project |
| `auto` (default) | Allow if shared context exists (same thread, overlapping reservations, recent contact) |
| `contacts_only` | Require explicit contact approval first |
| `block_all` | Reject all new contacts |
### Messages
GitHub-Flavored Markdown with threading, importance levels (`low`, `normal`, `high`, `urgent`), and optional acknowledgment requirements. Images are auto-converted to WebP.
## Essential Workflow
### 1. Start Session (One-Call Bootstrap)
```
macro_start_session(
human_key="/abs/path/to/project",
program="claude-code",
model="opus-4.5",
task_description="Implementing auth module"
)
```
Returns: `{project, agent, file_reservations, inbox}`
This single call: ensures project exists, registers your identity, optionally reserves files, fetches your inbox.
### 2. Reserve Files Before Editing
```
file_reservation_paths(
project_key="/abs/path/to/project",
agent_name="GreenCastle",
paths=["src/auth/**/*.ts", "src/middleware/auth.ts"],
ttl_seconds=3600,
exclusive=true,
reason="bd-123"
)
```
Returns: `{granted: [...], conflicts: [...]}`
Conflicts are reported but reservations are still granted. Check conflicts and coordinate if needed.
### 3. Announce Your Work
```
send_message(
project_key="/abs/path/to/project",
sender_name="GreenCastle",
to=["BlueLake"],
subject="[bd-123] Starting auth refactor",
body_md="Reserving src/auth/**. Will update session handling.",
thread_id="bd-123",
importance="normal",
ack_required=true
)
```
### 4. Check Inbox Periodically
```
fetch_inbox(
project_key="/abs/path/to/project",
agent_name="GreenCastle",
limit=20,
urgent_only=false,
include_bodies=true
)
```
Or use resources for fast reads:
```
resource://inbox/GreenCastle?project=/abs/path&limit=20&include_bodies=true
```
### 5. Release Reservations When Done
```
release_file_reservations(
project_key="/abs/path/to/project",
agent_name="GreenCastle"
)
```
## The Four Macros
Prefer macros for speed and smaller models. Use granular tools when you need fine control.
| Macro | Purpose |
|-------|---------|
| `macro_start_session` | Bootstrap: ensure project → register agent → optional file reservations → fetch inbox |
| `macro_prepare_thread` | Join existing conversation: register → summarize thread → fetch inbox context |
| `macro_file_reservation_cycle` | Reserve files, do work, optionally auto-release when done |
| `macro_contact_handshake` | Request contact permission, optionally auto-accept, send welcome message |
## Beads Integration (bd-### Workflow)
When using Beads for task management, keep identifiers aligned:
```
1. Pick ready work: bd ready --json → choose bd-123
2. Reserve files: file_reservation_paths(..., reason="bd-123")
3. Announce start: send_message(..., thread_id="bd-123", subject="[bd-123] Starting...")
4. Work and update: Reply in thread with progress
5. Complete: bd close bd-123
release_file_reservations(...)
send_message(..., subject="[bd-123] Completed")
```
Use `bd-###` as:
- Mail `thread_id`
- Message subject prefix `[bd-###]`
- File reservation `reason`
- Commit message reference
## Beads Viewer (bv) Integration
Use bv's robot flags for intelligent task selection:
| Flag | Output | Use Case |
|------|--------|----------|
| `bv --robot-insights` | PageRank, critical path, cycles | "What's most impactful?" |
| `bv --robot-plan` | Parallel tracks, unblocks | "What can run in parallel?" |
| `bv --robot-priority` | Recommendations with confidence | "What should I work on next?" |
| `bv --robot-diff --diff-since <ref>` | Changes since commit/date | "What changed?" |
**Rule of thumb:** Use `bd` for task operations, use `bv` for task intelligence.
## Cross-Project Coordination
For frontend/backend or multi-repo projects:
**Option A: Shared project_key**
Both repos use the same `project_key`. Agents coordinate automatically.
**Option B: Separate projects with contact links**
```
# Backend agent requests contact with frontend agent
request_contact(
project_key="/abs/path/backend",
from_agent="GreenCastle",
to_agent="BlueLake",
to_project="/abs/path/frontend",
reason="API contract coordination"
)
# Frontend agent accepts
respond_contact(
project_key="/abs/path/frontend",
to_agent="BlueLake",
from_agent="GreenCastle",
accept=true
)
```
## Pre-Commit Guard
Install the guard to block commits that conflict with others' exclusive reservations:
```
install_precommit_guard(
project_key="/abs/path/to/project",
code_repo_path="/abs/path/to/project"
)
```
### Guard Features
- **Composition-safe**: Chain-runner preserves existing hooks in `hooks.d/`
- **Rename-aware**: Checks both old and new paths for renames/moves
- **NUL-safe**: Handles paths with special characters
- **Git-native matching**: Uses Git wildmatch pathspec semantics
Set `AGENT_NAME` environment variable so the guard knows who you are.
Bypass in emergencies: `AGENT_MAIL_BYPASS=1 git commit ...`
## Tools Reference
### Project & Identity
| Tool | Purpose |
|------|---------|
| `ensure_project(human_key)` | Create/ensure project exists |
| `register_agent(project_key, program, model, name?, task_description?)` | Register identity |
| `whois(project_key, agent_name)` | Get agent profile with recent commits |
| `create_agent_identity(project_key, program, model)` | Always create new unique agent |
### Messaging
| Tool | Purpose |
|------|---------|
| `send_message(project_key, sender, to, subject, body_md, ...)` | Send message |
| `reply_message(project_key, message_id, sender, body_md)` | Reply (preserves thread) |
| `fetch_inbox(project_key, agent, limit?, since_ts?, urgent_only?)` | Get messages |
| `mark_message_read(project_key, agent, message_id)` | Mark as read |
| `acknowledge_message(project_key, agent, message_id)` | Acknowledge receipt |
| `search_messages(project_key, query)` | FTS5 search |
| `summarize_thread(project_key, thread_id)` | Extract key points and actions |
##Related in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts — single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score ≥ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.