Skip to content

Cocoanetics/Post

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

76 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Post Logo

Post 🏀

A local mail daemon, MCP server, and CLI β€” built entirely in Swift.

πŸ“– Read the announcement β†’

Post pulls together SwiftMail, SwiftMCP, and SwiftText to give you a persistent, local-first email system that keeps tabs on multiple mailboxes across multiple IMAP servers.

Architecture

Post is three things in one package:

postd β€” The Daemon

A lightweight process that maintains persistent IMAP connections to all your configured mail servers. Optionally, it can use IMAP IDLE on any mailbox (INBOX, Sent, a custom folder, etc.) to get instant push notifications when messages arrive or change. When a change is detected, it can trigger a custom command β€” a shell script, a webhook call, whatever you need.

MCP Server

The daemon doubles as an MCP (Model Context Protocol) server, exposing your email to AI agents. Agents can list servers, search messages, fetch content, download attachments, move/copy/flag messages, draft emails, and more β€” all through a standardized tool interface.

post β€” The CLI

A fast command-line client for searching, reading, downloading, and managing email. Communicates with the running daemon via local Bonjour + HTTP β€” no separate IMAP connections needed.

post list --server work --limit 10
post fetch 12199 --server work
post fetch 12198,12199 --eml --out ./backup
post search --from "amazon" --since 2025-01-01
post move 12345 Archive
post attachment 12199 --out ./downloads
post draft --to colleague@example.com --subject "Update" --body email.md

πŸ“– Full CLI User Guide β†’

How It Works

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  post CLI   │◄── Bonjour + HTTP ─────►│                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                         β”‚                  │──── IMAP IDLE ──► Mail Server 1
                                        β”‚  postd daemon    │──── IMAP IDLE ──► Mail Server 2
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                         β”‚                  │──── IMAP IDLE ──► Mail Server 3
β”‚  AI Agents  │◄── MCP (TCP) ──────────►│                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

The daemon holds all IMAP connections. Both the CLI and AI agents talk to the daemon β€” never directly to mail servers. This means:

  • Single connection pool β€” no duplicate IMAP sessions
  • Local-only by default β€” daemon accepts connections from localhost only (secure by default)
  • Instant discovery β€” CLI finds the daemon via Bonjour on the local machine
  • Always up-to-date β€” IDLE keeps mailbox state fresh
  • Trigger scripts β€” run custom commands when new mail arrives

Key Features

πŸ” Secure Credential Storage

Store credentials directly in config (simple) or in a hardware-bound macOS Keychain (recommended). Post creates a private keychain encrypted with your Mac's hardware UUID β€” credentials never leave your machine.

πŸ“ Markdown Email Drafts

Draft rich HTML emails from plain markdown files. Post handles the conversion and creates drafts in your mail client, ready to review and send.

post draft --to team@company.com \
  --subject "Weekly Update" \
  --body weekly-update.md

πŸ”‘ Multi-Agent Access Control

Create scoped API keys that limit which agents can access which mail servers. Perfect for sandboxed agents or multi-tenant scenarios.

post api-key create --servers work     # Work-only token
post api-key create --servers personal # Personal-only token

⚑ IMAP IDLE Push Notifications

Get instant notifications when mail arrives. Perfect for automation workflows like invoice processing, newsletter archival, or notification routing.

πŸ“¬ Mail Room Automation

Combine IDLE with handler scripts to build a "mail room" that automatically sorts incoming mail:

  • Newsletters β†’ Archived as markdown
  • Service notifications β†’ Organized by sender
  • Spam β†’ Filtered with AI (sandboxed, no access to personal data)
  • Personal mail β†’ Stays in inbox for your attention

Goal: Inbox Zero through intelligent, automated triage.

Getting Started

Requirements

  • macOS 14.0+
  • Swift 6.0+

Build & Run

# Build
swift build

# Add credentials to secure keychain
post keychain add personal --host imap.gmail.com --port 993

# Create config
echo '{ "servers": { "personal": {} } }' > ~/.post.json

# Start the daemon
postd start

πŸ“– Daemon Setup & Configuration β†’ β€” configuration options, IMAP IDLE, Launch Agent setup, credential management

Dependencies

Package Purpose
SwiftMail IMAP/SMTP client library
SwiftMCP Model Context Protocol server framework
SwiftText HTML/PDF/DOCX to markdown conversion
swift-argument-parser CLI argument parsing
swift-log Structured logging

Related Projects

  • mail-room β€” OpenClaw skill for automated email sorting and archival
  • Agent Skills β€” Standard for building reusable AI agent tools
  • OpenClaw β€” Agentic platform that inspired Post's design

Roadmap

  • Identity-based access control β€” assign different identities to different agents, restricting which mailboxes and servers each agent can see
  • Permission levels β€” fine-grained access tiers:
    • Read-only
    • Archive-only
    • Allow trash/delete
    • Allow creating drafts
    • Allow sending
  • Multi-agent isolation β€” ensure agents only see what they're supposed to see
  • Homebrew distribution β€” easy installation via brew install cocoanetics/tap/post
  • ClawHub skill β€” pre-packaged OpenClaw skill for easy integration

License

MIT β€” see LICENSE for details.


Built with ❀️ by Oliver Drobnik β€’ Blog β€’ GitHub

About

Post 🏀 β€” Local mail daemon, MCP server, and CLI built in Swift

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors