Skip to main content
Glama
androidua

Apple Mail MCP Server

by androidua

mail_search_emails

Read-onlyIdempotent

Search Apple Mail for emails by keyword and date range. Filter results by account, mailbox, or include system folders. Returns merged, deduplicated results sorted newest-first.

Instructions

Search Apple Mail for emails by keyword and/or date range.

Searches across all configured accounts in parallel, then merges, deduplicates and sorts the results newest-first. System/junk/duplicate-view mailboxes are excluded by default (see include_all_mailboxes). Returns matching emails with opaque email_id values for use with mail_read_email.

IMPORTANT — date range strategy (always follow this order): Large date windows (since_days > 90) are slow on big IMAP accounts and frequently timeout. Always start narrow and expand only if needed:

Step 1: since_days=7   → if results < needed, continue
Step 2: since_days=30  → if results < needed, continue
Step 3: since_days=90  → if results < needed, continue
Step 4: since_days=365 → last resort only

Never jump straight to since_days=365 for vague queries like
"recent emails" or "last few emails". Start with 7 days.

To page further back, keep since_days and add before_days instead of
re-reading overlapping results.

Args: params (SearchEmailsInput): Input containing: - keyword (str): Optional search term matched against subject and sender. Omit when filtering by date only. - since_days (int): Optional. Restrict to emails received in the last N days (1–365). Use 1=today, 7=week, 30=month. - limit (int): Max results to return (default 20, max 100). - account (str): Optional. Restrict to one account (e.g. 'iCloud'). - mailbox_name (str): Optional. Restrict to one mailbox (e.g. 'INBOX'). - before_days (int): Optional. Exclude emails newer than N days ago; combine with since_days to page an older window (e.g. since_days=90, before_days=30 → 30–90 days ago) without re-fetching newer results. - include_all_mailboxes (bool): Optional. Also search normally-skipped mailboxes (Trash, Junk/Spam/Bulk, Deleted Items, Gmail All Mail/ Important/Starred, Outbox). Default false. - response_format (str): 'markdown' (default) or 'json'.

At least one of keyword or since_days must be provided.

Returns: str: Results are merged across accounts, deduplicated by message id (Gmail label copies collapse to one), and sorted newest-first. System/junk/duplicate-view mailboxes (Trash, Deleted Items, Junk/Spam/Bulk, Gmail All Mail/Important/Starred, Outbox) are skipped unless include_all_mailboxes=true. Each result carries subject, sender, date, read-status and an opaque email_id. Timed-out accounts are listed as a warning (not a crash).

Markdown example:
    # Search Results: "invoice" · last 30 days
    Found 3 email(s) ...

JSON example:
    [{"email_id": "...", "account": "iCloud", "mailbox": "INBOX",
      "subject": "Invoice", "sender": "x@y.com",
      "date": "Mon 3 Mar 2025", "read": true}]

Examples: - "Most recent 3 emails" → since_days=7, limit=3 (expand to 30/90 if < 3 found) - "Emails this week" → since_days=7 - "Invoices in the past month" → keyword="invoice", since_days=30 - "Find emails from Alice" → keyword="Alice", since_days=30 - "Search only Yahoo INBOX" → account="Yahoo", mailbox_name="INBOX", since_days=7

Error Handling: - Returns an error string if Mail.app cannot be reached. - Returns "No emails found" with filter description if no matches. - Accounts that exceed the 45 s per-account timeout are listed as warnings; other accounts' results are still returned.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Discloses parallel search, deduplication, sorting, exclusion of system mailboxes, and error behavior (timeouts, no results). Annotations already mark it as read-only and idempotent; description adds context without contradiction.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with sections for args, returns, examples, and error handling. It is somewhat lengthy but efficiently organized and front-loaded with the critical date strategy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Covers purpose, all parameters, usage strategy, error handling, and return format comprehensively. Given an output schema exists and the description is thorough, it provides complete guidance for correct tool invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has detailed descriptions for each parameter (high coverage), but the description adds extra value with usage examples and strategic advice (e.g., start with since_days=7). Baseline 3 is exceeded due to this added context.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states 'Search Apple Mail for emails' with specific verbs and resources. It distinguishes from sibling tools like mail_read_email (which reads a single email) and mail_list_mailboxes (which lists mailboxes).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Provides extensive usage guidance including a step-by-step date range strategy, examples mapping common queries to parameters, and instructions for paging. However, it does not explicitly compare to mail_read_email or mail_list_mailboxes, though it implies usage of email_id for reading.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

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