macOS Mail MCP

macOS Mail MCP

Discovers and reads mail accounts configured in Apple Mail via macOS automation, allowing MCP clients to access email without storing passwords.

Category
访问服务器

README

macOS Mail MCP

An MCP server that discovers the mail accounts already configured in Apple Mail and reads them through Apple Mail automation. There is no accounts configuration file, and this project never writes a password or token to disk.

Status and macOS boundary

macOS has no supported public API for enumerating the detailed incoming/outgoing server settings of every Internet Account. This server reads the current Sonoma accountd store at ~/Library/Accounts/Accounts4.sqlite (and supports legacy Apple Mail Accounts.plist metadata when present), then obtains credentials only on demand with the macOS security tool. This is deliberately best-effort across Mail versions: test it against your particular Sonoma-or-newer Mail configuration before using it for production workflows.

The first mail operation may show an Automation prompt. Allow the ChatGPT desktop app to control Mail. Do not export/import passwords: Apple Mail performs its own account authentication, including provider OAuth.

Because Apple Mail stores its account database in a TCC-protected Library location, macOS also requires Full Disk Access for the application launching this server. In System Settings → Privacy & Security → Full Disk Access, add Terminal/iTerm if you launch it there; add your MCP desktop client (for example Codex) when that client launches it. Restart the launching application afterwards.

Install

Requires macOS Sonoma+, Python 3.12+, and Apple Mail configured with IMAP-capable accounts.

git clone git@github.com:wherecodegetscooked/applemail-mcp.git
cd applemail-mcp
python3.12 -m venv .venv
.venv/bin/pip install -e '.[dev]'
.venv/bin/pytest

Run it over standard input/output (the normal MCP transport):

.venv/bin/macos-mail-mcp

Register the server with the ChatGPT desktop app / Codex:

codex mcp add macos-mail -- "$PWD/.venv/bin/macos-mail-mcp"

Restart the ChatGPT desktop app, then ask a new Codex task about your mail. Keep stdout reserved for MCP traffic; diagnostics go to stderr/the launchd log.

Architecture

  • discovery.py scans macOS account metadata every cycle. Account additions, removals, and server changes are picked up without a server restart.
  • apple_mail.py uses macOS JXA automation to read the already-synced Apple Mail app. Apple Mail remains responsible for IMAP, SMTP, provider OAuth, retries, and credentials.
  • service.py queries Apple Mail directly for current mail and search, then caches returned messages in SQLite/FTS5 for subsequent local reads.
  • store.py contains message metadata, indexed bodies, and attachment metadata. It has no credentials. Attachment bytes are fetched only after read_attachment.

Security and operations

The SQLite cache is private to the user at ~/Library/Application Support/macOS-Mail-MCP/mail.sqlite3; protect the macOS login account and use FileVault. It can contain email content, so do not place it in a shared directory. Set MAIL_MCP_DB to another private path if required and MAIL_MCP_LOG_LEVEL=DEBUG for troubleshooting. Logs never include passwords.

Apple Mail performs provider authentication itself, so OAuth-only accounts such as Gmail can be queried without making their tokens available to this server. The server needs Full Disk Access for account discovery and Automation permission to read Mail.

launchd

launchd/com.example.macos-mail-mcp.plist is a template. Replace both REPLACE_ME occurrences and the executable path with the virtualenv’s absolute executable path, then install it:

mkdir -p ~/Library/LaunchAgents
cp launchd/com.example.macos-mail-mcp.plist ~/Library/LaunchAgents/
launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/com.example.macos-mail-mcp.plist

For an stdio MCP server, launchd is normally used by a client-side bridge; most MCP desktop clients instead start the command themselves. Do not start two instances against the same SQLite file unless you have intentionally chosen that arrangement.

Testing

Unit tests cover plist normalization, Keychain command handling, and SQLite FTS/incremental sync state. Integration testing should use a dedicated disposable IMAP account and an isolated MAIL_MCP_DB; it must never use a personal mailbox in CI. Run pytest locally after configuring that account.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选