Skip to main content
Glama
icloud-mail-mcp

icloud-mail-mcp

icloud-mail-mcp

A small remote MCP server that lets Claude search, read and archive iCloud Mail. It runs as one Cloudflare Worker, talks IMAP over implicit TLS to imap.mail.me.com:993, and signs Claude in with OAuth gated by Cloudflare Access.

What it can do

Tool

Does

Changes mail?

list_folders

Folder names with message and unread counts

No

search_messages

One folder, by date range, sender, subject, unread. Newest first, max 50

No

read_message

Headers and plain-text body (512 KB raw, 20k chars text). Attachments listed, not returned

No (opens the folder read-only, so nothing is marked read)

archive_messages

Moves up to 50 messages to Archive

Yes, a move only

There is no send, delete, flag or mark-read tool. Archive uses IMAP MOVE when the server has it. Without MOVE it needs UIDPLUS: ImapFlow then copies the messages, flags just those as \Deleted in the source folder and runs UID EXPUNGE on exactly those UIDs, so it can never purge other messages already marked deleted. With neither, it refuses. iCloud currently takes the UIDPLUS path. If the server reports a failed move, the tool returns an error rather than claiming success. Archive is a separate OAuth scope (mail:archive) that you tick on the consent page, so you can connect read-only first.

Related MCP server: IMAP MCP Server

How sign-in works

Claude ──OAuth (DCR/CIMD, PKCE)──▶ Worker /authorize ◀── Cloudflare Access (only your email)
   │                                   │  verifies the Access JWT again, then shows a consent page
   └──── bearer token ────▶ Worker /mcp ──IMAP over TLS──▶ imap.mail.me.com:993
  • Cloudflare Access protects only /authorize. Claude's servers must reach /token, /register and /mcp directly, and those are protected by the OAuth tokens instead.

  • The Worker checks the Access JWT itself too (issuer, audience, owner email), so a loosened Access policy still cannot let anyone else in.

  • Authorization codes go only to https://claude.ai or https://claude.com redirect hosts (ALLOWED_REDIRECT_HOSTS).

  • The app-specific password lives only as a Worker secret. Tokens and grants live hashed and encrypted in KV (by @cloudflare/workers-oauth-provider).

Layout

  • src/store.ts: the allowed operations, as an interface

  • src/imap-store.ts: that interface over ImapFlow (search, read, archive)

  • src/tools.ts: MCP tool definitions and input validation

  • src/mcp-http.ts: stateless Streamable HTTP handler. Serves the 2026-07-28 MCP protocol through the v2 TypeScript SDK and still answers 2025-era clients

  • src/access.ts: Cloudflare Access JWT check and redirect allowlist

  • src/consent.ts: the consent page

  • src/imap-client.ts: per-call IMAP session over cloudflare:sockets

  • src/worker.ts: wires OAuth, Access and MCP together

  • test/: 68 tests against synthetic fixtures (no real mail)

Develop

cp wrangler.example.jsonc wrangler.jsonc   # git-ignored; fill in your values
npm ci
npm test          # vitest, synthetic fixtures only
npm run typecheck
npx wrangler deploy --dry-run --outdir dist   # bundle without deploying

Setup and deploy steps are in SETUP.md.

License

MIT. See LICENSE.

Tool Schema Changelog

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

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      A
      maintenance
      Enables Claude to interact with email accounts via IMAP and SMTP, providing tools for searching, reading, sending, and managing emails across multiple providers.
      40
      819 npm
      140
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables Claude to read, search, send, and manage emails across multiple IMAP/SMTP accounts via a single deployment.
      -
    • F
      license
      Not graded
      quality
      B
      maintenance
      Enables Claude to read, search, draft, send, flag, and move email across multiple IMAP/SMTP mailboxes while keeping credentials local.
      -
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables Claude and ChatGPT to read, search, and organize mail in a user's own email account, including folders, threads, attachments, drafts, and optional sending, with per-user permission levels and OAuth-secured remote connections.
      MIT