Skip to main content
Glama
apple-mail-mcp

apple-mail-mcp

by TrevorIkky

apple-mail-mcp

Let an AI assistant read your Apple Mail — search it, read threads, and save drafts — instead of squinting at screenshots of the Mail window.

It is an MCP server for macOS. It talks to Mail.app through AppleScript out of the box (no setup, no credentials), and can optionally use IMAP for speed on big mailboxes.

It never sends mail. The only write it can do is save a draft.


Quick start

You need macOS with Mail.app set up, and uv.

Claude Code

claude mcp add apple-mail -s user -- uvx --from git+https://github.com/TrevorIkky/apple-mail-mcp apple-mail-mcp

Claude Desktop, or any MCP client

Add this to the client's MCP config (for Claude Desktop that is ~/Library/Application Support/Claude/claude_desktop_config.json):

{
  "mcpServers": {
    "apple-mail": {
      "command": "uvx",
      "args": [
        "--from",
        "git+https://github.com/TrevorIkky/apple-mail-mcp",
        "apple-mail-mcp"
      ]
    }
  }
}

Restart the client. The first time the server talks to Mail, macOS asks you to allow it to control Mail — say yes, or it can't read anything.

Then just ask: "what did Jane send me last week?", "summarise the thread about the invoice", "draft a reply agreeing to Tuesday".

Check it works

uvx --from git+https://github.com/TrevorIkky/apple-mail-mcp apple-mail-mcp --selftest

That prints your account names and the five newest messages in the first one.


Related MCP server: Apple Mail MCP Server

What it can do

Tool

What it does

list_accounts

The accounts configured in Mail

list_mailboxes

Folders in an account

list_messages

Newest messages, headers only, with sender/subject/unread filters

read_messages

Full bodies for specific message ids

read_by_position

Full bodies by position in the mailbox (1 = newest) — use on slow mailboxes like Sent

search_messages

Find by sender or subject (optionally body text)

create_draft

Save a draft in Mail — never sends

imap_search / imap_fetch / imap_mailboxes

The fast path, see below

A typical sequence: list_messages to see what's there → read_messages with the handful of ids that matter → create_draft for the reply.


The fast path (optional)

AppleScript is the only route Apple documents, but every call is synchronous against the Mail app and dies at the Apple Event timeout (~2 minutes). On a mailbox with tens of thousands of messages, a broad search will simply time out.

If that's you, point the IMAP tools at the same account and get real server-side search. Create ~/.config/apple-mail-mcp/config.json:

{
  "accounts": {
    "work": {
      "host": "imap.example.com",
      "port": 993,
      "user": "you@example.com",
      "keychain_service": "apple-mail-mcp",
      "keychain_account": "you@example.com"
    }
  }
}

Your password is not in that file. Put it in the macOS Keychain yourself:

security add-generic-password -s apple-mail-mcp -a you@example.com -w

For Gmail and iCloud this must be an app-specific password, not your login password.


Why it works this way

There is no supported Apple framework for reading a mailbox from outside Mail, so the honest options are limited:

Route

Supported

Fast

Notes

AppleScript

Yes — Mail's scripting dictionary

No

Bound by the Apple Event timeout. What this server uses by default.

MailKit

Yes, but wrong tool

—

macOS 12+ extension API: content blocking, message actions, compose sessions, security. It hands your extension messages as they arrive; it cannot browse mailboxes or fetch stored mail.

On-disk store (~/Library/Mail/V*/, Envelope Index, .emlx)

No — undocumented

Yes

Needs Full Disk Access, and the format can change with any macOS release.

IMAP

Yes — a standard protocol

Yes

Independent of Mail. Needs credentials. The opt-in path above.

Two rules keep the AppleScript backend from wedging Mail, both learned the hard way:

  • No whose filters. messages whose id is N walks the entire store and times out. The server iterates by index and filters in Python.

  • Never fetch bodies for a list. Headers are cheap, bodies are not. list_messages returns headers only; bodies come from read_messages for the ids you actually want.

Every call takes a scan bound, so a request can't quietly turn into a mailbox-wide walk.


Troubleshooting

"Mail got an error: AppleEvent timed out (-1712)" — a request was too big, or Mail is busy syncing. Lower scan, or use the IMAP path. If Mail itself has become unresponsive, give it a minute; it recovers.

