apple-mail-mcp CLAUDE.md

apple-mail-mcp CLAUDE.md is an instructions file for coding agents from androidua/apple-mail-mcp. It costs 2,316 tokens per session, scanned A, original, MIT.

Project instructions for a read-only Apple Mail server that lets Claude communicate with Apple Mail through three local tools.

In plain words
What is it for?
Use them when developing or testing the Apple Mail MCP server, checking Python syntax, running its tests, managing its virtual environment, or reviewing its AppleScript safety rules.
Why use it?
They explain how the server is structured, tested, and started without network access or third-party email libraries. This gives contributors a consistent way to work on the project safely.

Instructions file

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add instructions/androidua/apple-mail-mcp/claude-md
Clone the repo
git clone --depth 1 https://github.com/androidua/apple-mail-mcp

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for apple-mail-mcp CLAUDE.md

README.md
[![agentmods](https://agentmods.dev/badge/instructions/androidua/apple-mail-mcp/claude-md.svg)](https://agentmods.dev/instructions/androidua/apple-mail-mcp/claude-md)
Your own site
<a href="https://agentmods.dev/instructions/androidua/apple-mail-mcp/claude-md"><img src="https://agentmods.dev/badge/instructions/androidua/apple-mail-mcp/claude-md.svg" alt="Measured on agentmods" height="20"></a>
Per session 2,316 This file is loaded in full into every session.
When invoked 2,316 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.02316 $0.02316
Opus 5 $0.01158 $0.01158
Sonnet 5 $0.00463 $0.00463
Haiku 4.5 $0.00232 $0.00232

Measured 4d ago against content hash f5893f55a65e, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

apple-mail-mcp CLAUDE.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

CLAUDE.md · 135 lines

How it starts

The opening of the file, as written. The whole thing — 135 lines — stays where its author put it; the contents beside it link to each section on GitHub.

CLAUDE.md — Apple Mail MCP Server

Project overview

Read-only Apple Mail MCP server. Exposes three tools to Claude Desktop via stdio transport. Uses AppleScript via subprocess — no third-party email libraries, no network calls.

Commands

# Start the server manually (for testing)
venv/bin/python apple_mail_mcp.py

# Syntax check
venv/bin/python -m py_compile apple_mail_mcp.py && echo "OK"

# Run the unit test suite (pure functions — no live Mail needed)
venv/bin/python -m pytest -q

# Reinstall dependencies into a fresh venv (runtime + dev)
python3 -m venv venv
venv/bin/pip install -r requirements.txt -r requirements-dev.txt

# Freeze current deps (after adding a new package)
venv/bin/pip freeze > requirements.txt

Architecture

Single file: all server logic lives in apple_mail_mcp.py. Do not split into multiple files.

Transport: stdio only. The server never opens a network socket.

AppleScript execution:

  • Run via asyncio.create_subprocess_exec("osascript", "-e", script)
  • 60-second async timeout with proc.kill() on expiry
  • All user strings pass through _sanitize_for_applescript() before embedding
  • Line continuation: AppleScript uses ¬ (U+00AC), NOT \. When scripts are passed via osascript -e, the parser is strict — a \ at end of line produces error -2741 ("Expected expression but found unknown token"). Always use sequential assignment statements instead of multi-line expressions.

Search strategy (mail_search_emails):

  • Pipeline (v1.3.0): each mailbox emits up to limit newest matches (per-mailbox cap, NOT per-account) → Python _parse_search_rows() parses the delimited rows → _merge_results() dedups by (account, message_id), sorts newest-first, truncates to limit. This replaced the old "concatenate per-account outputs, truncate at limit in account order" loop, which let the first responding account fill the whole result list and silently drop other accounts (bug B1). Any message in the true global top-limit is within the newest limit of its own mailbox, so per-mailbox collection + global sort is exact.
  • Sortable timestamp: each row carries a relative-seconds field (date received) - refDate, where refDate = (current date) is captured once at script start. It is always a small negative integer. Never emit absolute epochs — AppleScript mangles large integers (32-bit/scientific-notation hazard); relative seconds avoid that and need no GMT correction. _parse_search_rows reads it via int(float(...)).
  • Skip list (default): Trash, Deleted Messages, Deleted Items, Junk, Junk Email, Junk E-mail, Spam, Bulk Mail, Bulk, All Mail, [Gmail]All Mail, Important, Starred, Outbox. Covers real-world junk/trash names across iCloud/Yahoo/Gmail/Hotmail plus Gmail duplicate-view mailboxes (fixes B2/B3). include_all_mailboxes=true opts back in; an explicit mailbox_name bypasses the skip list.
  • whose clause builds its predicate dynamically from active filters (keyword, since_days, before_days). Why whose instead of search: Mail 16 (macOS 26) removed the search <mailbox> for <keyword> command.
  • whose is O(n) per mailbox at the Objective-C layer (~0.5–1.5k msgs/sec) — it fully materialises the match list before the per-mailbox cap applies. Low limit reduces output size, not scan cost. Because there is no global early-exit anymore, all non-skipped mailboxes are scanned; date-only wide-window searches are the slow case.
  • before_days bounds the near edge of the window (date received <= (current date) - (N * days)); requires since_days and must be < since_days (enforced by the validator). Use it to page older mail without re-fetching.
  • Multi-account parallel execution: when no account filter is set, the tool first calls _SCRIPT_LIST_ACCOUNTS to enumerate accounts, then runs one search script per account via asyncio.gather(return_exceptions=True) with a 45 s per-account timeout. A slow/offline IMAP account cannot block or crash results from other accounts. Timed-out accounts are listed as a warning in the response.
  • When account is specified, a single script runs with a 60 s timeout (no gather overhead).
  • Do NOT call proc.stdout.close() or proc.stderr.close() on timeoutasyncio.StreamReader has no .close() method. Use only proc.kill() + await proc.wait().

Read the full file on GitHub · 135 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 135 lines · 2,316 tokens per session scan A f5893f55a65e

Subscribe to this mod's changes

apple-mail-mcp CLAUDE.md is an instructions file published in the GitHub repository androidua/apple-mail-mcp (0 stars, last pushed 1mo ago), licensed MIT. It adds 2,316 tokens to every session, about $0.0116 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other instructions, from other repositories

vscode buildNext.instructions.md

Working notes and architecture documentation for the new esbuild-based build system in build/next. Use when making changes to the new build pipeline (transpile/bundle commands, NLS plugin, source-map handling, resource copying, or self-hosting watch tasks).

microsoft/vscode · 6,785 tokens

spec-kit AGENTS.md

AGENTS.md instructions for github/spec-kit, covering agents.md, about spec kit and specify, quickstart — add a new integration in 5 steps, integration architecture and integrationmanifest — file tracking.

github/spec-kit · 7,104 tokens

codex AGENTS.md

AGENTS.md instructions for openai/codex, covering rust/codex-rs, the codex-core crate, code review rules, crate api surface and model visible context.

openai/codex · 5,182 tokens

vscode oss-third-party-notices.instructions.md

Instructions for microsoft/vscode, covering vs code oss third-party-notices pipeline, architecture, pipeline flow in ci, applying the notice (cutover) and fallback chain (never fail the build).

microsoft/vscode · 5,001 tokens

langchain AGENTS.md

AGENTS.md instructions for langchain-ai/langchain, covering global development guidelines for the langchain monorepo, corridor security analysis, project architecture and context, monorepo structure and development tools & commands.

langchain-ai/langchain · 4,469 tokens

deepseek-harness AGENTS.md

AGENTS.md instructions for deepseek-ai/deepseek-harness, covering agents.md, pre-stable apis and released session data, repository layout, commands and host sandbox failures.

deepseek-ai/deepseek-harness · 3,733 tokens