Build with Mailathon
Intent in, verified email out. Connect your agents via MCP or REST, leverage the provider adapter framework, and let Mailathon handle brand compliance, deliverability, and rendering.
Quickstart
Get up and running in 5 minutes
API Reference
REST endpoints & models
MCP Server
8 tools for AI agents
Integrations
Provider adapter framework
Quickstart
1. Install the MCP server
cd mcp
pip install -e .2. Configure environment
MAILATHON_API_BASE_URL=http://localhost:8000
MAILATHON_WEB_BASE_URL=http://localhost:3000
MAILATHON_AUTH_TOKEN=your-token-here3. Run the server
# stdio transport (Claude Desktop, Cursor)
python server.py
# SSE transport (web-based MCP clients)
python server.py --sse4. Add to Claude Desktop
{
"mcpServers": {
"mailathon": {
"command": "python",
"args": ["/path/to/mailathon-web/mcp/server.py"],
"env": {
"MAILATHON_API_BASE_URL": "http://localhost:8000",
"MAILATHON_WEB_BASE_URL": "http://localhost:3000",
"MAILATHON_AUTH_TOKEN": "your-token-here"
}
}
}
}API Reference
The Mailathon API is a FastAPI service exposing intent-native email operations. All models use Pydantic v2 with extra="forbid" for strict validation.
/v1/emails/{task_id}/sendSend a verified email draft via a delivery provider. Self-contained - the caller provides draft, provider name, config, and recipient. No cross-service DB access needed.
{
"draft": {
"subject": "Welcome to Mailathon",
"html_body": "<html>...</html>",
"plain_body": "Welcome...",
"from_name": "Mailathon",
"from_email": "hello@mailathon.ai"
},
"provider_name": "resend",
"provider_config": { "api_key": "re_..." },
"recipient": "user@example.com",
"metadata": { "campaign_id": "camp_01" }
}{
"send_id": "msg_abc123",
"task_id": "task_789",
"status": "queued"
}Core Models
EmailTypewelcome, promotion, newsletter, reactivation, transactional, announcement
CampaignGoalactivate, convert, retain, upsell, educate, recover_cart
FunnelStageawareness, consideration, conversion, onboarding, retention
ToneOverridesofter, more_direct, urgent
MCP Server
Thin HTTP proxy that exposes Mailathon's workflows to AI agents. Each tool maps 1:1 to an HTTP endpoint — no business logic lives in the MCP layer.
Available Tools (8)
| Tool | Target |
|---|---|
| generate_brand_email | API :8000 |
| get_email_status | Web :3000 |
| get_email_result | Web :3000 |
| approve_email | Web :3000 |
| send_email | Web :3000 |
| get_brand_guidelines | API :8000 |
| update_brand_guidelines | API :8000 |
| list_templates | Web :3000 |
Example Tool Call
{
"method": "tools/call",
"params": {
"name": "generate_brand_email",
"arguments": {
"org_id": "org_123",
"brand_id": "brand_456",
"intent": "announce our new product launch",
"audience_desc": "existing customers",
"magic_mode": false
}
}
}Environment Variables
| Variable | Description |
|---|---|
| MAILATHON_API_BASE_URL | FastAPI backend base URL |
| MAILATHON_WEB_BASE_URL | Next.js web app base URL |
| MAILATHON_AUTH_TOKEN | Bearer token sent to both services |
Integration Framework
Provider adapters — not one-off integrations. The registry pattern lets you connect once and swap freely between providers.
Delivery Providers
resendResend transactional email service
agentmailAgentMail inbox + thread management
Data Providers
csv_importCSV file import for subscriber lists
Registering a Provider
from integrations import registry, DeliveryProvider
class MyProvider(DeliveryProvider):
@property
def name(self) -> str:
return "my_provider"
async def send_email(self, draft, recipient, metadata=None):
# Your delivery logic here
...
# Auto-registers via decorator or manual call
registry.register_provider("my_provider", MyProvider)Troubleshooting
CONNECTION_ERROROne of the backend services is not running. Start FastAPI (:8000) and/or Next.js (:3000).
TIMEOUTGeneration can take up to 5 minutes for complex emails. SSE stream has a 300s timeout. Check backend logs if persistent.
HTTP 401/403Set MAILATHON_AUTH_TOKEN to a valid bearer token.
Retry behavior: requests automatically retry 3x with exponential backoff (0.5s → 4s) for 502/503/504 responses and connection errors.