"Operation not permitted" — your client needs Automation permission for Mail in System Settings → Privacy & Security → Automation.

Empty results from an account that clearly has mail — check the mailbox name with list_mailboxes; it is INBOX on some accounts and Inbox on others.


Development

git clone https://github.com/TrevorIkky/apple-mail-mcp
cd apple-mail-mcp
uv run pytest
uv run apple-mail-mcp --selftest

See CONTRIBUTING.md for the layout and the rules that keep Mail.app from wedging.

License

MIT

Available Tools

10 tools
create_draftB

Save a new message as a draft in Mail.app. It is never sent.

account picks the sending address (an account name from list_accounts). The person reviews and sends the draft themselves.

Inputs: to (required), body (required), subject (required), cc, +1 more. Returns: result

imap_fetchC

Fetch full message bodies by UID, as returned by imap_search.

Inputs: uids (required), account (required), mailbox, max_chars. Returns: result

imap_mailboxesA

List IMAP folders for a configured account.

account is a key under "accounts" in ~/.config/apple-mail-mcp/config.json, not necessarily the name Mail.app shows.

Inputs: account (required). Returns: result

list_accountsA

List the mail accounts configured in Mail.app.

Inputs: no named parameters. Returns: result

list_mailboxesA

List the mailboxes (folders) of one account.

Names differ between accounts - INBOX on some, Inbox on others - so check here before guessing.

Inputs: account (required). Returns: result

list_messagesA

List message headers, newest first, without fetching bodies.

scan bounds how many of the newest messages are examined; limit caps how many matches come back. Filters are case-insensitive substrings. Positions in this result feed read_by_position.

Inputs: account (required), scan, limit, mailbox, +3 more. Returns: result

read_by_positionB

Read full bodies by position in the mailbox, where 1 is the newest.

list_messages returns messages in this order. Prefer this on mailboxes with long quoted threads - Sent, typically - where locating a message by id is slow enough to time out.

Inputs: account (required), positions (required), mailbox, max_chars. Returns: result

read_messagesA

Read full bodies for specific message ids from list_messages.

Locates them by scanning the newest scan messages, so raise scan for older mail. If this times out, use read_by_position instead.

Inputs: ids (required), account (required), scan, mailbox, +1 more. Returns: result

search_messagesA

Find messages whose sender or subject contains query, case-insensitively.

search_body: true also searches bodies and returns an excerpt, which is much slower - keep scan small. For real search on a large mailbox, use imap_search.

Inputs: query (required), account (required), scan, limit, +3 more. Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.4/5.0

    Scored across 10 tools

    Disambiguation3/5

    There are two parallel surfaces, AppleScript and IMAP, causing overlapping pairs such as list_mailboxes/imap_mailboxes, list_messages/search_messages/imap_search, and read_messages/read_by_position/imap_fetch. The descriptions give useful guidance and fallback advice, but the boundaries are not as crisp as ideal.

    Naming Consistency4/5

    Most tools use lower_snake_case action-oriented names like list_accounts, read_messages, search_messages, and create_draft. The imap_ prefixed family is still readable and groupable, though imap_mailboxes is noun-like rather than following the same verb_noun pattern.

    Tool Count5/5

    Ten tools is well within a reasonable range for an email integration. The AppleScript and IMAP paths each add tools for distinct operational needs rather than padding the surface unnecessarily.

    Completeness3/5

    The set covers account/mailbox discovery, listing/searching/reading messages, and draft creation, but omits sending, moving/deleting/marking messages, attachment operations, and draft editing. The draft-only design may be intentional safety, but it leaves notable gaps in the mail lifecycle.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      C
      maintenance
      Enables AI assistants to read, search, send, and manage email on macOS through programmatic access to Apple Mail.
      29
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI assistants to query a local, read-only Apple Mail archive, letting them search messages by keyword, sender, subject, date or account and retrieve summaries, individual message bodies, pending action items and stored daily briefs. All tools are annotated read-only, so assistants can consult mail without sending, deleting, moving or editing anything.
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Lets an AI agent read messages in Apple Mail on macOS through AppleScript, list the newest mail, and open drafts for review. Sending happens only after the user clicks Send in Mail's confirmation dialog, so nothing leaves the machine unapproved.
      MIT