Agent-first email client for macOS. Gives AI agents full programmatic access to email, calendar, contacts, and tasks via MCP, CLI, and REST API.
ClawMail runs as a macOS menu bar daemon, maintaining persistent IMAP connections to your email accounts. AI agents (like Claude) interact with your email through three interfaces — no browser automation or credential sharing required.
Agent Interfaces: MCP (stdio) | CLI | REST API (localhost:24601)
| | |
IPC (Unix domain socket, JSON-RPC 2.0)
|
AccountOrchestrator
______________|______________
| | | | |
Email Calendar Contacts Tasks Guardrails
(IMAP/ (CalDAV) (CardDAV) (VTODO) + Audit
SMTP) Log
The human UI exists only for setup and monitoring. All operations flow through the agent interfaces.
- macOS 14.0 (Sonoma) or later
- Swift 6 toolchain (Xcode 16+)
- Docker (optional, for integration tests)
git clone https://github.com/AppsAtMe/ClawMail.git
cd ClawMail
make installThis builds a release binary, creates ClawMail.app, and installs it to /Applications/ClawMail.app.
If BIN_DIR is writable, make install also symlinks the CLI tools there. By default, BIN_DIR=/usr/local/bin:
| Symlink | Points to |
|---|---|
/usr/local/bin/clawmail |
ClawMail.app/Contents/MacOS/ClawMailCLI |
/usr/local/bin/clawmail-mcp |
ClawMail.app/Contents/MacOS/ClawMailMCP |
If /usr/local/bin is not writable on your machine, the app install still succeeds and make install prints the direct executable path. You can either:
- rerun with
make install BIN_DIR="$HOME/.local/bin" - use
/Applications/ClawMail.app/Contents/MacOS/ClawMailCLIand/Applications/ClawMail.app/Contents/MacOS/ClawMailMCPdirectly - create the
/usr/local/binsymlinks manually withsudo
Launch at login installs ~/Library/LaunchAgents/com.clawmail.agent.plist, which starts /Applications/ClawMail.app/Contents/MacOS/ClawMailApp.
make uninstallRemoves the app, symlinks, and LaunchAgent.
-
Launch ClawMail — open from
/Applicationsor runopen /Applications/ClawMail.app. It appears as a menu bar icon (no Dock icon). On a first launch with no accounts configured, ClawMail opens Settings to the Accounts tab automatically and presents the add-account flow. If you close that window, you can reopen it from the menu bar icon. -
Add an account — click the menu bar icon, open Settings, go to the Accounts tab, and click "+". The setup wizard walks through:
- Provider selection (Apple/iCloud, Google, Microsoft 365 / Outlook, Fastmail, Other)
- Credentials — server details and authentication
- Connection test — verifies IMAP, SMTP, CalDAV, and CardDAV connectivity
- Label — a short name used in CLI/API calls (e.g.,
work,personal)
-
Configure guardrails (optional) — Settings > Guardrails:
- Send rate limits (per minute / hour / day)
- Domain allowlist or blocklist
- First-time recipient approval (requires human approval before sending to new addresses)
- Held sends can be reviewed in Settings > Guardrails, via
clawmail recipients ..., or through the/api/v1/recipients/*REST routes - If macOS notification permission is granted, ClawMail posts a local notification when a send is held for approval
-
Connect an agent — see Agent Interfaces below.
Need help? See docs/ACCOUNTS.md for detailed setup instructions and troubleshooting for all providers.
For manual testing, a handy way to keep app logs visible without blocking your shell is:
: > /tmp/clawmail.stderr.log && tail -n 0 -F /tmp/clawmail.stderr.log &
open /Applications/ClawMail.appApple documents iCloud Mail for third-party apps via app-specific passwords and publishes the mail server settings separately.
- Create an app-specific password for your Apple Account
- In ClawMail, choose
Apple / iCloud - Enter your iCloud email address and that app-specific password
- ClawMail prefills Apple's published mail servers:
imap.mail.me.com:993with SSL andsmtp.mail.me.com:587with STARTTLS
- Open the Google Cloud Console credential guide
- Create an OAuth client for a
Desktop app - Configure the OAuth consent screen (set Audience to
Externalfor personal accounts) - Enable required APIs: Gmail, CalDAV API (for calendar), and CardDAV scope
- Copy the
Client IDtoSettings > API > OAuth Client IDs > Google Client IDin ClawMail - Choose
Googlein ClawMail and complete the browser sign-in
See docs/ACCOUNTS.md for troubleshooting common Google OAuth issues.
- Open the Microsoft Entra desktop app setup guide
- Create an app registration with Supported account types set to "Accounts in any organizational directory and personal Microsoft accounts"
- Copy the
Application (client) IDtoSettings > API > OAuth Client IDs > Microsoft Client IDin ClawMail - Choose
Microsoft 365 / Outlookin ClawMail and click "Open Browser" - Add the displayed redirect URI to your Entra app registration under Authentication → Mobile and desktop applications
- Complete the browser sign-in flow
CalDAV/CardDAV support varies by tenant — leave blank unless your provider documents specific DAV endpoints.
See docs/ACCOUNTS.md for troubleshooting Microsoft OAuth issues.
Fastmail works best with an app password:
- Create a Fastmail app password
- In ClawMail, choose
Fastmail - Enter your Fastmail address and app password
- ClawMail prefills:
- IMAP:
imap.fastmail.com:993 - SMTP:
smtp.fastmail.com:465 - CalDAV:
https://caldav.fastmail.com/dav/calendars/user/ - CardDAV:
https://carddav.fastmail.com/dav/addressbooks/user/
- IMAP:
Add to your Claude Code .mcp.json or MCP settings:
{
"mcpServers": {
"clawmail": {
"command": "/Applications/ClawMail.app/Contents/MacOS/ClawMailMCP"
}
}
}If you installed ClawMail somewhere other than /Applications, point command at that bundle's ClawMailMCP executable instead.
ClawMail provides 34 MCP tools across email, calendar, contacts, tasks, and administration. It also pushes server-initiated notifications for new mail, connection status changes, and errors.
Only one MCP session is allowed at a time (exclusive agent lock). CLI sessions run concurrently alongside.
clawmail status # daemon status
clawmail email list --account=work --folder=INBOX # list messages
clawmail email send --account=work \
--to="alice@example.com" \
--subject="Report" \
--body="See attached" \
--attach="/path/to/report.pdf" # send with attachment
clawmail email search --account=work "from:bob invoice" # full-text search
clawmail calendar list --account=work \
--from=2026-01-01 --to=2026-01-31 # list events
clawmail contacts list --account=personal --query="Alice" # search contacts
clawmail tasks create --account=work \
--task-list=default --title="Review PR" --due=2026-03-10
clawmail recipients list # approved recipients
clawmail recipients pending # held sends awaiting approval
clawmail recipients approve --account=work --request-id=<id> # release held send
clawmail recipients reject --account=work --request-id=<id> # reject held send
clawmail recipients remove --account=work alice@example.com # revoke approved recipient
clawmail audit list --account=work --limit=20 # audit logOutput defaults to JSON. Use --format=text for human-readable output.
Available command groups: email, calendar, contacts, tasks, accounts, audit, recipients, status
Local HTTP server at http://127.0.0.1:24601/api/v1. Authenticated via Bearer token.
Retrieve the API key:
API_KEY=$(security find-generic-password -s "com.clawmail" -a "clawmail-api-key" -w)Example requests:
# Check status (no auth required)
curl http://localhost:24601/api/v1/status
# List emails
curl -H "Authorization: Bearer $API_KEY" \
"http://localhost:24601/api/v1/email?account=work&folder=INBOX&limit=10"
# Send email
curl -X POST -H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"account":"work","to":[{"email":"alice@example.com"}],"subject":"Hello","body":"Hi there"}' \
http://localhost:24601/api/v1/email/send
# Search
curl -H "Authorization: Bearer $API_KEY" \
"http://localhost:24601/api/v1/email/search?account=work&q=from:bob+invoice"
# List held sends awaiting approval
curl -H "Authorization: Bearer $API_KEY" \
"http://localhost:24601/api/v1/recipients/pending?account=work"
# Approve a held send by request ID
curl -X POST -H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"account":"work","requestId":"req-123"}' \
http://localhost:24601/api/v1/recipients/approveRate limited to 120 requests/minute.
Endpoints: /email, /calendar, /contacts, /tasks, /accounts, /audit, /recipients, /recipients/pending, /recipients/approve, /recipients/reject
Full-text search supports field-specific queries:
| Query | Description |
|---|---|
invoice |
Free-text search across all fields |
from:alice |
Messages from alice |
to:bob@example.com |
Messages to a specific address |
subject:quarterly report |
Subject line search |
from:alice subject:invoice |
Combined filters |
has:attachment |
Messages with attachments |
from:alice budget |
Field filter + free text |
Config file: ~/Library/Application Support/ClawMail/config.json
Most settings are managed through the Settings UI, but can also be edited directly:
{
"accounts": [],
"restApiPort": 24601,
"syncIntervalMinutes": 15,
"initialSyncDays": 30,
"auditRetentionDays": 90,
"idleFolders": ["INBOX"],
"launchAtLogin": true,
"guardrails": {
"sendRateLimit": { "maxPerHour": 20, "maxPerDay": 100 },
"domainAllowlist": null,
"domainBlocklist": ["competitor.com"],
"firstTimeRecipientApproval": false
},
"webhookURL": "https://your-server.com/clawmail-webhook"
}Set webhookURL in Settings > API to receive HTTP POST notifications when new mail arrives. Payload:
{
"event": "newMail",
"account": "work",
"folder": "INBOX",
"messageId": "msg-123",
"from": "alice@example.com",
"subject": "Hello",
"timestamp": "2026-03-05T10:30:00Z"
}When first-time recipient approval blocks a send, ClawMail requests macOS notification permission at launch and posts a local notification identifying the affected account and recipients. Delivery failures are non-fatal and logged to stderr.
| Item | Path |
|---|---|
| Config | ~/Library/Application Support/ClawMail/config.json |
| Database | ~/Library/Application Support/ClawMail/metadata.sqlite |
| IPC socket | ~/Library/Application Support/ClawMail/clawmail.sock |
| IPC token | ~/Library/Application Support/ClawMail/ipc.token |
| Credentials | macOS Keychain (service: com.clawmail) |
| LaunchAgent | ~/Library/LaunchAgents/com.clawmail.agent.plist |
| Logs | /tmp/clawmail.stdout.log, /tmp/clawmail.stderr.log |
Direct app launches and LaunchAgent runs both append to those log files.
- Credentials: Stored in macOS Keychain with
.afterFirstUnlockThisDeviceOnly— never synced to iCloud - TLS: Required for all IMAP/SMTP/CalDAV/CardDAV connections; DAV endpoints must use HTTPS
- REST API: Bound to localhost only, authenticated via API key, rate-limited (120 req/min)
- IPC: Token file with 0600 permissions, peer PID verification, socket directory chmod 0700
- Guardrails: Configurable send rate limits, domain allow/blocklists, and account-scoped first-time recipient approval with explicit held-send review
- Audit: Every agent write operation is logged with timestamp, action, account, and parameters
- Input validation: IMAP/SMTP injection prevention, FTS5 query sanitization, DAV same-origin follow-up URL validation, and path traversal blocking
- Attachment security: Attachment path checks resolve symlinks before enforcement. Downloads are restricted to
~/Downloads,~/Documents,~/Desktop, and temp. Reads are blocked from system paths plus sensitive home directories such as.ssh,.gnupg,.config,.aws, Keychains, and ClawMail's own app-support directory.
# Development
swift build # debug build
swift build -c release # release build
swift test # unit tests (no Docker needed)
# Integration tests (requires Docker)
make test-all # start containers, run tests, stop containers
# Or manually:
docker compose up -d # start GreenMail (IMAP/SMTP) + Radicale (CalDAV/CardDAV)
swift test # run all tests
docker compose down # stop containers
# Packaging
make bundle # create .app bundle
make sign # ad-hoc code sign (local dev)
make dmg # create distributable DMG
make install # install to /Applications + symlink CLI
make uninstall # remove everythingmake dmg SIGNING_ID="Developer ID Application: Your Name (TEAMID)"Requires a Developer ID certificate and stored credentials:
# One-time: store notarization credentials
xcrun notarytool store-credentials "notarytool-password" \
--apple-id you@example.com \
--team-id XXXXXXXXXX \
--password "app-specific-password"
# Build, sign, package, and notarize
make notarize \
SIGNING_ID="Developer ID Application: Your Name (TEAMID)" \
TEAM_ID=XXXXXXXXXXClawMail/
Sources/
ClawMailCore/ # Shared library: models, protocol clients, business logic
Models/ # Data models (Account, EmailSummary, CalendarEvent, etc.)
Email/ # IMAP client, SMTP client, EmailManager
Search/ # SearchEngine (FTS5 query building)
Calendar/ # CalDAV client, CalendarManager
Contacts/ # CardDAV client, ContactsManager
Tasks/ # TaskManager, VTODOParser
Auth/ # OAuth2Manager, OAuthHelpers
Storage/ # MetadataIndex (SQLite/FTS5), CredentialStore, AuditLog
Guardrails/ # GuardrailEngine
Sync/ # SyncEngine, SyncScheduler
IPC/ # JSON-RPC 2.0 server/client, dispatcher
Webhook/ # WebhookManager
ClawMailAppLib/ # REST API library (routes, middlewares)
ClawMailApp/ # macOS menu bar app (SwiftUI)
ClawMailCLI/ # CLI tool
ClawMailMCP/ # MCP stdio server
Tests/
ClawMailCoreTests/ # Unit tests for core library
ClawMailAppLibTests/ # REST API tests
ClawMailIntegrationTests/ # Docker-dependent integration tests
Resources/ # LaunchAgent plist template
HomebrewFormula/ # Homebrew Cask formula
| Component | Technology |
|---|---|
| Language | Swift 6 (strict concurrency) |
| UI | SwiftUI (macOS 14+) |
| Build | Swift Package Manager |
| Database | SQLite via GRDB.swift (FTS5 for search) |
| Networking | SwiftNIO (IMAP/SMTP), URLSession (CalDAV/CardDAV) |
| HTTP Server | Hummingbird 2.x |
| CLI | Swift Argument Parser |
| Credentials | macOS Keychain via KeychainAccess |
| HTML Parsing | SwiftSoup |
docs/SPECIFICATION.md— Complete feature specificationdocs/BLUEPRINT.md— Implementation blueprint with build phasesdocs/ROADMAP.md— Remaining gaps, deferred features, and testing backlogdocs/ACCOUNTS.md— Account setup guide and troubleshooting for all providersdocs/FAQ.md— Frequently asked questionsdocs/INSTALL.md— Installation guidedocs/operations-reference.md— Runtime services, files, approvals, and operational behavior
Troubleshooting tip: If you run into issues during account setup, check docs/ACCOUNTS.md for provider-specific troubleshooting steps.
See CONTRIBUTING.md for guidelines on reporting bugs, requesting features, and submitting pull requests.
