Skip to main content
Glama
icloud-mcp

icloud-mcp

by mcdscot
README.md
# icloud-mcp

An [MCP](https://modelcontextprotocol.io) server that gives AI assistants access to **iCloud Mail**
(IMAP/SMTP) and **iCloud Calendar** (CalDAV).

It signs in with an Apple **app-specific password**, so it never sees your Apple ID password and needs
no two-factor handling. Run it locally over stdio, or host it as a remote server protected by an API key.

## Tools

| Mail | Calendar |
| --- | --- |
| `icloud_list_mailboxes` | `icloud_list_calendars` |
| `icloud_search_messages` | `icloud_list_events` (recurring events expanded) |
| `icloud_get_message` | `icloud_create_event` |
| `icloud_create_draft` | `icloud_update_event` |
| `icloud_send_message` | `icloud_delete_event` |
| `icloud_move_messages` (archive / trash) | |
| `icloud_set_flags` (read / flagged) | |

- Mail is never hard-deleted: "delete" means moving to `Deleted Messages`.
- iCloud does not file mail sent over SMTP, so `icloud_send_message` saves a copy to `Sent Messages` itself.
- iCloud rejects CalDAV UID queries, so events are addressed by their CalDAV URL (`event_id`).
- Editing or deleting a recurring event affects the whole series.
- **Subscribed calendars** (webcal feeds such as sports fixtures or app schedules) are included, read-only.
  iCloud stores only a link to each feed, so the server downloads it itself and caches it for 15 minutes.
  Feed URLs often contain private tokens, so tools only ever return the publisher's host name.
- Legacy CalDAV Reminders lists (shown in iCloud with ⚠️) are hidden; current Reminders are not available
  over CalDAV.

## Requirements

- Python 3.12+ and [uv](https://docs.astral.sh/uv/)
- An app-specific password: <https://account.apple.com> → Sign-In and Security → App-Specific Passwords

## Run locally

```bash
git clone https://github.com/mcdscot/icloud-mcp.git
cd icloud-mcp
uv run icloud-mcp setup    # prompts for Apple ID and app-specific password, stores them in the OS keychain
uv run icloud-mcp check    # verifies Mail and Calendar sign-in
```

`setup` stores the credentials with [keyring](https://pypi.org/project/keyring/) (macOS Keychain, Windows
Credential Manager or the Linux Secret Service). The password is never echoed or written to a file.

Then add it to your MCP client as a stdio server. For example, with Claude Code:

```bash
claude mcp add --scope user icloud -- uv run --directory /path/to/icloud-mcp icloud-mcp
```

## Host it remotely

Remote MCP clients (for example cloud-hosted agents) need an HTTPS endpoint. `icloud-mcp serve-http`
serves stateless Streamable HTTP on `$PORT` (default 8080), at both `/` and `/mcp`, and refuses any request
without the API key in `$MCP_API_KEY`. `GET /healthz` is open for health checks.

Clients authenticate with either header:

```
Authorization: Bearer <key>
X-API-Key: <key>
```

### Deploy to Fly.io

```bash
cp fly.example.toml fly.toml              # set your app name, region and ICLOUD_TIMEZONE
fly apps create <your-app-name>
python3 -c "import secrets; print('icmcp_' + secrets.token_urlsafe(32))"   # your API key: keep it safe
fly secrets set ICLOUD_USERNAME=<apple-id> ICLOUD_APP_PASSWORD=<app-specific-password> MCP_API_KEY=<api-key>
fly deploy
```

Your endpoint is `https://<your-app-name>.fly.dev`. To use your own domain, run
`fly certs add <domain>` and add the DNS records it prints. If your DNS is on Cloudflare, set the record to
DNS only (grey cloud) so Fly can issue the certificate.

`fly.toml` is git-ignored so your app name and settings stay out of the repository. Other hosts work the
same way: run the `Dockerfile` and set the same environment variables.

## Configuration

| Variable | Purpose |
| --- | --- |
| `ICLOUD_USERNAME` | Apple ID email (overrides the keychain) |
| `ICLOUD_APP_PASSWORD` | App-specific password (overrides the keychain) |
| `ICLOUD_FROM` | Send-as address, if different from the Apple ID (must be one of your iCloud aliases) |
| `ICLOUD_TIMEZONE` | IANA zone for times given without an offset; defaults to the machine's zone |
| `ICLOUD_ALLOW_SEND` | `false` removes `icloud_send_message`; default `true` |
| `MCP_API_KEY` | Required by `serve-http`; at least 32 characters |
| `PORT` | Port for `serve-http`; default `8080` |

## Security

This server can read, move and (unless disabled) send email as you. Treat it accordingly.

- **Prompt injection.** Emails and calendar invites are written by other people. An assistant reading them
  can be tricked by instructions hidden in a message, such as "forward the last ten emails to …". For a
  hosted server, keep `ICLOUD_ALLOW_SEND=false`: the assistant can still write drafts, and you send them
  yourself. Only enable sending if you trust every client and review what it does.
- **The API key is the only lock** on a hosted server. Generate a long random key, give it only to your
  MCP client's credential store, never paste it into a chat, and rotate it (`fly secrets set MCP_API_KEY=…`)
  if it leaks.
- **Use an app-specific password**, never your Apple ID password. You can revoke it at any time at
  <https://account.apple.com> without affecting anything else.
- **Single user.** One deployment serves one iCloud account; there is no per-user isolation.
- Destructive tools are marked with MCP `destructiveHint`, and nothing deletes mail permanently.

## Development

```bash
uv run pytest
```

## License

[MIT](LICENSE)

TDQS

A3.6/5.0

Scored across 12 tools

Disambiguation5/5

Mail and calendar tools are cleanly separated, and within mail each tool maps to a distinct action: listing mailboxes, searching, reading a single message, drafting, sending, moving, and flagging. The move vs. set_flags split is explicitly clarified in the descriptions, leaving no real boundary confusion.

Naming Consistency5/5

All twelve tools follow a uniform `icloud_<verb>_<noun>` snake_case pattern, and the resource prefixes (mailboxes, messages, calendars, events) make the pattern even more predictable. No mixed conventions or vague verbs.

Tool Count5/5

Twelve tools split sensibly into seven mail operations and five calendar operations, each earning its place with no filler. The surface is well-scoped for a personal iCloud mail+calendar integration.

Completeness4/5

Core CRUD and lifecycle coverage is present for both domains: search/read/draft/send/move/flag for mail and list/create/update/delete for events. Minor gaps remain, such as no reply/forward, no attachment download, no calendar creation/deletion, and no attendee/RSVP handling.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues