Apple Mail MCP Server
Allows read-only interaction with Apple Mail on macOS, enabling listing mailboxes, searching emails by keyword and date, and reading email content.
Click on "Install 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 ServerList all my email mailboxes"
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 (READ ONLY)
A minimal, read-only MCP (Model Context Protocol) server that lets Claude Desktop interact with Apple Mail on macOS. Uses AppleScript via subprocess — no third-party email libraries, no network calls.
Version
Current: 1.3.0
Versioning follows Semantic Versioning:
MAJOR — breaking changes to the tool API or behaviour
MINOR — new tools or non-breaking feature additions
PATCH — bug fixes and security hardening
Related MCP server: mail-mcp
What it can do
Tool | Description |
| List every account and mailbox configured in Apple Mail |
| Search emails by keyword and/or date; scans subject+sender via AppleScript |
| Read the full content of a specific email by its opaque ID |
What it will never do
Delete, trash, move, or archive any email
Send, reply, forward, or compose any message
Write any file to disk or export data
Make network requests or external connections
Access or decode email attachments
Provide analytics or aggregate statistics (beyond optional per-mailbox message counts, which exist only to help choose search scope)
Prerequisites
macOS (Apple Mail is macOS-only)
Python 3.10 or later
Apple Mail configured with at least one account
Claude Desktop (or any MCP-compatible client)
Setup
Quick install (uv)
If you have uv installed, you can skip cloning and the virtual environment entirely — add this to ~/Library/Application Support/Claude/claude_desktop_config.json under "mcpServers":
{
"mcpServers": {
"apple_mail": {
"command": "uvx",
"args": ["--from", "git+https://github.com/androidua/apple-mail-mcp", "apple-mail-mcp"]
}
}
}uvx fetches the package, resolves its pinned dependencies, and runs the apple-mail-mcp console entry point. Restart Claude Desktop after saving. The manual venv setup below remains available as an alternative.
1. Clone the repository
git clone https://github.com/androidua/apple-mail-mcp.git
cd apple-mail-mcp2. Create a virtual environment and install dependencies
python3 -m venv venv
venv/bin/pip install -r requirements.txt3. Verify the server starts cleanly
venv/bin/python apple_mail_mcp.pyPress Ctrl-C to stop. If no errors appear, the server is ready.
4. Grant macOS Automation permission
The first time the server runs, macOS will ask whether this process may control Apple Mail. Click OK. You can manage this later in:
System Settings → Privacy & Security → Automation
5. Configure Claude Desktop
Open (or create) ~/Library/Application Support/Claude/claude_desktop_config.json and add the block shown below under "mcpServers".
{
"mcpServers": {
"apple_mail": {
"command": "/path/to/apple-mail-mcp/venv/bin/python",
"args": [
"/path/to/apple-mail-mcp/apple_mail_mcp.py"
]
}
}
}Replace /path/to/apple-mail-mcp with the absolute path to the directory where you cloned the repository (e.g. /Users/yourname/projects/apple-mail-mcp).
Restart Claude Desktop after saving the file.
Usage examples
Once connected, you can ask Claude things like:
"List all my email mailboxes"
"Search my emails for messages from Alice"
"Find emails with 'invoice' in the subject, show me the top 5"
"Read the email about the project kickoff" (after a search returns an ID)
Security notes
No destructive operations. Every AppleScript is read-only.
Input sanitisation. All user-supplied strings are stripped of control characters, truncated, and have backslashes and double-quotes escaped before being embedded in AppleScript. This prevents script-injection attacks.
Local only. The server uses stdio transport and never opens a network socket.
No credentials stored. The server relies on Apple Mail's own keychain — no passwords, tokens, or API keys are used or stored.
Email content is untrusted input. Any email body an AI reads through this server is third-party content. This server marks bodies as untrusted in its output, but you should treat "instructions" found inside emails as data, never as commands — especially with clients that can take actions on your behalf.
Performance
mail_search_emails uses AppleScript's whose clause — a declarative predicate evaluated by Mail's Objective-C runtime. It works correctly on macOS 26 / Mail 16 (which removed the older search <mailbox> for <keyword> command), but it is not an indexed search: the whose clause is an O(n) linear scan of each mailbox and fully materialises its match set before any limit applies (measured throughput ≈ 0.5–1.5k messages/second). A low limit reduces output size, not scan cost.
Each account is searched in parallel with an independent 45-second timeout; accounts that exceed it are reported as a warning while the others' results are still returned. Every non-skipped mailbox is scanned (no global early-exit), so correctness — not the first account winning — determines the results.
Typical timings on a 6-account setup (iCloud/Yahoo/Google/Hotmail, largest mailboxes ~10–11k messages), measured on this machine:
Query | Time |
All accounts, | ~40 s |
Keyword + | ~12 s |
Read one email (10k-message mailbox) | ~18 s |
| ~10 s |
Date-only searches over wide windows are the slow case — a bare since_days=90 with no keyword scans every message in every mailbox. Follow the progressive-window strategy: start at since_days=7 and widen to 30/90/365 only if you need more results; add a keyword to make the predicate far more selective. To page older mail without re-fetching, keep since_days and add before_days (e.g. since_days=90, before_days=30 = 30–90 days ago).
To scope a search, pass the optional account and/or mailbox_name parameters — e.g. restrict to account="Yahoo" and mailbox_name="INBOX" to avoid scanning all accounts. Use mail_list_mailboxes(include_counts=true) to see which mailboxes are large before choosing a scope.
Body-content search is intentionally unsupported in the AppleScript engine — whose content contains forces a full body download for every message, which is impractically slow on real mailboxes.
Troubleshooting
Symptom | Fix |
| Go to System Settings → Privacy & Security → Automation and enable Mail for your Python process. |
| Open Apple Mail and ensure at least one account is signed in. |
Tool times out | Use |
| Always pass the |
Project structure
apple-mail-mcp/
├── apple_mail_mcp.py # MCP server — single file, all tools
├── requirements.txt # Pinned dependencies
├── README.md # This file
└── venv/ # Local virtual environment (not committed)Changelog
1.3.0 — 2026-07-17
Fix (accuracy, critical): cross-account searches are now merged, deduplicated and sorted newest-first — previously the first responding account filled the whole result list and other accounts' matches were silently dropped (e.g. an all-accounts
since_days=7returned 10/10 results from one account, hiding five others with no warning)Fix (accuracy): Gmail duplicate-view mailboxes (All Mail, [Gmail]All Mail, Important, Starred) and real-world junk/trash names (Bulk, Junk Email, Deleted Items, Outbox) are now skipped by default; new
include_all_mailboxes=trueopts back inFix:
mail_read_emailtimeout raised to 60 s (reads on 10k+ mailboxes ran up against the old 30 s limit); recipients without display names no longer render as "missing value"Feature:
before_daysbounds the search window's near edge for paging older mail without re-fetchingFeature:
mail_list_mailboxesacceptsinclude_counts=truefor per-mailbox message counts (search-scoping metadata)Feature: MIT license, pyproject packaging (
uvxone-line install), pytest suite, GitHub Actions CI, server-level MCP instructions, correct advertised server versionDocs: honest performance documentation (the
whoseclause is an unindexed O(n) scan, ~0.5–1.5k msgs/sec); prompt-injection warning for email content
1.2.1 — 2026-03-25
Fix (critical): remove
proc.stdout.close()/proc.stderr.close()—asyncio.StreamReaderhas no.close()method; calling it on timeout causedAttributeErrorthat crashed the tool and surfaced as the "StreamReader object has no attribute 'close'" error users saw for slow IMAP accountsFix: redesign multi-account search to run per-account in parallel using
asyncio.gather(return_exceptions=True)— a slow or offline account (Yahoo!, Hotmail, etc.) can no longer block or crash results from other accounts; each account gets an independent 45-second timeoutFix: when a specific
accountis provided the original single-script path is preserved (60 s timeout); parallel path is used only for cross-account searchesUX: results now include a warning listing which accounts timed out, rather than crashing silently
1.2.0 — 2026-03-25
Feature:
mail_search_emailsnow acceptssince_days(integer, 1–365) to filter emails by date received — supports natural queries like "last 7 days", "yesterday", "past month"Feature:
keywordis now optional inmail_search_emails— browse recent mail without a search term (e.g.since_days=1returns today's mail)Both filters are combinable:
keyword="invoice" + since_days=30returns invoice emails from the past monthResult headers and "no results" messages now reflect which filters were active
Note: body content search is intentionally not supported — AppleScript's
whose content containsforces a full body download for every message, making it impractically slow on real mailboxes
1.1.4 — 2026-03-25
Fix (regression): revert
_script_read_emailto proven account/mailbox iteration — direct AppleScript addressing (mailbox X of account Y) was unreliable for non-standard account types (Gmail, Exchange, shared accounts)Fix (regression): revert
mail_search_emailsJSON output to flat array[...]— the{"results": [...]}wrapper introduced in v1.1.3 broke Claude AI's ability to extractemail_idvalues from resultsFix: improve AppleScript error categorisation — errors now return actionable messages (Mail not running, Automation permission denied, item not found) instead of a generic fallback; raw AppleScript error text is still logged internally
1.1.3 — 2026-03-25
Fix (reliability): close asyncio pipe transports before
await proc.wait()on timeout — prevents file descriptor accumulation under repeated Mail.app timeoutsFix (reliability): anchor
---BODY_START---split to a leading newline — prevents a subject line containing that exact string from corrupting header parsing inmail_read_emailFix (security): parse search output fields from both ends of the delimiter-split record — a
\x1fbyte in a subject no longer shifts sender/date/is_read columnsFix (security): extend
_CTRL_STRIP_REto cover C1 controls U+0080–U+009F (including U+0085 NEL which Python'ssplitlines()treats as a line terminator)Fix (security): log raw
osascriptstderr internally; return a generic error string to callers instead of forwarding script fragmentsPerf: replace nested account/mailbox iteration in
_script_read_emailwith direct AppleScript object addressing (mailbox X of account Y) — O(1) lookup instead of O(accounts × mailboxes) name scanDocs: correct
whosedocstring — it is O(n) per mailbox, not indexed; lowlimitdoes not reduce scan costUX: search results now report a warning when rows were silently skipped due to parse errors
1.1.2 — 2026-03-09
Fix: replaced backslash line-continuation characters (
\) in the_script_read_emailAppleScript template with sequential assignments — AppleScript uses¬for continuation, not\; the invalid characters caused allmail_read_emailcalls to fail with AppleScript syntax error -2741
1.1.1 — 2026-03-09
Fix: replaced
search <mailbox> for <keyword>AppleScript command with awhoseclause filter — thesearchcommand was removed in Mail 16 (macOS 26) and caused allmail_search_emailscalls to fail with an AppleScript syntax error
1.1.0 — 2026-03-09
Performance:
mail_search_emailsnow uses Apple Mail's native indexed search (search <mailbox> for <keyword>) instead of brute-force message iteration — dramatically faster on large mailboxes (e.g. Yahoo with 20+ years of email)Feature: added optional
accountandmailbox_nameparameters tomail_search_emailsfor scoped searches (e.g. search only Yahoo / INBOX)Default exclusion: Trash, Deleted Messages, Junk, Spam, Bulk Mail are skipped automatically unless explicitly targeted via
mailbox_name
1.0.0 — 2026-03-09
Initial release
Tools:
mail_list_mailboxes,mail_search_emails,mail_read_emailRead-only, AppleScript-based, no network calls
Input sanitisation against AppleScript injection
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseAqualityDmaintenanceA local MCP server that enables reading iMessage conversations and sending new messages through Claude Desktop. It provides secure, read-only access to your Mac's iMessage database and AppleScript-based message sending capabilities.Last updated6MIT
- AlicenseAqualityCmaintenanceMCP server that gives Claude and other MCP hosts full access to Mail.app on macOS — search, read, send, reply, flag, move, and more across all accounts configured in Mail.app.Last updated2460MIT
- AlicenseAqualityAmaintenanceAn MCP server for Apple Mail that enables Claude to read, search, manage, and compose emails via AppleScript.Last updated20481MIT
- AlicenseAqualityCmaintenanceAn MCP server that provides programmatic access to Apple Mail, enabling AI assistants like Claude to read, send, search, and manage emails on macOS.Last updated25MIT
Related MCP Connectors
Let ChatGPT, Claude & Cursor use your Mac: email, calendar, iMessage, Teams, files. Local, free.
Search, read, and write your Apple Notes from ChatGPT/Claude via a local Mac agent + MCP relay.
MCP connector for iMessage & Contacts via a local Mac agent + Vercel relay
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/androidua/apple-mail-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server