An MCP (Model Context Protocol) server for interacting with Fastmail via JMAP. Designed for interactive email cleanup - finding and managing newsletters, receipts, marketing emails, and other accumulated mail.
- List Mailboxes - See all folders and their email counts
- Search Emails - Find emails by sender, recipient (alias), age, read status
- Analyze Senders - See who sends you the most email
- Analyze Aliases - See which of your addresses receive the most mail
- Get Cleanup Candidates - Find newsletters, shipping notifications, marketing emails
- Delete Emails - Move to trash or permanently delete
- Go to Fastmail Settings → Privacy & Security → API Tokens
- Click "Generate API Token"
- Name it something like "Claude MCP"
- Enable these scopes:
- Email (required) - for reading and managing mail
- Masked Email (optional) - for seeing your aliases
- Leave "Read-only access" OFF (we need write access to delete)
- Click "Generate API token" and copy the token
Create a .env file in this directory:
FASTMAIL_API_TOKEN=fmu1-your-token-here
cd ~/repos/fastmail-mcp
pip install -e .Or install dependencies directly:
pip install mcp httpx python-dotenv pydanticAdd to your Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json):
{
"mcpServers": {
"fastmail": {
"command": "python",
"args": ["/Users/greg/repos/fastmail-mcp/server.py"]
}
}
}Or if you installed it as a package:
{
"mcpServers": {
"fastmail": {
"command": "fastmail-mcp"
}
}
}Restart Claude Desktop, then try:
- "What mailboxes do I have in Fastmail?"
- "Who sends me the most email?"
- "Find newsletters older than 30 days"
- "Show me emails sent to lowes@802ski.com"
Verify your connection and see account details.
List all folders with email counts.
Search with filters:
mailbox_name- Folder to searchfrom_address- Sender email or domainto_address- Recipient (your alias)older_than_days- Age filteris_read- Read/unread statussubject_contains- Subject text searchlimit- Max results (1-100)
Top senders by volume in a mailbox.
Which of your addresses receive the most mail.
Find cleanup targets by category:
newsletters- Newsletter-like emailsshipping- Shipping/tracking notificationsmarketing- Promotional emailsold_unread- Old emails you never readall- Check all categories
Delete emails by ID:
email_ids- List of IDs to deletepermanent- True to permanently delete, False (default) to move to Trash
1. "What's accumulating in my mail?"
2. "Find newsletters older than 14 days"
3. "Show me shipping notifications older than 30 days"
4. [Review the list]
5. "Delete these emails" [paste IDs]
1. "Who sends me the most email?"
2. "Show me all emails from newsletter@example.com"
3. "Delete all those older than 7 days"
1. "Show me emails sent to lowes@802ski.com"
2. "Which are shipping notifications vs receipts?"
3. "Delete the shipping ones older than 60 days"
- Your API token is stored in
.envand never transmitted except to Fastmail's API - The token has full email access - treat it like a password
- Add
.envto.gitignore(already done if you cloned this repo)
"FASTMAIL_API_TOKEN not set"
- Make sure
.envfile exists in the project directory - Make sure the token starts with
fmu1-
"Authentication failed"
- Token may be expired or revoked
- Generate a new one in Fastmail settings
"Permission denied"
- Check that the Email scope is enabled for your token
- Make sure "Read-only access" is OFF
MIT