Apple Mail MCP Server
An MCP server that gives AI assistants full access to Apple Mail on macOS for reading, searching, composing, organizing, and analyzing email via natural language.
Read & search: inbox overview, list emails/accounts/addresses/mailboxes, unread counts, unified search by sender, subject, body, dates, attachments, flags/colors, read individual messages, view threads, and retrieve raw RFC 822 source.
Organize: create nested mailboxes, move/archive emails, mark read/unread, flag/unflag with colors, manage trash with dry-run, and force account synchronization.
Compose & send: send plain-text or HTML emails with attachments/CC/BCC, reply or reply-all, forward, manage drafts, and create rich HTML
.emldrafts.Attachments: list and save email attachments to disk.
Smart inbox: find sent emails awaiting replies, identify emails likely needing a response, and analyze top senders.
Analytics & export: email statistics, export single emails or mailboxes to TXT/HTML, and an interactive dashboard for compatible clients.
Safety & configuration: read-only mode, conservative batch-operation limits, protected file-location rules, optional user preferences, and restricted write/attachment directories.
Provides comprehensive integration with Apple Mail, enabling AI assistants to read, search, organize, compose, and manage emails directly through natural language commands. Supports advanced email operations including threading, attachment handling, folder management, and email analytics.
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., "@Apple Mail MCP Server find emails from John about the Alpha project"
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.
Apple Mail MCP Server
Star History
An MCP server that gives AI assistants full access to Apple Mail -- read, search, compose, organize, and analyze emails via natural language. Built with FastMCP.
Related MCP server: apple-mail-mcp
Quick Install
Prerequisites: macOS with Apple Mail configured, Python 3.10+, and uv (the plugin and uvx installs launch the server with uvx)
Claude Code Plugin (Recommended)
Two commands — gets you the MCP server, /email-management slash command, and the Email Management Expert skill:
claude plugin marketplace add patrickfreyer/apple-mail-mcp
claude plugin install apple-mail@apple-mail-mcpThen restart Claude Code.
Other Install Methods
claude mcp add apple-mail -- uvx mcp-apple-mailOr for Claude Desktop (~/Library/Application Support/Claude/claude_desktop_config.json):
{
"mcpServers": {
"apple-mail": {
"command": "uvx",
"args": ["mcp-apple-mail"]
}
}
}pip install mcp-apple-mail
claude mcp add apple-mail -- mcp-apple-mailInstalls the Email Management Expert skill via the open skills CLI. The skill does not include the MCP server, so install that too (e.g. with uvx above):
npx skills add patrickfreyer/apple-mail-mcp
claude mcp add apple-mail -- uvx mcp-apple-mailAdd -g to install the skill globally, or -a <agent> to target a specific agent.
Download the latest
apple-mail-mcp-vX.Y.Z.mcpbfrom ReleasesOpen Claude Desktop → Settings → Developer → MCP Servers → Install from file
Select the
.mcpbfile and grant Mail.app permissions
git clone https://github.com/patrickfreyer/apple-mail-mcp.git
cd apple-mail-mcp/plugin
python3 -m venv venv
venv/bin/pip install -r requirements.txt
claude mcp add apple-mail -- /bin/bash $(pwd)/start_mcp.shTools (28)
Reading & Search
Tool | Description |
| Dashboard with unread counts, folders, and recent emails |
| List emails with account/read-status filtering and optional content preview |
| Unread counts per mailbox or per-account summary |
| List all configured Mail accounts |
| Email addresses configured for each account |
| Unified search — subject, sender, body text, dates, attachments, flag status/color, cross-account |
| Read one message by numeric id — headers, capped plain-text body and attachment metadata (text or JSON) |
| Conversation thread view |
| Raw RFC 822 source of one message (headers, MIME parts) |
Organization
Tool | Description |
| Folder hierarchy with message counts |
| Create new mailboxes (supports nested paths) |
| Move/archive emails with filters (subject, sender, date, read status, dry-run) |
| Mark read/unread, flag/unflag (optional flag color) — by filters or message IDs |
| Soft delete, permanent delete, empty trash (with dry-run) |
| Ask Mail.app to check the server for new mail now |
Composition
Tool | Description |
| Send new emails (plain text or HTML body) |
| Reply or reply-all with optional HTML body |
| Forward with optional message, CC/BCC |
| Create, list, send, and delete drafts |
| Export an unsent HTML |
Attachments
Tool | Description |
| List attachments with names and sizes |
| Save attachments to disk |
Smart Inbox
Tool | Description |
| Find sent emails that haven't received a reply |
| Identify emails that likely need your response |
| Analyse most frequent senders by count or domain |
Analytics & Export
Tool | Description |
| Email analytics (volume, top senders, read ratios) |
| Export single emails or mailboxes to TXT/HTML |
| Interactive UI dashboard (requires mcp-ui-server) |
Configuration
Read-Only Mode
Pass --read-only to block delivery. Nothing leaves the machine: compose_email and reply_to_email refuse mode="send", manage_drafts refuses action="send", and forward_email is removed entirely because it has no non-sending mode.
The composing tools stay registered so that mode="draft" and mode="open" keep working. Those never deliver anything, and they are the only place in the compose surface that supports attachments — manage_drafts and create_rich_email_draft cannot attach files.
{
"mcpServers": {
"apple-mail": {
"command": "/path/to/venv/bin/python3",
"args": ["/path/to/apple_mail_mcp.py", "--read-only"]
}
}
}User Preferences (Optional)
Set the USER_EMAIL_PREFERENCES environment variable to give the assistant context about your workflow:
{
"mcpServers": {
"apple-mail": {
"command": "/path/to/venv/bin/python3",
"args": ["/path/to/apple_mail_mcp.py"],
"env": {
"USER_EMAIL_PREFERENCES": "Default to BCG account, show max 50 emails, prefer Archive and Projects folders"
}
}
}
}For .mcpb installs, configure this in Claude Desktop under Developer > MCP Servers > Apple Mail MCP.
Safety Limits
Batch operations have conservative defaults to prevent accidental bulk actions:
Operation | Default Limit |
| 10 emails |
| 5 emails |
| 1 email |
Override via function parameters when needed.
File Access
By default the server can write and attach files anywhere your user account can, except a hardened denylist of locations an attacker could use for code execution or credential theft. (Attachment bytes come from whoever emailed you, and a prompt-injected email can steer tool arguments.)
Writes (save_email_attachment, export_emails, create_rich_email_draft's output_path) are refused for:
any dotfile or dot-folder directly in your home folder: shell startup files (
~/.zshrc,~/.zshenv,~/.zprofile,~/.zlogin,~/.bashrc,~/.bash_profile,~/.profile),~/.ssh,~/.gnupg,~/.aws,~/.config(incl.~/.config/git),~/.gitconfig,~/.netrc,~/.envrc,~/.local/bin, ....git/hooks,.git/configand.envrcin any folderautostart, persistence and app-config folders:
~/Library/LaunchAgents,~/Library/LaunchDaemons,/Library/LaunchAgents,/Library/LaunchDaemons,~/Library/Application Support(incl.com.apple.backgroundtaskmanagementagent),~/Library/Application Scripts,~/Library/Preferences,~/Library/Keychains,~/Library/Mail,~/Library/Containers, ...folders on
PATH:~/bin,/usr/local/bin,/opt/homebrew/bin, and/etc
Attachments (compose_email, reply_to_email, ...) may be any readable file except secrets: ~/.ssh, ~/.gnupg, ~/.aws, ~/.netrc, ~/.git-credentials, ~/.config/gh, .env files, ~/Library/Keychains, and browser profiles and cookie stores (Safari, Chrome, Firefox, Edge, Brave, Arc, ...).
Paths are resolved (~, .., symlinks) before checking, and matching is case-insensitive like APFS.
Restricting further (opt-in). To confine writes or attachments to specific folders, list them (colon-separated) in the server's env, or pass --write-dir / --attach-dir (repeatable) as arguments. Once set, only those folders are allowed for that side, and the denylist still applies inside them. The tool's own cache (~/Library/Caches/apple-mail-mcp, the default rich-draft location) stays writable.
"env": {
"APPLE_MAIL_MCP_WRITE_DIRS": "~/Downloads:~/Documents/mail-exports",
"APPLE_MAIL_MCP_ATTACH_DIRS": "~/Documents:~/Desktop"
}Usage Examples
Show me an overview of my inbox
Search for emails about "project update" in my Gmail
Reply to the email about "Domain name" with "Thanks for the update!"
Move emails with "invoice" in the subject to my Archive folder
Show me email statistics for the last 30 days
Create a rich HTML draft for a weekly update and open it in MailRich HTML Drafts
Use create_rich_email_draft when you need a visually formatted email, newsletter, or leadership update.
It generates an unsent
.emlfile with multipart plain-text + HTML bodiesIt can open the draft directly in Mail for editing
It can optionally ask Mail to save the opened compose window into Drafts
It accepts partial details, so you can start with just an account and subject and fill in the rest later
This is more reliable than injecting raw HTML into AppleScript content, which Mail often stores as literal markup.
Email Management Skill
A companion Claude Code Skill is included that teaches Claude expert email workflows (Inbox Zero, daily triage, folder organization). When installed as a plugin, the skill is loaded automatically. For standalone MCP installs, add it with npx skills add patrickfreyer/apple-mail-mcp or copy it manually:
cp -r plugin/skills/email-management ~/.claude/skills/email-managementRequirements
macOS with Apple Mail configured
Python 3.10+ and uv for the plugin / uvx installs
fastmcp(+ optionalmcp-ui-serverfor dashboard)Claude Desktop or any MCP-compatible client
Mail.app permissions: Automation + Mail Data Access (grant in System Settings > Privacy & Security > Automation)
Troubleshooting
Issue | Fix |
Mail.app not responding | Ensure Mail.app is running; check Automation permissions in System Settings |
Slow searches | Set |
Mailbox not found | Use exact folder names; nested folders use |
Permission errors | Grant access in System Settings > Privacy & Security > Automation |
Rich draft shows raw HTML | Use |
Project Structure
apple-mail-mcp/
├── .claude-plugin/
│ └── marketplace.json # Marketplace manifest (for plugin distribution)
├── plugin/ # Claude Code plugin
│ ├── .claude-plugin/
│ │ └── plugin.json # Plugin manifest
│ ├── skills/ # Email Management Expert skill (also invocable as /email-management)
│ ├── apple_mail_mcp/ # Python MCP server package (28 tools)
│ ├── apple_mail_mcp.py # Entry point
│ ├── start_mcp.sh # Startup wrapper for the .mcpb bundle and local clones (auto-creates venv)
│ └── requirements.txt
├── apple-mail-mcpb/ # MCPB build files (Claude Desktop)
├── LICENSE
└── README.mdContributing
Fork the repository
Create a feature branch (
git checkout -b feature/my-feature)Commit and push
Open a Pull Request
Releasing
Follow these steps when cutting a new release to keep all version strings in sync:
Bump
__version__inplugin/apple_mail_mcp/__init__.pyto the new version.Update
apple-mail-mcpb/manifest.json("version"field) to match.Update
pyproject.toml(version = ...under[project]) to match.Update both version fields in
server.json("version"and"packages"[0]["version"]) to match.Run
python3 scripts/check_versions.py— it must print OK before you proceed.Commit, tag, and push:
git tag vX.Y.Z && git push origin vX.Y.Z.Create a GitHub release from the tag.
Build and publish to PyPI:
python -m build && twine upload dist/*(requires PyPI credentials).
The test suite also enforces version consistency (
tests/test_version_consistency.py), so any CI run on a branch with mismatched versions will fail fast.
Privacy Policy
The server runs entirely on your Mac, makes no network requests of its own and collects nothing. It reads Mail.app data only when a tool asks, returns it to your MCP client, and sends email only when you ask a sending tool to. Installing through the plugin downloads the pinned mcp-apple-mail package from PyPI with uvx. Full policy: PRIVACY.md.
License
MIT -- see LICENSE.
Links
Available Tools
28 toolscompose_emailCompose EmailC
Compose and send a new email from a specific account.
Inputs: to (required), body (required), account (required), subject (required), +6 more. Returns: result
create_mailboxCreate MailboxA
Create a new mailbox (folder) in the specified account.
Supports nested paths via the parent_mailbox parameter (e.g., parent_mailbox="Projects" + name="2024" creates Projects/2024). You can also pass a full slash-separated path as name (e.g., "Projects/2024/ClientName") and omit parent_mailbox.
Inputs: name (required), account (required), parent_mailbox. Returns: result
create_rich_email_draftCreate Rich Email DraftA
Create a rich-text email draft by generating an unsent .eml message and optionally opening it in Mail.
This is the preferred path for HTML or richly formatted emails because Mail reliably renders .eml
content, while setting raw HTML through AppleScript often stores the literal markup instead.
Inputs: account (required), cc, to, bcc, +7 more. Returns: result
export_emailsExport EmailsC
Export emails to files for backup or analysis.
Inputs: scope (required), account (required), format, mailbox, +3 more. Returns: result
forward_emailForward EmailC
Forward an email to one or more recipients.
Inputs: to (required), account (required), subject_keyword (required), cc, +4 more. Returns: result
get_awaiting_replyGet Awaiting ReplyA
Find sent emails that haven't received a reply yet.
Scans the Sent mailbox for outgoing emails and cross-references with the Inbox to see if a reply (matching subject) was received from the same recipient. Useful for follow-up tracking.
Inputs: account (required), days_back, max_results, exclude_noreply. Returns: result
get_email_sourceGet Email SourceA
Return the raw RFC 822 source of a single message.
The MCP's other body-extraction paths return Mail.app's rendered content (HTML collapsed to display text, hrefs dropped, embedded objects replaced with U+FFFC). This tool returns the raw source instead — all headers, all MIME parts, all hrefs intact.
Implementation note:
Wraps the source property of message defined in Mail.sdef
(the AppleScript dictionary for Mail.app). That property returns the
same RFC 822 text Mail.app writes to the on-disk .partial.emlx file,
so the consumer does not need filesystem access or knowledge of the
Mail directory layout to recover MIME parts / hrefs / custom headers.
Identifier resolution: message_id is preferred when both are provided
(exact match on the RFC 822 Message-Id header via AppleScript's
message id property — distinct from id, which is Mail.app's
internal numeric id). subject_keyword matches the first message in
mailbox whose subject contains the substring.
Output sizing: messages can be large (a plain note is ~200 KB; with
attachments far larger). max_bytes caps the returned payload and
appends a truncation marker when exceeded. headers_only=True returns
only the RFC 822 header block (everything up to and including the first
blank line) — usually sufficient for URL/header inspection and avoids
returning base64 bodies. Cap applies after the headers_only filter.
Inputs: account (required), mailbox, max_bytes, message_id, +2 more. Returns: result
get_email_threadGet Email ThreadA
Get an email conversation thread - messages linked by Message-ID, not just by subject.
Candidates are found by subject (fast, filtered inside Mail), then linked through their Message-ID / In-Reply-To / References headers. Messages that merely share the subject but belong to a different conversation are listed separately instead of being mixed into the thread.
Inputs: account (required), subject_keyword (required), mailbox, max_messages. Returns: result
get_inbox_overviewGet Inbox OverviewB
Get a comprehensive overview of your email inbox status across all accounts.
Inputs: no named parameters. Returns: result
get_mailbox_unread_countsGet Mailbox Unread CountsA
Get unread counts per mailbox for one account or all accounts.
When summary_only=True, returns only per-account inbox unread totals (replaces the former get_unread_count tool).
Inputs: account, include_zero, summary_only. Returns: object
get_needs_responseGet Needs ResponseA
Identify unread emails that likely need a response from you.
Filters out newsletters, automated emails, and noreply senders. Prioritises direct emails (To: you) with question marks as likely needing a reply.
Inputs: account (required), mailbox, days_back, max_results. Returns: result
get_statisticsGet StatisticsC
Get comprehensive email statistics and analytics.
Inputs: account (required), scope, sender, mailbox, +1 more. Returns: result
get_top_sendersGet Top SendersB
Analyse a mailbox to find the most frequent senders.
Useful for identifying key contacts, high-volume senders to filter, or newsletter sources to unsubscribe from.
Inputs: account (required), top_n, mailbox, days_back, +1 more. Returns: result
inbox_dashboardInbox DashboardA
Get an interactive dashboard view of your email inbox.
Returns an interactive UI dashboard resource that displays:
Unread email counts by account (visual cards with badges)
Recent emails across all accounts (filterable list)
Quick action buttons for common operations (Mark Read, Archive, Delete)
Search functionality to filter emails
This tool returns a UIResource that can be rendered by compatible MCP clients (like Claude Desktop with MCP Apps support) to provide an interactive dashboard experience.
Note: Requires mcp-ui-server package and a compatible MCP client.
Inputs: no named parameters.
list_account_addressesList Account AddressesA
List all configured email addresses for each Mail account.
Useful for mapping a Mail.app account name (e.g. "Gmail", "Work") to the actual email address(es) it receives mail at — handy when an integration needs to know which inbox a message landed in by address rather than by Mail.app's display name.
Inputs: no named parameters. Returns: object
list_accountsList AccountsB
List all available Mail accounts.
Inputs: no named parameters. Returns: result
list_email_attachmentsList Email AttachmentsC
List attachments for emails matching a subject keyword.
Inputs: account (required), mailbox, message_id, max_results, +1 more. Returns: result
list_inbox_emailsList Inbox EmailsA
List all emails from inbox across all accounts or a specific account.
Replaces the former get_recent_emails tool — use account + max_emails to get recent emails from a single account.
Inputs: account, max_emails, include_read, output_format, +1 more. Returns: result
list_mailboxesList MailboxesA
List all mailboxes (folders) for a specific account or all accounts.
Inputs: account, include_counts. Returns: result
manage_draftsManage DraftsB
Manage draft emails - list, create, send, open, or delete drafts.
Inputs: action (required), account (required), cc, to, +5 more. Returns: result
manage_trashManage TrashA
Manage trash operations - delete emails or empty trash.
When dry_run=True (default) and action is "move_to_trash", previews what would be deleted without acting. Set dry_run=False to actually move to trash.
Mail's AppleScript interface has no command that erases a message: delete
means "move to Trash", and on a message that already sits in Trash it does
nothing. "delete_permanent" and "empty_trash" therefore usually remove
nothing at all. Both report the real before/after mailbox count instead of
the number of delete calls, and say so when nothing was removed; emptying
the trash for good has to happen in Mail itself.
Inputs: action (required), account (required), sender, dry_run, +7 more. Returns: result
move_emailMove EmailA
Move email(s) matching filters from one mailbox to another.
Supports subject, sender, and date filters. Use dry_run=True to preview matches without moving. Set only_read=True to skip unread emails (useful for archiving). For archiving to "Archive", just set to_mailbox="Archive". Pass message_ids to move specific messages by exact id (ignores other filters; same fast path as update_email_status).
Inputs: account (required), to_mailbox (required), sender, dry_run, +7 more. Returns: result
read_emailRead EmailA
Read headers, plain-text body and attachment metadata for one message.
Use the numeric message_id returned by search_emails, not the RFC Message-ID header. The lookup never scans messages. max_chars caps only the body, with explicit truncation metadata. output_format is text or json. Attachment contents are never returned.
Inputs: account (required), message_id (required), mailbox, max_chars, +1 more. Returns: result
reply_to_emailReply To EmailC
Reply to an email matching a subject keyword.
Inputs: account (required), reply_body (required), subject_keyword (required), cc, +7 more. Returns: result
save_email_attachmentSave Email AttachmentC
Save a specific attachment from an email to disk.
Inputs: account (required), mailbox, save_path, message_id, +2 more. Returns: result
search_emailsSearch EmailsA
Unified search tool with JSON output, pagination, and real date filtering.
Consolidates subject search, sender search, body content search, and cross-account search into a single tool.
Inputs: sort, limit, offset, sender, +15 more. Returns: result
synchronize_accountSynchronize AccountA
Force Mail.app to synchronize an account (or every account) with its IMAP / Exchange server right now. Equivalent to clicking the refresh button next to the account or selecting Mailbox → Synchronize.
Use after move_email, update_email_status, or manage_trash
when downstream clients (iPhone, web mail, etc.) need to see the
change immediately. Mail.app's natural sync cadence is "automatic"
which can be several minutes — this collapses that to one IMAP push.
Implementation note:
Uses the synchronize with <account> AppleScript verb (per Mail.sdef:
"Command to trigger synchronizing of an IMAP account with the server")
rather than check for new mail. The latter is receive-only — it
pulls new messages but does NOT push pending IMAP commands like
queued moves / archives / flag changes. With check for new mail,
archives done via move_email could sit in Mail.app's local cache
for several minutes before reaching the IMAP server, leaving iPhone
Mail (which reads IMAP directly) showing already-archived messages
still in INBOX. synchronize with is the bidirectional verb that
drains pending IMAP commands AND fetches new mail.
Mail.app's synchronize is potentially long-running. We wrap each
invocation in with timeout of N seconds so the AppleScript returns
promptly. When the timeout fires (error -1712) Mail.app keeps the
sync running in the background — exactly the fire-and-forget
semantics callers expect.
Inputs: account. Returns: result
update_email_statusUpdate Email StatusA
Update email status - mark as read/unread or flag/unflag emails.
When message_ids is provided, uses exact ID matching (ignores other filters). Otherwise filters by subject, sender, and/or age.
Inputs: action (required), account (required), sender, mailbox, +7 more. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 28 tools
Most tools have distinct purposes, but several overlap: get_inbox_overview, get_statistics, inbox_dashboard, and get_mailbox_unread_counts all surface inbox-level summaries, and get_awaiting_reply vs get_needs_response are easy to confuse at a glance. read_email vs get_email_source and search_emails vs list_inbox_emails are clarified by descriptions but still require careful reading. The boundaries exist but are not crisp.
Nearly all tools follow a consistent verb_noun snake_case pattern (get_, list_, update_, create_, move_, manage_, forward_, reply_, synchronize_). The main deviations are inbox_dashboard (noun-only, no verb) and the manage_* umbrella verbs, but overall it reads predictably.
At 28 tools this is heavy for a single email domain, with several near-redundant analytics/overview tools pushing the count up. Many could be consolidated (e.g. the three inbox-summary tools, the two reply-tracking tools) without losing capability.
The surface covers the full email lifecycle: read/search/list, compose/reply/forward, drafts, attachments, mailbox management, moves, trash, account sync, plus analytics and export. No obvious dead ends remain for an agent working with Apple Mail.
Maintenance
Related MCP Connectors
Connect Gmail, iCloud Mail, Outlook, Yahoo Mail, Fastmail and other IMAP inboxes to ChatGPT, Claude and compatible AI assistants. Find emails by meaning across languages with semantic search. Ask AI to find customer conversations, summarize deadlines and draft follow-ups. Give a sales rep access to a shared outreach inbox or bring email into a compatible CRM. Share an iCloud custom-domain inbox with teammates without their own Apple ID or iCloud+ plan. Search results may be incomplete or stale; separate permissions control mail actions.
Email for AI agents: read, search and send from your Gmail, Outlook, Yahoo, iCloud or IMAP inbox.
Connect any mailbox to Claude, ChatGPT & AI: read, send, reply, schedule & search emails.
Your mailboxes in ChatGPT and Claude: Gmail, iCloud, Fastmail, any IMAP. Passwords stay yours.
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables AI assistants to read, search, compose, and send emails by connecting to any IMAP/SMTP provider. It supports comprehensive mailbox management, including draft handling and message deletion, directly through natural language.10233 npm11MIT
- AlicenseAqualityBmaintenanceEnables AI assistants to read, send, search, and manage emails in Apple Mail on macOS.2559 PyPI105MIT
- AlicenseAqualityBmaintenanceEnables AI assistants to read, search, send, and manage email on macOS through programmatic access to Apple Mail.29MIT
- AlicenseNot gradedqualityBmaintenanceEnables AI assistants to read, search, and manage email via IMAP, and send emails with attachments via SMTP, using natural language commands.1,767 npmMIT