Fastmail MCP Server
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Fastmail MCP Server summarize my unread emails from the last 24 hours"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Fastmail MCP Server
A Model Context Protocol (MCP) server for Fastmail email, enabling AI assistants to read inbox mail, search messages, page through large result sets, send and reply to email, and manage drafts.
Tool descriptions are written as routing hints for MCP clients, so prompts like "check email", "read my inbox", "reply to this email", and "save a draft" map more reliably to the right Fastmail tools.
Features
Core Email Operations
List mailboxes and get mailbox statistics
List, search, and filter emails with advanced criteria
Get specific emails by ID with full content
Send emails (text and HTML) with proper draft/sent handling
Reply to emails with proper threading (In-Reply-To, References headers)
Create and save email drafts (with or without threading)
Email management: mark read/unread, delete, move between folders
Advanced Email Features
Attachment Handling: List and download email attachments
Threading Support: Get complete conversation threads
Advanced Search: Multi-criteria filtering (sender, date range, attachments, read status)
Bulk Operations: Process multiple emails simultaneously
Statistics & Analytics: Account summaries and mailbox statistics
Label vs Move Operations
move_email/bulk_move: Replaces ALL mailboxes for an email (folder behavior)
add_labels/remove_labels: Adds/removes SPECIFIC mailboxes while preserving others (label behavior)
Identity & Account Management
List available sending identities
Account summary with comprehensive statistics
Related MCP server: fastmail-mcp
Setup
Prerequisites
Node.js 18+
A Fastmail account with API access
Fastmail API token
Installation
Clone or download this repository
Install dependencies:
npm installBuild the project:
npm run build
Configuration
Get your Fastmail API token:
Log in to Fastmail web interface
Go to Settings ā Privacy & Security
Find "Connected apps & API tokens" section
Click "Manage API tokens"
Click "New API token"
Copy the generated token
Set environment variables:
export FASTMAIL_API_TOKEN="your_api_token_here" # Optional: customize base URL (defaults to https://api.fastmail.com) export FASTMAIL_BASE_URL="https://api.fastmail.com"
Running the Server
Start the MCP server:
npm startFor development with auto-reload:
npm run devRemote HTTP Mode for ChatGPT / Hosted MCP
You can also run the server as a private remote MCP endpoint by setting MCP_PATH.
This mode is intended for a small number of trusted clients that all use the same Fastmail account.
export FASTMAIL_API_TOKEN="your_api_token_here"
export MCP_PATH="replace-with-a-long-random-secret-path"
export PORT="3000"
# Optional operational limits
export MCP_MAX_SESSIONS="10"
export MCP_SESSION_TTL_MS="900000"
export MCP_REAP_INTERVAL_MS="60000"
export MCP_MAX_BODY_BYTES="1048576"
npm startBehavior in HTTP mode:
The server is single-tenant: every MCP session uses the same Fastmail token from the environment.
Stateless sessionless
POSTrequests are the default hosted path; most remote MCP clients do not need to sendmcp-session-id.ChatGPT-compatible auth is expected to happen at the infrastructure layer, not via OAuth in this server.
Do not assume ChatGPT will send arbitrary custom bearer tokens to your MCP endpoint.
Protect the endpoint with a high-entropy
MCP_PATH, and optionally add reverse-proxy controls such as IP allowlists if they fit your deployment.If a client opts into explicit stateful sessions, they are isolated in-process, expire after idle timeout, and are capped by
MCP_MAX_SESSIONS.Oversized bodies are rejected and invalid session requests return structured JSON-RPC errors.
Run via npx (GitHub)
Default to main branch:
FASTMAIL_API_TOKEN="your_token" FASTMAIL_BASE_URL="https://api.fastmail.com" \
npx --yes github:MadLlama25/fastmail-mcp fastmail-mcpWindows PowerShell:
$env:FASTMAIL_API_TOKEN="your_token"
$env:FASTMAIL_BASE_URL="https://api.fastmail.com"
npx --yes github:MadLlama25/fastmail-mcp fastmail-mcpPin to a tagged release:
FASTMAIL_API_TOKEN="your_token" \
npx --yes github:MadLlama25/fastmail-mcp@v1.7.1 fastmail-mcpInstall as a Claude Desktop Extension (DXT)
You can install this server as a Desktop Extension for Claude Desktop using the packaged .dxt file.
Build and pack:
npm run build npx @anthropic-ai/dxt packThis produces
fastmail-mcp.dxtin the project root.Install into Claude Desktop:
Open the
.dxtfile, or drag it into Claude DesktopWhen prompted:
Fastmail API Token: paste your token (stored encrypted by Claude)
Fastmail Base URL: leave blank to use
https://api.fastmail.com(default)
Use any of the tools (e.g.
get_recent_emails).
Available Tools (28 Total)
šÆ Most Popular Tools:
check_function_availability: Check what's available and get setup guidance
test_bulk_operations: Safely test bulk operations with dry-run mode
send_email: Full-featured email sending with proper draft/sent handling
advanced_search: Powerful multi-criteria email filtering
get_recent_emails: Quick access to recent emails from any mailbox, especially for prompts like "check email"
Paged email tools now return
items,total,has_more, andnext_offsetso agents can fetch more only when needed.
Email Tools
list_mailboxes: Get all mailboxes in your account
list_emails: List emails from a specific mailbox or all mailboxes
Parameters:
mailboxId(optional),limit(default: 20),offset(default: 0)
get_email: Get a specific email by ID
Parameters:
emailId(required)
send_email: Send an email (supports threading via optional
inReplyToandreferencesheaders)Parameters:
to(required array),cc(optional array),bcc(optional array),from(optional),mailboxId(optional),subject(required),textBody(optional),htmlBody(optional),inReplyTo(optional array),references(optional array)
reply_email: Reply to an existing email with proper threading headers (automatically builds In-Reply-To and References)
Parameters:
originalEmailId(required),to(optional array, defaults to original sender),cc(optional array),bcc(optional array),from(optional),textBody(optional),htmlBody(optional)
save_draft: Save an email as a draft without sending (supports threading headers for reply drafts)
Parameters:
to(required array),cc(optional array),bcc(optional array),from(optional),subject(required),textBody(optional),htmlBody(optional),inReplyTo(optional array),references(optional array)
create_draft: Create a minimal email draft (at least one of to/subject/body required)
Parameters:
to(optional array),cc(optional array),bcc(optional array),from(optional),mailboxId(optional),subject(optional),textBody(optional),htmlBody(optional)
search_emails: Search emails by content
Parameters:
query(required),limit(default: 20),offset(default: 0)
get_recent_emails: Get the most recent emails from a mailbox (inspired by JMAP-Samples top-ten)
Parameters:
limit(default: 10, max: 50),mailboxName(default: 'inbox'),offset(default: 0)
mark_email_read: Mark an email as read or unread
Parameters:
emailId(required),read(default: true)
delete_email: Delete an email (move to trash)
Parameters:
emailId(required)
move_email: Move an email to a different mailbox (replaces all mailboxes)
Parameters:
emailId(required),targetMailboxId(required)
add_labels: Add labels (mailboxes) to an email without removing existing ones
Parameters:
emailId(required),mailboxIds(required array)
remove_labels: Remove specific labels (mailboxes) from an email
Parameters:
emailId(required),mailboxIds(required array)
Advanced Email Features
get_email_attachments: Get list of attachments for an email
Parameters:
emailId(required)
download_attachment: Download an email attachment. If savePath is provided, saves the file to disk and returns the file path and size. Otherwise returns a download URL.
Parameters:
emailId(required),attachmentId(required),savePath(optional)
advanced_search: Advanced email search with multiple criteria
Parameters:
query(optional),from(optional),to(optional),subject(optional),hasAttachment(optional),isUnread(optional),mailboxId(optional),after(optional),before(optional),limit(default: 20),offset(default: 0)
get_thread: Get all emails in a conversation thread
Parameters:
threadId(required)
Email Statistics & Analytics
get_mailbox_stats: Get statistics for a mailbox (unread count, total emails, etc.)
Parameters:
mailboxId(optional, defaults to all mailboxes)
get_account_summary: Get overall account summary with statistics
Bulk Operations
bulk_mark_read: Mark multiple emails as read/unread
Parameters:
emailIds(required array),read(default: true)
bulk_move: Move multiple emails to a mailbox
Parameters:
emailIds(required array),targetMailboxId(required)
bulk_delete: Delete multiple emails (move to trash)
Parameters:
emailIds(required array)
bulk_add_labels: Add labels to multiple emails simultaneously
Parameters:
emailIds(required array),mailboxIds(required array)
bulk_remove_labels: Remove labels from multiple emails simultaneously
Parameters:
emailIds(required array),mailboxIds(required array)
Identity & Testing Tools
list_identities: List sending identities (email addresses that can be used for sending)
check_function_availability: Check which functions are available based on account permissions (includes setup guidance)
test_bulk_operations: Safely test bulk operations with dry-run mode
Parameters:
dryRun(default: true),limit(default: 3)
API Information
This server uses the JMAP (JSON Meta Application Protocol) API provided by Fastmail. JMAP is a modern, efficient alternative to IMAP for email access.
Inspired by Fastmail JMAP-Samples
Many features in this MCP server are inspired by the official Fastmail JMAP-Samples repository, including:
Recent emails retrieval (based on top-ten example)
Email management operations
Efficient chained JMAP method calls
Authentication
The server uses bearer token authentication with Fastmail's API. API tokens provide secure access without exposing your main account password.
Rate Limits
Fastmail applies rate limits to API requests. The server handles standard rate limiting, but excessive requests may be throttled.
Development
Project Structure
src/
āāā index.ts # Startup entrypoint (stdio or HTTP mode)
āāā mcp-server.ts # MCP server factory and tool handlers
āāā http-server.ts # Streamable HTTP session management and limits
āāā auth.ts # Authentication handling
āāā jmap-client.ts # JMAP client wrapper with paginated email queriesBuilding
npm run buildDevelopment Mode
npm run devLicense
MIT
Contributing
Contributions are welcome! Please ensure that:
Code follows the existing style
All functions are properly typed
Error handling is implemented
Documentation is updated for new features
Troubleshooting
Common Issues
Authentication Errors: Ensure your API token is valid and has the necessary permissions
Missing Dependencies: Run
npm installto ensure all dependencies are installedBuild Errors: Check that TypeScript compilation completes without errors using
npm run buildUnexpectedly Large Search Results: Use
limitandoffset, then follownext_offsetonly whenhas_moreis trueHTTP Session Errors: Prefer sessionless
POSTrequests first;mcp-session-idis only needed for explicit stateful-session flowsToo Many Concurrent Clients: Increase
MCP_MAX_SESSIONSor wait for idle sessions to expire if you are using explicit stateful sessions and the server returns "maximum concurrent MCP sessions reached"
Email Tools Failing with Serialization Errors?
If get_email, list_emails, search_emails, or advanced_search fail with "content serialization" or "Cannot read properties of undefined" errors, upgrade to v1.7.1+. This was caused by incomplete JMAP response validation that surfaced after the MCP SDK v1.x upgrade added stricter result checking.
Testing Your Setup
Use the built-in testing tools:
check_function_availability: See what's available and get setup help
test_bulk_operations: Safely test bulk operations without making changes
For more detailed error information, check the console output when running the server.
Privacy & Security
API tokens are stored encrypted by Claude Desktop when installed via the DXT and are never logged by this server.
The server avoids logging raw errors and sensitive data (tokens, email addresses, identities, attachment names/blobIds) in error messages.
Tool responses may include your email metadata/content by design (e.g., listing emails) but internal identifiers and credentials are not disclosed beyond what Fastmail returns for the requested data.
If you encounter errors, messages are sanitized and summarized to prevent leaking personal information.
In remote HTTP mode, this server is designed for a single shared Fastmail account, not for multi-tenant per-user isolation.
Remote HTTP mode does not implement OAuth and does not rely on custom bearer-token auth from ChatGPT; secure it with a secret path and network/proxy controls appropriate for your deployment.
Available Tools
28 toolsadd_labelsAIdempotent
Add one or more mailbox labels to an email without removing existing ones. Use when the user wants to tag or categorize a message while keeping its current mailbox membership. Do not use to relocate an email into a single destination mailbox; use move_email.
Inputs: emailId (required), mailboxIds (required).
advanced_searchARead-onlyIdempotent
Search Fastmail email with structured filters such as sender, recipient, subject, unread state, attachments, mailbox, and date range in paginated form. Use when the user asks for something like "find the latest message from Alice", "show unread invoices with attachments", or "find messages from last week". Returns items, total, has_more, and next_offset so the agent can refine or continue the search without consuming excess context. Do not use for simple inbox checks; use get_recent_emails. Do not use when you already have an emailId; use get_email.
Inputs: query, from, to, subject, +7 more.
bulk_add_labelsAIdempotent
Add labels to multiple emails in one call. Use when the user wants to categorize many specific messages at once. Do not use to relocate messages into a different mailbox; use bulk_move.
Inputs: emailIds (required), mailboxIds (required).
bulk_deleteADestructiveIdempotent
Delete multiple emails by moving them to Trash. Use when the user explicitly wants to trash a batch of specific messages. Do not use for a single message; use delete_email.
Inputs: emailIds (required).
bulk_mark_readAIdempotent
Mark multiple emails as read or unread in one call. Use when the user wants to triage a group of specific email IDs together. Do not use for one email; use mark_email_read.
Inputs: emailIds (required), read.
bulk_moveAIdempotent
Move multiple emails to a mailbox in one call. Use when the user wants to file a set of known email IDs into the same destination mailbox. Do not use to apply labels while preserving the current mailbox set; use bulk_add_labels.
Inputs: emailIds (required), targetMailboxId (required).
bulk_remove_labelsAIdempotent
Remove labels from multiple emails in one call. Use when the user wants to untag a batch of specific messages together. Do not use to delete or move email.
Inputs: emailIds (required), mailboxIds (required).
check_function_availabilityARead-onlyIdempotent
Report which Fastmail email and identity functions are currently available for this account and API token. Use when setup seems incomplete, a mail tool fails in an unexpected way, or you need a quick capability summary for the configured account. Do not use for reading email content or browsing the inbox.
Inputs: no named parameters.
create_draftA
Create a minimal draft email record without sending it. Use when the user wants a placeholder draft or partial draft state, such as saving a subject/body before the message is complete. Do not use for threaded replies or a send-ready draft reply; use save_draft or reply_email.
Inputs: to, cc, bcc, from, +4 more.
delete_emailADestructiveIdempotent
Delete one email by moving it to Trash. Use when the user explicitly wants a single message deleted or trashed. Do not use for mailbox cleanup across many messages; use bulk_delete.
Inputs: emailId (required).
download_attachmentA
Get an attachment download URL or save an attachment to disk when savePath is provided. Use when the user wants the file from a specific message attachment. Do not use when you still need to discover attachment IDs; use get_email_attachments first.
Inputs: emailId (required), attachmentId (required), savePath.
get_account_summaryARead-onlyIdempotent
Get an overall Fastmail account summary with aggregate mailbox statistics. Use when the user wants a high-level status view of the mailbox rather than raw email lists. Do not use for message content or search.
Inputs: no named parameters.
get_emailARead-onlyIdempotent
Get one specific email by ID, including full content and metadata. Use after get_recent_emails, list_emails, search_emails, or advanced_search when you need to read the body, inspect headers, or prepare a reply. Do not use for browsing or discovery; use get_recent_emails or search tools first.
Inputs: emailId (required).
get_email_attachmentsARead-onlyIdempotent
List the attachments on a specific email. Use after get_email when you need attachment IDs before downloading one. Do not use to download content directly; use download_attachment.
Inputs: emailId (required).
get_mailbox_statsARead-onlyIdempotent
Get statistics such as unread counts and total emails for a mailbox or across the account. Use when the user wants a summary of mailbox volume or unread counts rather than individual messages. Do not use for listing messages themselves.
Inputs: mailboxId.
get_recent_emailsARead-onlyIdempotent
Get the newest email summaries from a Fastmail mailbox, defaulting to Inbox, in paginated form. Use when the user says "check email", "read my inbox", "show recent emails", or asks what just arrived. Returns items, total, has_more, and next_offset so the caller can keep paging only when needed. Use mailboxName to target another mailbox. Do not use when you need full message content for a known emailId (use get_email) or when you need filtered search results (use search_emails or advanced_search).
Inputs: limit, mailboxName, offset.
get_threadARead-onlyIdempotent
Get all emails in one conversation thread. Use when the user wants the full conversation around a known thread or needs context before replying. Do not use when you only have one emailId and need the full message first; use get_email.
Inputs: threadId (required).
list_emailsARead-onlyIdempotent
List email summaries from one Fastmail mailbox or across the account in paginated form. Use when you already know the mailboxId and want to browse messages there, such as "show messages in Archive" or "list emails in Projects". Returns an object with items, total, has_more, and next_offset so the caller can continue paging without fetching everything at once. Do not use for "check email" or "read my inbox" when no mailbox is specified; use get_recent_emails instead. Do not use when you already have an emailId; use get_email.
Inputs: mailboxId, limit, offset.
list_identitiesARead-onlyIdempotent
List Fastmail sending identities that can be used in the from field. Use before send_email, save_draft, or create_draft when the user wants to send from an alias or confirm which sender addresses are allowed. Do not use for inbox or message retrieval.
Inputs: no named parameters.
list_mailboxesARead-onlyIdempotent
List the mailboxes, folders, and label IDs in the connected Fastmail account. Use when the user wants mailbox names, wants to choose a destination for moving or labeling email, or asks what folders exist. Do not use when the user wants recent messages or inbox contents; use get_recent_emails, list_emails, or search_emails instead.
Inputs: no named parameters.
mark_email_readAIdempotent
Mark one email as read or unread. Use after selecting a specific email when the user wants to clear unread state or mark something unread for later. Do not use for bulk mailbox triage; use bulk_mark_read.
Inputs: emailId (required), read.
move_emailAIdempotent
Move one email to a different Fastmail mailbox. Use when the user wants a specific message filed into another mailbox. Do not use to add extra labels while keeping the current mailbox membership; use add_labels.
Inputs: emailId (required), targetMailboxId (required).
remove_labelsAIdempotent
Remove one or more mailbox labels from an email. Use when the user wants to untag a specific message while leaving any remaining mailbox memberships alone. Do not use to move an email to Trash; use delete_email.
Inputs: emailId (required), mailboxIds (required).
reply_emailA
Reply to an existing email with Fastmail threading headers preserved automatically. Use when the user says "reply to this email", "answer the latest message from Alice", or wants a proper threaded response. Do not use for a brand-new outbound message; use send_email. Do not use when you only want to save a reply draft; use save_draft.
Inputs: originalEmailId (required), to, cc, bcc, +3 more.
save_draftA
Save an unsent draft email in Fastmail, including reply-thread headers when provided. Use when the user says "save a draft", "draft a reply", or wants a message prepared without sending it yet. Do not use for immediate delivery; use send_email. Do not use for a minimal placeholder draft with only partial fields; use create_draft.
Inputs: to (required), subject (required), cc, bcc, +5 more.
search_emailsARead-onlyIdempotent
Search Fastmail email by free-text query across subject and message content in paginated form. Use when the user wants to find email about a topic or phrase, such as "search for invoices" or "find messages about taxes". Returns items, total, has_more, and next_offset so the agent can stop after the first useful page instead of pulling a large result set. Do not use for "check email" or "show recent emails"; use get_recent_emails. Do not use when you need structured filters like sender, unread, attachments, or date range; use advanced_search.
Inputs: query (required), limit, offset.
send_emailA
Send a new outbound email from the connected Fastmail account. Use when the user says things like "send email to Alice" or wants to compose a fresh message right now. Do not use for threaded replies; use reply_email. Do not use when the user wants to save a draft instead of sending; use save_draft or create_draft.
Inputs: to (required), subject (required), cc, bcc, +6 more.
test_bulk_operationsA
Test bulk email actions against recent inbox messages, optionally as a dry run. Use only for safe operational verification of bulk email tooling. Do not use for normal user-facing mailbox tasks; use the actual bulk tools instead.
Inputs: dryRun, limit.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogā¦
TDQS
Scored across 28 tools
Each tool has a clearly distinct purpose. Descriptions explicitly clarify when to use which tool, differentiating similar operations like single vs. bulk actions, search vs. retrieval, and draft creation vs. saving vs. sending.
All tool names follow a consistent verb_noun pattern in lower_snake_case (e.g., add_labels, bulk_delete, get_email). The use of prefixes like 'bulk_' and 'get_' is uniform, making the pattern predictable.
With 28 tools, the server covers a broad range of email operations comprehensively. While slightly on the higher side, each tool serves a specific function, and the count is justified by the domain's complexity without being excessive.
The tool set provides full lifecycle coverage for email management: send, receive, search, draft, reply, label, move, delete, thread view, attachments, mailbox management, and account info. No obvious gaps for standard email tasks.
Related MCP Connectors
Private, EU-hosted email for AI agents over JMAP: read, search, reply, draft, organize, send.
Email inboxes and calendars for AI agents: send, receive, search, draft and schedule.
Email inboxes and calendars for AI agents: send, receive, search, draft and schedule.
Email for AI agents: read, search and send from your Gmail, Outlook, Yahoo, iCloud or IMAP inbox.
Related MCP Servers
- AlicenseBqualityCmaintenanceEnables AI assistants to interact with Fastmail email, contacts, and calendars through JMAP API, supporting operations like sending emails, managing attachments, searching conversations, and organizing events.52131MIT
- AlicenseAqualityDmaintenanceEnables AI assistants to manage Fastmail email accounts via JMAP, including reading, sending, organizing emails, and handling mailboxes, drafts, and masked emails.43MIT
- FlicenseNot gradedqualityAmaintenanceEnables AI assistants to read, search, send, and organize email, manage contacts, and handle calendar events through Fastmail's JMAP, CalDAV, and WebDAV APIs, including attachments, drafts, labels, and account identities. It also supports setup checks and bulk operations for mailbox workflows.-
- AlicenseNot gradedqualityAmaintenanceEnables AI assistants to manage email, contacts, and calendar data through Fastmail's JMAP/CalDAV APIs, including sending, searching, threading, attachments, labels, drafts, and bulk operations.MIT