Skip to content
AppsAtMePublic

About

ClawMail is a macOS-native application that gives AI agents full, programmatic access to email, contacts, calendar, and tasks on configured accounts. It is designed to run in the background as a menu bar app, requiring minimal human interaction beyond initial account setup and occasional status monitoring.

Resources

Code of conduct

Contributing

Security policy

Stars

3 stars

Watchers

0 watching

Forks

Repository files navigation

ClawMail

ClawMail

Agent-first email client for macOS. Gives AI agents full programmatic access to email, calendar, contacts, and tasks via MCP, CLI, and REST API.

What Is This?

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.

Requirements

  • macOS 14.0 (Sonoma) or later
  • Swift 6 toolchain (Xcode 16+)
  • Docker (optional, for integration tests)

Installation

From Source

git clone https://github.com/AppsAtMe/ClawMail.git
cd ClawMail
make install

This 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/ClawMailCLI and /Applications/ClawMail.app/Contents/MacOS/ClawMailMCP directly
  • create the /usr/local/bin symlinks manually with sudo

Launch at login installs ~/Library/LaunchAgents/com.clawmail.agent.plist, which starts /Applications/ClawMail.app/Contents/MacOS/ClawMailApp.

Uninstall

make uninstall

Removes the app, symlinks, and LaunchAgent.

First-Run Setup

  1. Launch ClawMail — open from /Applications or run open /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.

  2. 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)
  3. 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
  4. 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.app

Apple / iCloud Setup

Apple documents iCloud Mail for third-party apps via app-specific passwords and publishes the mail server settings separately.

  1. Create an app-specific password for your Apple Account
  2. In ClawMail, choose Apple / iCloud
  3. Enter your iCloud email address and that app-specific password
  4. ClawMail prefills Apple's published mail servers: imap.mail.me.com:993 with SSL and smtp.mail.me.com:587 with STARTTLS

Google Setup

  1. Open the Google Cloud Console credential guide
  2. Create an OAuth client for a Desktop app
  3. Configure the OAuth consent screen (set Audience to External for personal accounts)
  4. Enable required APIs: Gmail, CalDAV API (for calendar), and CardDAV scope
  5. Copy the Client ID to Settings > API > OAuth Client IDs > Google Client ID in ClawMail
  6. Choose Google in ClawMail and complete the browser sign-in

See docs/ACCOUNTS.md for troubleshooting common Google OAuth issues.

Microsoft 365 / Outlook Setup

  1. Open the Microsoft Entra desktop app setup guide
  2. Create an app registration with Supported account types set to "Accounts in any organizational directory and personal Microsoft accounts"
  3. Copy the Application (client) ID to Settings > API > OAuth Client IDs > Microsoft Client ID in ClawMail
  4. Choose Microsoft 365 / Outlook in ClawMail and click "Open Browser"
  5. Add the displayed redirect URI to your Entra app registration under Authentication → Mobile and desktop applications
  6. 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 Setup

Fastmail works best with an app password:

  1. Create a Fastmail app password
  2. In ClawMail, choose Fastmail
  3. Enter your Fastmail address and app password
  4. 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/

Agent Interfaces

MCP (Primary)

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.

CLI

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 log

Output defaults to JSON. Use --format=text for human-readable output.

Available command groups: email, calendar, contacts, tasks, accounts, audit, recipients, status

REST API

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/approve

Rate limited to 120 requests/minute.

Endpoints: /email, /calendar, /contacts, /tasks, /accounts, /audit, /recipients, /recipients/pending, /recipients/approve, /recipients/reject

Search Syntax

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

Configuration

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"
}

Webhook Notifications

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"
}

Local Approval Notifications

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.

Data Locations

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.

Security

  • 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.

Building & Testing

# 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 everything

Release Build with Signing

make dmg SIGNING_ID="Developer ID Application: Your Name (TEAMID)"

Notarization

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=XXXXXXXXXX

Project Structure

ClawMail/
  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

Tech Stack

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

Documentation

Troubleshooting tip: If you run into issues during account setup, check docs/ACCOUNTS.md for provider-specific troubleshooting steps.

Contributing

See CONTRIBUTING.md for guidelines on reporting bugs, requesting features, and submitting pull requests.

License

MIT

About

ClawMail is a macOS-native application that gives AI agents full, programmatic access to email, contacts, calendar, and tasks on configured accounts. It is designed to run in the background as a menu bar app, requiring minimal human interaction beyond initial account setup and occasional status monitoring.

Resources

Code of conduct

Contributing

Security policy

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages