apple-mail-fast-mcp
AGENTS.md103 starsChanged 2 months agoMITView on GitHub
This is the canonical project guidance for Codex and Claude Code. Read it at the start of work, then load only the domain references needed for the task. Python 3.10+, FastMCP, AppleScript via osascript, IMAP via imapclient, and SMTP. The server exposes structured MCP tools for Apple Mail on macOS. All modules below live in src/apple_mail_fast_mcp/: - server.py: tool registration, validation, confirmation gates, responses. - mail_connector.py: domain logic and dispatch between AppleScript and network paths. - imap_connector.py: IMAP reads, mutations,…
1 other project uses a version of this.
Adopted by
Most recently taken up by
- s-morgan-jeffries/apple-mail-mcpword for word, first seen Oct 9, 2026
Other versions1 project uses a version of this.
Word for word · 1
- s-morgan-jeffries/apple-mail-mcp★ 104100% same
Edited · 0
None found.
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 31,439 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository6 other files it gives its agents.
- .claude/CLAUDE.mdCLAUDE.md
- api-designSkill
- applescript-mailSkill
- integration-testingSkill
- performance-patternsSkill
- releaseSkill
The file
We split this AGENTS.md into the rules it gives an agent
8 rules. About 0 are common, 2 are distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 11
All modules below live in src/apple_mail_fast_mcp/:
- Very specific: line 29
Use TOOLS.md for the API and ARCHITECTURE.md for dispatch details.
- Very specific: line 46
Start from current origin/main on {type}/issue-{num}-{description} (feature/, fix/, or docs/).
- Distinctive: line 54
After pushing/opening a PR, inspect checks for that PR/current commit.
- Very specific: line 56
When asked to merge, follow MERGE_AND_STATUS.md: wait for CI, squash merge ordinary PRs, delete the branch, update local main, surface …
- Distinctive: line 93
Test-mode gates are not universal isolation (see open #352).
- Very specific: line 100
Follow SECURITY_CHECKLIST.md: sanitize inputs, escape interpolated AppleScript strings, validate path-bearing names, apply rate limits and …
- Very specific: line 103
Use the existing AppleScript JSON wrapper/parser (NSJSONSerialization), quote record key |name|, and coerce missing value before …
≈ “Common” is an estimate: at least 1 in 5 of the 40,246 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Apple Mail Fast MCP — shared agent instructions
This is the canonical project guidance for Codex and Claude Code. Read it at the start of work, then load only the domain references needed for the task.
Project map
Python 3.10+, FastMCP, AppleScript via osascript, IMAP via imapclient, and
SMTP. The server exposes structured MCP tools for Apple Mail on macOS.
All modules below live in src/apple_mail_fast_mcp/:
server.py: tool registration, validation, confirmation gates, responses.mail_connector.py: domain logic and dispatch between AppleScript and network paths.imap_connector.py: IMAP reads, mutations, connection pool, and tiered thread lookup (Gmail X-GM-THRID, IMAP THREAD, header-search BFS).draft_builder.py,smtp_sender.py: MIME construction and clean SMTP sends. Drafts can use IMAP APPEND; compose/send is not exclusively AppleScript. Credentials and account/seed information determine which path engages.security.py,utils.py,exceptions.py: safety gates, sanitization, escaping, parsing, and typed errors.drafts.py,templates.py,imap_overrides.py,keychain.py: state and credentials.
AppleScript is the baseline for many operations, with optional IMAP fast paths. Some mailbox operations require IMAP. Fallback is not a guarantee of equivalent latency or completeness: preserve partial/incomplete-result reporting and never turn an indeterminate lookup into a definitive not-found result.
Use TOOLS.md for the API and
ARCHITECTURE.md for dispatch details. Read current
code before changing a path. pyproject.toml is authoritative for version and
dependencies; collect tests and run coverage for current counts. Do not add
hand-maintained line counts, timings, or test totals to these instructions.
Working a GitHub issue
GitHub is the source of truth for planned work and status. Follow CONTRIBUTING.md and the repository PR template.
- Inspect the working tree, current branch, issue body/comments/assignees, milestone, and open PRs before coding. Respect existing claims and contributor work; do not duplicate an in-flight fix. Preserve unrelated local changes.
- Work from an issue. For new work, file one first; for an existing issue, record the claim as described in CONTRIBUTING when authorized to post. A request to review an issue alone is not a request to implement it.
- Start from current
origin/mainon{type}/issue-{num}-{description}(feature/,fix/, ordocs/). Do not commit directly tomain. - For code changes use RED/GREEN/REFACTOR. Keep connector behavior and MCP exposure aligned when the API changes; internal or documentation work need not modify both modules. Run the relevant checks below before pushing.
- Open a PR against
main, using the PR template andCloses #Nfor completed issues (orRelated to #Nfor partial work). Explain behavior and validation, including checks that could not run. Assign the issue's milestone to the PR. - After pushing/opening a PR, inspect checks for that PR/current commit. Do not report an unrelated latest repository run as this branch's CI result.
- When asked to merge, follow MERGE_AND_STATUS.md: wait for CI, squash merge ordinary PRs, delete the branch, update local main, surface contributor PRs and untriaged contributor issues with counts, then report remaining milestone work. Never silently close outside contributions.
CHANGELOG.md and version bumps belong on release branches. Use
./scripts/create_tag.sh for tags. Release PRs use the release procedure's rebase
merge, not the ordinary PR squash workflow. Read the release reference only when
performing release work; setup or feature work does not execute a release.
Setup and validation
uv sync --dev
./scripts/install-git-hooks.sh
gh auth status
make check-allThe Git hooks are shared by both agents. Claude's .claude/settings.json hooks
are not this project's Codex automation: explicitly perform the session checks,
branch/tag safeguards, and CI monitoring above. See the full mapping and a
fresh-session smoke check in CODEX.md.
| Change | Validation |
| All changes | make check-all (lint, mypy, unit tests, complexity, version sync, parity, doc drift) |
| Coverage assessment | make coverage (90% minimum; CI enforces coverage separately from make check-all) |
| AppleScript changes | Integration tests covering the changed operation, then make test-integration on a dedicated test account |
| IMAP paths, AppleScript paths, or elicitation-gated tools | make test-e2e before pushing, per CONTRIBUTING |
| New/modified MCP tools | E2E coverage and updated TOOLS.md; regenerate eval descriptions if needed |
| Performance work | Profile the actual path/account first; use make benchmark and BENCHMARKING.md |
Unit tests mock real I/O. Full integration/e2e/benchmark runs have additional
prerequisites and are excluded from CI. Read TESTING.md
and relevant fixtures before running them. Use MAIL_TEST_MODE=true and an
explicit dedicated MAIL_TEST_ACCOUNT; never assume a default account is safe.
Test-mode gates are not universal isolation (see open #352); inspect the targeted
operations and fixtures. Do not send real email as a setup smoke test.
Implementation rules
- Return structured
{"success": bool, ...}responses; errors includeerroranderror_type. Preserve typed failures and partial-result semantics. - Follow SECURITY_CHECKLIST.md: sanitize inputs, escape interpolated AppleScript strings, validate path-bearing names, apply rate limits and audit logging, and consider confirmation for effects.
- Use the existing AppleScript JSON wrapper/parser (
NSJSONSerialization), quote record key|name|, and coercemissing valuebefore serialization. Let errors that need typed routing reach_run_applescriptvia stderr. - Build AppleScript dates with
_construct_as_date_var, never date-string literals. - Numeric Mail IDs and RFC Message-IDs are different. Preserve both ID forms;
avoid unindexed
whose message id is ...scans that freeze Mail. Use existing resolvers and account/mailbox hints. Profile property reads as well as subprocess and network costs; batching is not automatically faster (see #450). - Gmail labels need provider-aware handling.
gmail_modeis deprecated; do not introduce it on new tools. Inspect current connector behavior before changing moves. - Persistent application data uses
~/.apple_mail_mcp/orAPPLE_MAIL_MCP_HOME. Resolve storage roots at use time and validate filename stems before building paths. Keep credentials out of source, issue bodies, and logs.
Domain references
These remain single-source files under .claude/skills/. Codex should open them
as task-specific references; no copied Codex skill installation is required.
Their historical examples can lag current behavior. The current rules above and
maintained API docs take precedence over stale tool counts, old timings, or
examples claiming that rule mutation is unimplemented.
- AppleScript work: applescript-mail
- API changes: api-design
- Real-Mail testing: integration-testing
- Performance work: performance-patterns
- Releases: release. If a named reviewer plugin is unavailable, use an available review workflow and report that substitution.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

