icloud-mcp-server 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. icloud_mcp_server-0.2.0/LICENSE +21 -0
  2. icloud_mcp_server-0.2.0/PKG-INFO +473 -0
  3. icloud_mcp_server-0.2.0/README.md +435 -0
  4. icloud_mcp_server-0.2.0/pyproject.toml +58 -0
  5. icloud_mcp_server-0.2.0/setup.cfg +4 -0
  6. icloud_mcp_server-0.2.0/src/icloud_mcp/__init__.py +0 -0
  7. icloud_mcp_server-0.2.0/src/icloud_mcp/__main__.py +3 -0
  8. icloud_mcp_server-0.2.0/src/icloud_mcp/approvals.py +145 -0
  9. icloud_mcp_server-0.2.0/src/icloud_mcp/auth.py +368 -0
  10. icloud_mcp_server-0.2.0/src/icloud_mcp/bridge.py +350 -0
  11. icloud_mcp_server-0.2.0/src/icloud_mcp/cal.py +908 -0
  12. icloud_mcp_server-0.2.0/src/icloud_mcp/config.py +205 -0
  13. icloud_mcp_server-0.2.0/src/icloud_mcp/contacts.py +575 -0
  14. icloud_mcp_server-0.2.0/src/icloud_mcp/mail.py +1100 -0
  15. icloud_mcp_server-0.2.0/src/icloud_mcp/matching.py +71 -0
  16. icloud_mcp_server-0.2.0/src/icloud_mcp/outbox.py +119 -0
  17. icloud_mcp_server-0.2.0/src/icloud_mcp/selftest.py +105 -0
  18. icloud_mcp_server-0.2.0/src/icloud_mcp/server.py +1022 -0
  19. icloud_mcp_server-0.2.0/src/icloud_mcp/static/README.md +5 -0
  20. icloud_mcp_server-0.2.0/src/icloud_mcp/static/favicon.ico +0 -0
  21. icloud_mcp_server-0.2.0/src/icloud_mcp/static/icon-180.png +0 -0
  22. icloud_mcp_server-0.2.0/src/icloud_mcp/static/icon-32.png +0 -0
  23. icloud_mcp_server-0.2.0/src/icloud_mcp_server.egg-info/PKG-INFO +473 -0
  24. icloud_mcp_server-0.2.0/src/icloud_mcp_server.egg-info/SOURCES.txt +42 -0
  25. icloud_mcp_server-0.2.0/src/icloud_mcp_server.egg-info/dependency_links.txt +1 -0
  26. icloud_mcp_server-0.2.0/src/icloud_mcp_server.egg-info/entry_points.txt +4 -0
  27. icloud_mcp_server-0.2.0/src/icloud_mcp_server.egg-info/requires.txt +14 -0
  28. icloud_mcp_server-0.2.0/src/icloud_mcp_server.egg-info/top_level.txt +1 -0
  29. icloud_mcp_server-0.2.0/tests/test_agent_experience.py +301 -0
  30. icloud_mcp_server-0.2.0/tests/test_bridge.py +377 -0
  31. icloud_mcp_server-0.2.0/tests/test_bulk_fetch.py +102 -0
  32. icloud_mcp_server-0.2.0/tests/test_calendar_builders.py +144 -0
  33. icloud_mcp_server-0.2.0/tests/test_config.py +42 -0
  34. icloud_mcp_server-0.2.0/tests/test_contacts.py +461 -0
  35. icloud_mcp_server-0.2.0/tests/test_drive_ops.py +159 -0
  36. icloud_mcp_server-0.2.0/tests/test_local_mode.py +156 -0
  37. icloud_mcp_server-0.2.0/tests/test_lookup.py +194 -0
  38. icloud_mcp_server-0.2.0/tests/test_mac_helper.py +343 -0
  39. icloud_mcp_server-0.2.0/tests/test_mac_ops.py +330 -0
  40. icloud_mcp_server-0.2.0/tests/test_mail_builders.py +153 -0
  41. icloud_mcp_server-0.2.0/tests/test_oauth_flow.py +178 -0
  42. icloud_mcp_server-0.2.0/tests/test_oauth_logging.py +123 -0
  43. icloud_mcp_server-0.2.0/tests/test_outbox.py +267 -0
  44. icloud_mcp_server-0.2.0/tests/test_resilience.py +93 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 epinethrone
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,473 @@
1
+ Metadata-Version: 2.4
2
+ Name: icloud-mcp-server
3
+ Version: 0.2.0
4
+ Summary: MCP server for iCloud Mail, Calendar, Contacts, Reminders, Notes and iCloud Drive. Self-hosted or local, approval-first.
5
+ Author: epinethrone
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/epinethrone/icloud-mcp
8
+ Project-URL: Issues, https://github.com/epinethrone/icloud-mcp/issues
9
+ Project-URL: Security, https://github.com/epinethrone/icloud-mcp/security/policy
10
+ Keywords: mcp,model-context-protocol,icloud,apple,claude,imap,caldav,carddav,email,calendar
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Environment :: Console
13
+ Classifier: Intended Audience :: End Users/Desktop
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Operating System :: MacOS
16
+ Classifier: Operating System :: POSIX :: Linux
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Communications :: Email
21
+ Requires-Python: >=3.11
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Requires-Dist: mcp<3,>=2.2
25
+ Requires-Dist: imapclient>=3.0
26
+ Requires-Dist: caldav>=2.0
27
+ Requires-Dist: icalendar>=6.1
28
+ Requires-Dist: html2text>=2024.2.26
29
+ Requires-Dist: python-dateutil>=2.9
30
+ Requires-Dist: uvicorn>=0.30
31
+ Requires-Dist: httpx>=0.27
32
+ Provides-Extra: test
33
+ Requires-Dist: pytest>=8; extra == "test"
34
+ Requires-Dist: pytest-asyncio>=0.23; extra == "test"
35
+ Requires-Dist: aiosmtpd>=1.4; extra == "test"
36
+ Requires-Dist: radicale>=3.2; extra == "test"
37
+ Dynamic: license-file
38
+
39
+ <div align="center">
40
+
41
+ <!-- mcp-name: io.github.epinethrone/icloud-mcp -->
42
+
43
+ <img src="https://raw.githubusercontent.com/epinethrone/icloud-mcp/main/assets/logo.svg" alt="iCloud MCP logo" width="128" height="128">
44
+
45
+ # iCloud MCP
46
+
47
+ **Give Claude your iCloud: Mail, Calendar, Contacts, Reminders, Notes and iCloud Drive.**
48
+ **Self-hosted, single-owner, and built around your approval, not the model's good behaviour.**
49
+
50
+ [![Tests](https://github.com/epinethrone/icloud-mcp/actions/workflows/tests.yml/badge.svg)](https://github.com/epinethrone/icloud-mcp/actions/workflows/tests.yml)
51
+ [![License: MIT](https://img.shields.io/badge/license-MIT-2ea44f.svg)](https://github.com/epinethrone/icloud-mcp/blob/main/LICENSE)
52
+ [![Python 3.11+](https://img.shields.io/badge/python-3.11%2B-3776ab.svg?logo=python&logoColor=white)](https://github.com/epinethrone/icloud-mcp/blob/main/pyproject.toml)
53
+ [![Model Context Protocol](https://img.shields.io/badge/MCP-server-6e56cf.svg)](https://modelcontextprotocol.io)
54
+ [![Docker](https://img.shields.io/badge/docker-compose-2496ed.svg?logo=docker&logoColor=white)](https://github.com/epinethrone/icloud-mcp/blob/main/docker-compose.yml)
55
+ [![Self-hosted](https://img.shields.io/badge/self--hosted-your%20server-555.svg)](#quick-start)
56
+ [![Tools](https://img.shields.io/badge/tools-47-f28b30.svg)](#tools)
57
+
58
+ [Why](#why-icloud-mcp) · [What you can ask](#what-you-can-ask-claude) · [How it works](#how-it-works) · [Security](#security-first) · [Quick start](#quick-start) · [Run locally](#run-it-locally-claude-desktop-and-claude-code) · [Tools](#tools) · [Mac helper](#reminders-notes-and-icloud-drive-through-your-mac) · [Configuration](#configuration) · [Troubleshooting](#troubleshooting)
59
+
60
+ </div>
61
+
62
+ ---
63
+
64
+ A self-hosted [Model Context Protocol](https://modelcontextprotocol.io) server that connects **Claude** (or any MCP client) to your **Apple iCloud** account through one custom connector. Mail, Calendar and Contacts speak the standard IMAP, SMTP, CalDAV and CardDAV protocols. Reminders, Notes and iCloud Drive, which Apple only exposes on its own devices, go through an optional helper on your Mac.
65
+
66
+ > [!NOTE]
67
+ > **Not affiliated with Apple.** iCloud is a trademark of Apple Inc. This is an independent open-source project.
68
+
69
+ ## Why iCloud MCP
70
+
71
+ | Feature | What it means for you |
72
+ |---|---|
73
+ | 🍎 **All of iCloud in one connector** | 47 tools across Mail, Calendar, Contacts, Reminders, Notes and iCloud Drive, instead of a separate integration for each. |
74
+ | 🔐 **Your credentials never leave your server** | Apple offers no OAuth for these protocols, so an app-specific password lives only in your server's environment. Claude signs in to *your* server through its own single-owner OAuth and never sees it. |
75
+ | ✋ **You approve what leaves** | Outgoing mail is queued for your approval in a browser by default. Invitations to other people are blocked unless you allow them. Deletes go to the Trash. |
76
+ | 🛡️ **Built for prompt injection** | Every email, event, note and file is marked as untrusted data, and the dangerous actions are gated by configuration rather than by asking the model nicely. |
77
+ | 💻 **Server or no server** | Host it once for Claude on the web and your phone, or run it locally for Claude Desktop and Claude Code with one command: no domain, tunnel or Docker needed. |
78
+ | 🧪 **Tested against the real iCloud** | 269 offline tests on every push (Python 3.11 to 3.13), plus integration tests against local mail, calendar and contacts servers, plus manual runs against a live account for the quirks only Apple's servers show. |
79
+
80
+ ## What you can ask Claude
81
+
82
+ - *"Find the email from my landlord about the heating and draft a polite reply."*
83
+ - *"What's on my calendar next week? Move Thursday's dentist appointment to Friday at the same time."*
84
+ - *"Add Anna's new work address to her contact card."*
85
+ - *"Remind me to renew my passport on the first of next month."*
86
+ - *"Move all my recipe notes into a Recipes folder, and delete the three empty notes."*
87
+ - *"Find my tax return PDF in iCloud Drive and tell me what I paid last year."*
88
+
89
+ ## How it works
90
+
91
+ ```mermaid
92
+ flowchart TB
93
+ C["<b>Claude</b><br/>or any MCP client"] -->|"OAuth + MCP over HTTPS"| S["<b>icloud-mcp</b><br/>on your server"]
94
+ M["<b>Mac helper</b><br/>optional"] -->|"polls out over pinned TLS"| S
95
+ S -->|"IMAP · SMTP · CalDAV · CardDAV"| I["<b>iCloud</b><br/>Mail · Calendar · Contacts"]
96
+ M -->|"EventKit · scripts · files"| A["<b>On your Mac</b><br/>Reminders · Notes · iCloud Drive"]
97
+ classDef you fill:#eef6ff,stroke:#0969da,color:#0b1f33
98
+ classDef apple fill:#f6f8fa,stroke:#57606a,color:#1f2328
99
+ class S,M you
100
+ class I,A apple
101
+ ```
102
+
103
+ The server runs anywhere Docker runs (a home server, a Raspberry Pi, a small VPS) behind a public HTTPS address such as a Cloudflare Tunnel. If you only use Claude Desktop or Claude Code, you can skip all of that and [run it locally](#run-it-locally-claude-desktop-and-claude-code) instead. The Mac helper is only needed for Reminders, Notes and iCloud Drive. It connects *out* to the server, so your Mac never opens a port.
104
+
105
+ ## Security first
106
+
107
+ A connector that can read your mail and act for you is a prompt-injection target: a hostile email or calendar invite can contain text that tries to steer the agent. The server labels all such content as untrusted and tells agents to treat it as data, but **that is a request to a language model, not a guarantee**. What actually protects you is configuration:
108
+
109
+ | Risk | Default | Setting |
110
+ |---|---|---|
111
+ | Agent sends mail on injected instructions | Sending only **queues** the message. You approve it in a browser with your owner password at `/outbox` | `SEND_REQUIRES_APPROVAL=true` |
112
+ | Agent emails invitations to strangers | Attendee changes are **blocked** | `ALLOW_CALENDAR_INVITES=false` |
113
+ | Agent mails arbitrary addresses | Any address, at most 25 per message | `SEND_ALLOWLIST`, `MAX_RECIPIENTS` |
114
+ | Agent destroys mail | Delete moves to Trash; permanent delete is off | `ALLOW_PERMANENT_DELETE=false` |
115
+ | Agent destroys notes or files | Notes go to Recently Deleted, Drive files to the Trash. Nothing through the Mac helper is ever deleted permanently | always on |
116
+ | Agent changes anything at all | Everything writable | `READ_ONLY=true` for a read-only connector |
117
+
118
+ In Claude you can also set the send, reply, forward and delete tools to "ask before use". Anyone who obtains the app-specific password has **full access to mail, calendar and contacts** (Apple offers no narrower scope), so protect the server and its `.env` accordingly.
119
+
120
+ <details>
121
+ <summary><b>The full security model</b></summary>
122
+
123
+ - iCloud credentials exist only in the server environment. Clients hold short-lived bearer tokens for *this* server.
124
+ - Clients may register dynamically, but nothing is authorised without the owner password. Redirect hosts are restricted. Tokens are stored as SHA-256 hashes (file mode 600). The approval and outbox pages lock after 10 wrong passwords in 15 minutes (server-wide; existing tokens keep working).
125
+ - Every refused sign-in renewal is logged with its reason (already rotated, expired, wrong client, not recognised), never with token values, and unauthenticated callers cannot flood the log: `docker compose logs icloud-mcp | grep 'oauth:'`.
126
+ - The MCP endpoint validates `Host` and `Origin`. Tool results carry an untrusted-content notice. HTTP-client request logging is disabled so account identifiers do not reach the logs.
127
+ - The Mac bridge runs on its own private TLS port with a self-signed certificate the helper pins by fingerprint, plus a bearer token. It is never served on the public address or through the tunnel. The server sends only an operation name and validated arguments from a fixed list, never script text.
128
+ - Single-owner by design: one deployment serves one iCloud account. It is not multi-tenant, and storing other people's app-specific passwords is deliberately out of scope.
129
+
130
+ </details>
131
+
132
+ ## Quick start
133
+
134
+ > [!TIP]
135
+ > Only using Claude Desktop or Claude Code on one computer? [Run it locally](#run-it-locally-claude-desktop-and-claude-code) instead: no server, domain or tunnel.
136
+
137
+ **You need:**
138
+ - Docker with the compose plugin (or Python 3.11+)
139
+ - An Apple Account with two-factor authentication and an **app-specific password** (account.apple.com → Sign-In and Security → App-Specific Passwords)
140
+ - A public **HTTPS** address for the server. Claude connects from Anthropic's cloud, so a LAN or VPN address won't work. A [Cloudflare Tunnel](https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/) is the simplest option: outbound only, no port forwarding.
141
+ - A Claude plan that supports custom connectors
142
+
143
+ > [!WARNING]
144
+ > Don't put Cloudflare Access or any other login wall in front of the server. Claude's servers can't pass an interactive login, and the server has its own OAuth.
145
+
146
+ **1. Configure**
147
+
148
+ ```bash
149
+ git clone https://github.com/epinethrone/icloud-mcp.git && cd icloud-mcp
150
+ cp .env.example .env # fill in ICLOUD_USERNAME, ICLOUD_APP_PASSWORD, ICLOUD_DISPLAY_NAME,
151
+ # MCP_PUBLIC_URL (your https address, no trailing slash), MCP_OWNER_PASSWORD
152
+ chmod 600 .env
153
+ ```
154
+
155
+ `MCP_OWNER_PASSWORD` is a new random password (12+ characters) that **you** type when approving a client and on the outbox page. It is not your Apple password. `./configure.sh` asks for the secrets with silent prompts if you prefer.
156
+
157
+ **2. Check your credentials against the real iCloud before exposing anything**
158
+
159
+ ```bash
160
+ docker build -t icloud-mcp:local .
161
+ docker run --rm --env-file .env icloud-mcp:local python -m icloud_mcp.selftest # logs in to IMAP, SMTP, CalDAV, CardDAV; sends nothing
162
+ docker run --rm --env-file .env icloud-mcp:local python -m icloud_mcp.selftest --probe-sent you@example.com # sends ONE test mail
163
+ ```
164
+
165
+ If a login fails, the login name is the usual cause: set `IMAP_USERNAME`, `SMTP_USERNAME`, `CALDAV_USERNAME` or `CARDDAV_USERNAME` separately.
166
+
167
+ **3. Run it**
168
+
169
+ ```bash
170
+ docker compose up -d --build # listens on 127.0.0.1:8000 only
171
+ ```
172
+
173
+ For the bundled Cloudflare Tunnel: create a tunnel, point its public hostname (the host in `MCP_PUBLIC_URL`) at `http://icloud-mcp:8000`, put the token in `.tunnel.env` as `TUNNEL_TOKEN=...`, and start with `docker compose --profile tunnel up -d --build`. Any TLS front (Caddy, nginx) works too, as long as it keeps the `Host` header. `MCP_PUBLIC_URL` must match the public address exactly.
174
+
175
+ **4. Connect Claude**
176
+
177
+ Settings → Connectors → Add custom connector → `https://<your-host>/mcp`. Your server shows an approval page: enter the owner password. Reconnect the connector whenever you change tools or settings, because Claude caches tool definitions. To revoke every connected client, delete `oauth_state.json` in the data volume and restart.
178
+
179
+ **5. Check it works**
180
+
181
+ In a new chat, open the tools menu: the connector should be listed with its tools. Then try a few read-only requests:
182
+
183
+ - *"List my mail folders."*
184
+ - *"What's on my calendar this week?"*
185
+ - *"Find Anna in my contacts."*
186
+ - *"Is the Mac helper online?"* (only if you set up the Mac helper)
187
+
188
+ Then ask Claude to email yourself. With the default settings nothing is sent: the message waits at `https://<your-host>/outbox` until you approve it. If anything fails, see [Troubleshooting](#troubleshooting).
189
+
190
+ ### Approving outgoing mail
191
+
192
+ With the default `SEND_REQUIRES_APPROVAL=true`, `mail_send`, `mail_reply` and `mail_forward` return `queued_for_owner_approval` and nothing leaves. Open `https://<your-host>/outbox` (bookmark it, and only type the password there, never on a link an agent gives you), enter the owner password, review the exact recipients and text, then approve or discard. Queued messages expire after `OUTBOX_TTL_SECONDS` (24 hours by default) and are released at most once.
193
+
194
+ ## Run it locally (Claude Desktop and Claude Code)
195
+
196
+ The same server can run on your own computer as a local MCP server. Your desktop client starts it when it needs it and talks to it over stdio, so there is no public address, tunnel, Docker or OAuth. Claude on the web and on your phone cannot reach it, which is the trade-off.
197
+
198
+ **1. Put your settings in a file only you can read**
199
+
200
+ ```bash
201
+ mkdir -p ~/.icloud-mcp && chmod 700 ~/.icloud-mcp
202
+ cat > ~/.icloud-mcp/icloud.env <<'END'
203
+ ICLOUD_USERNAME=you@icloud.com
204
+ ICLOUD_APP_PASSWORD=xxxx-xxxx-xxxx-xxxx
205
+ ICLOUD_DISPLAY_NAME=Your Name
206
+ DEFAULT_TIMEZONE=Europe/Berlin
207
+ END
208
+ chmod 600 ~/.icloud-mcp/icloud.env
209
+ ```
210
+
211
+ Any setting from [Configuration](#configuration) can go in this file. `MCP_PUBLIC_URL` and `MCP_OWNER_PASSWORD` are not needed.
212
+
213
+ **2. Add it to your client** (needs [uv](https://docs.astral.sh/uv/))
214
+
215
+ Claude Code:
216
+
217
+ ```bash
218
+ claude mcp add icloud -- uvx --from git+https://github.com/epinethrone/icloud-mcp icloud-mcp --local --env-file ~/.icloud-mcp/icloud.env
219
+ ```
220
+
221
+ Claude Desktop: Settings → Developer → Edit Config, then add this to `claude_desktop_config.json` and restart Claude:
222
+
223
+ ```json
224
+ {
225
+ "mcpServers": {
226
+ "icloud": {
227
+ "command": "uvx",
228
+ "args": ["--from", "git+https://github.com/epinethrone/icloud-mcp", "icloud-mcp", "--local",
229
+ "--env-file", "/Users/YOU/.icloud-mcp/icloud.env"]
230
+ }
231
+ }
232
+ }
233
+ ```
234
+
235
+ If Claude Desktop cannot find `uvx`, use its full path (`which uvx`). Without uv, `pip install git+https://github.com/epinethrone/icloud-mcp` and use `icloud-mcp` as the command.
236
+
237
+ **How sending works locally.** There is no approval page, so with the default `SEND_REQUIRES_APPROVAL=true` every message Claude sends is saved to your **Drafts** folder instead, and the result says so. You review it in Mail and press Send yourself. Set `SEND_REQUIRES_APPROVAL=false` to let Claude send directly; your client's own "ask before use" setting is then the only check.
238
+
239
+ **Reminders, Notes and iCloud Drive locally.** Add `ENABLE_REMINDERS=true` (and/or `ENABLE_NOTES`, `ENABLE_DRIVE`) and a `BRIDGE_TOKEN` to the env file, start your client once, then [install the Mac helper](#reminders-notes-and-icloud-drive-through-your-mac) with server `https://127.0.0.1:8001` and the fingerprint from `~/.icloud-mcp/bridge_fingerprint.txt`. In local mode the bridge only listens on `127.0.0.1`. If two clients start the server at once, only the first gets the Mac tools; Mail, Calendar and Contacts work in both.
240
+
241
+ ## Tools
242
+
243
+ **24 tools** for Mail, Calendar and Contacts, plus **22** more with the optional Mac helper.
244
+
245
+ <details>
246
+ <summary><b>📧 Mail</b> (14)</summary>
247
+
248
+ | Kind | Tools |
249
+ |---|---|
250
+ | Read | `mail_list_folders`, `mail_search`, `mail_find_correspondent`, `mail_get_message`, `mail_get_messages` (up to 25 in one call), `mail_get_thread`, `mail_get_attachment` |
251
+ | Write | `mail_send`, `mail_reply` (including reply-all), `mail_forward`, `mail_mark`, `mail_move`, `mail_delete` (to Trash), `mail_create_folder` |
252
+
253
+ - Replies keep the `Re:` subject, `In-Reply-To` and `References`, the right recipients and the quoted original in plain text and HTML. Sent mail is copied to Sent and the original is flagged Answered (forwards get `$Forwarded`). `draft=true` saves to Drafts instead of sending.
254
+ - `mail_get_messages` reads a batch (a day's unread mail, a whole thread) in one IMAP round trip, about 7 times faster than one at a time.
255
+ - Reading a message does not mark it read. Bcc recipients receive the mail, but the header is stripped on the wire.
256
+ - Recipients accept `a@b.com`, `Name <a@b.com>` or `mailto:a@b.com`. Anything else is rejected with a clear error and never silently dropped.
257
+
258
+ </details>
259
+
260
+ <details>
261
+ <summary><b>📅 Calendar</b> (6)</summary>
262
+
263
+ `calendar_list_calendars`, `calendar_list_events`, `calendar_get_event`, `calendar_create_event`, `calendar_update_event`, `calendar_delete_event`
264
+
265
+ - Multiple calendars, recurring events expanded when listing, all-day events, alerts, links, notes and attendees. Editing a recurring event changes the whole series.
266
+ - **Apple travel time and map locations.** Events can carry Apple's travel time (by bike, on foot, by car or public transport) and a structured destination, which is what makes Apple draw the map card.
267
+ - **Adding a guest leaves everyone else alone.** Updating the guest list merges instead of replacing, so existing guests keep their RSVP and aren't sent the invitation again. Invitations are emailed by iCloud itself and are off unless you allow them.
268
+
269
+ </details>
270
+
271
+ <details>
272
+ <summary><b>👥 Contacts</b> (5)</summary>
273
+
274
+ `contacts_search`, `contacts_get`, `contacts_create`, `contacts_update`, `contacts_delete`
275
+
276
+ - Contacts are fetched whole, cached and searched locally by name, nickname, company, email or phone, ignoring accents. A contact with no email comes back with `has_email: false`, so an agent asks instead of guessing.
277
+ - **Misspelled names are handled.** `contacts_search` suggests similar-sounding names when nothing matches exactly, and `mail_find_correspondent` finds people you've emailed by approximate name, address or company, reading only message headers. Approximate matches are labelled, and agents must ask you to confirm before sending, inviting or editing on one.
278
+ - **Postal addresses** are read and written as street, city, region, postcode and country, with home, work or your own labels ("Holiday house"), stored the way Apple's Contacts app expects.
279
+ - Updates keep every field outside the changed ones and use ETags to refuse stale overwrites. Contact photos and notes are never returned.
280
+
281
+ </details>
282
+
283
+ <details>
284
+ <summary><b>✅ Reminders</b> (6, Mac helper)</summary>
285
+
286
+ `reminders_lists`, `reminders_list`, `reminders_create`, `reminders_update`, `reminders_complete`, `reminders_delete`
287
+
288
+ - Runs through Apple's EventKit: every read is live and takes about 20 to 40 ms, however long your lists are. Only active reminders are returned.
289
+ - List names can repeat across accounts, so tools accept a `list_id` and refuse an ambiguous name. Due dates are validated as real dates (a bare date means 09:00 local time).
290
+
291
+ </details>
292
+
293
+ <details>
294
+ <summary><b>📝 Notes</b> (7, Mac helper)</summary>
295
+
296
+ `notes_folders`, `notes_list`, `notes_read`, `notes_create`, `notes_create_folder`, `notes_move`, `notes_delete`
297
+
298
+ - Read, create, and **organise**: create folders and subfolders, and move notes between them. The text of an existing note is never edited.
299
+ - Move and delete act on one note at a time and need its **current title** as well as its id, so a stale or wrong id changes nothing.
300
+ - Delete moves a note to **Recently Deleted**, where you can recover it for about 30 days. It refuses locked notes, and notes already in Recently Deleted, because removing them from there would be permanent. Nothing is ever moved into Recently Deleted.
301
+
302
+ </details>
303
+
304
+ <details>
305
+ <summary><b>🗂️ iCloud Drive</b> (8, Mac helper)</summary>
306
+
307
+ `drive_list`, `drive_search`, `drive_info`, `drive_read`, `drive_write`, `drive_create_folder`, `drive_move`, `drive_trash`
308
+
309
+ - Works on your **whole iCloud Drive** as your Mac keeps it in sync, so every change syncs to your other devices by itself.
310
+ - `drive_read` returns text from plain text files, **PDFs** and **Word, RTF, ODT and HTML** documents. Files offloaded by "Optimise Mac Storage" are downloaded first. If that takes too long, the answer says the file is still downloading, instead of timing out.
311
+ - `drive_write` creates plain text files. Replacing a file needs `overwrite`, and the old version goes to the Trash. `drive_move` never overwrites.
312
+ - **Nothing is ever deleted permanently.** `drive_trash` moves items to the Trash, where you can recover them.
313
+ - Paths are relative to the Drive and can't leave it, not through `..` and not through a symbolic link (links that lead outside are not even listed). The Drive's trash folder is off limits.
314
+
315
+ </details>
316
+
317
+ <details>
318
+ <summary><b>🔌 Status</b> (1)</summary>
319
+
320
+ `mac_helper_status` says whether the Mac helper is online, when it was last seen and which version it runs.
321
+
322
+ </details>
323
+
324
+ ## Reminders, Notes and iCloud Drive through your Mac
325
+
326
+ Apple only exposes Reminders, Notes and iCloud Drive on its own devices, so a small helper ([`mac-helper/`](https://github.com/epinethrone/icloud-mcp/blob/main/mac-helper/README.md)) runs on your Mac and does the work when the server asks.
327
+
328
+ - **Nothing listens on your Mac.** The helper connects *out* to a private HTTPS port of the server (never the public address, never the tunnel) and long-polls for jobs.
329
+ - **No code is ever sent.** The server sends an operation name and validated arguments from a fixed list. Reminders run a small EventKit program the installer builds on your Mac. Notes run static scripts. iCloud Drive runs one fixed Python script under Apple's own Python. In every case the arguments arrive as one JSON value, never as code.
330
+ - **Pinned and authenticated.** TLS with a self-signed certificate the helper pins by fingerprint, plus a bearer token.
331
+ - **Honest when it's off.** It works while your Mac is on and reachable (home network or VPN). When it isn't, the tools say so.
332
+
333
+ Enable it in `.env` with any of `ENABLE_REMINDERS=true`, `ENABLE_NOTES=true` and `ENABLE_DRIVE=true`, a `BRIDGE_TOKEN` of at least 32 random characters, and `BRIDGE_BIND` set to the address the Mac reaches the server on. The server logs the certificate fingerprint for the installer, and also writes it to `bridge_fingerprint.txt` in its data folder. Then follow the [Mac helper guide](https://github.com/epinethrone/icloud-mcp/blob/main/mac-helper/README.md).
334
+
335
+ > [!IMPORTANT]
336
+ > **iCloud Drive needs Full Disk Access** for the helper's Python. On macOS 27 the grant only takes effect when the helper runs as the Command Line Tools `Python.app` executable, which is what the installer sets up. Details in the [Mac helper guide](mac-helper/README.md#icloud-drive).
337
+
338
+ The Notes scripts are adapted from [MrGo2/icloud-mcp](https://github.com/MrGo2/icloud-mcp) (MIT); see [THIRD_PARTY_NOTICES.md](https://github.com/epinethrone/icloud-mcp/blob/main/THIRD_PARTY_NOTICES.md).
339
+
340
+ ## Configuration
341
+
342
+ Everything is an environment variable. [`.env.example`](https://github.com/epinethrone/icloud-mcp/blob/main/.env.example) has a comment for each one.
343
+
344
+ <details>
345
+ <summary><b>All settings</b></summary>
346
+
347
+ | Variable | Default | Meaning |
348
+ |---|---|---|
349
+ | `ICLOUD_USERNAME` | required | The Apple Account you sign in with |
350
+ | `ICLOUD_APP_PASSWORD` | required | App-specific password |
351
+ | `ICLOUD_EMAIL_ADDRESS` | username | From address (your iCloud address or alias) |
352
+ | `ICLOUD_DISPLAY_NAME`, `EMAIL_SIGNATURE` | empty | Sender name; plain-text signature added to sent mail (`\n` = new line) |
353
+ | `IMAP_HOST/PORT/SECURITY/USERNAME` | `imap.mail.me.com`, 993, ssl, username | IMAP |
354
+ | `SMTP_HOST/PORT/SECURITY/USERNAME` | `smtp.mail.me.com`, 587, starttls, username | SMTP |
355
+ | `CALDAV_URL`, `CALDAV_USERNAME`, `CALDAV_REQUIRE_TLS` | `https://caldav.icloud.com`, username, true | CalDAV |
356
+ | `CARDDAV_URL`, `CARDDAV_USERNAME` | `https://contacts.icloud.com`, username | CardDAV |
357
+ | `DEFAULT_TIMEZONE`, `DEFAULT_CALENDAR` | `UTC`, auto | Timezone for times without an offset; calendar for new events (else "Calendar" or "Home", else the first) |
358
+ | `ENABLE_MAIL`, `ENABLE_CALENDAR`, `ENABLE_CONTACTS` | true | Switch whole areas off |
359
+ | `ENABLE_REMINDERS`, `ENABLE_NOTES`, `ENABLE_DRIVE` | false | Areas that go through the Mac helper (need `BRIDGE_TOKEN`) |
360
+ | `BRIDGE_TOKEN`, `BRIDGE_BIND` | empty, 127.0.0.1 | Mac helper secret (32+ characters) and the address its private port is published on |
361
+ | `BRIDGE_HOST` | 0.0.0.0 (127.0.0.1 in local mode) | Address the bridge binds to inside the process. Use 127.0.0.1 when the server runs directly on the helper's Mac |
362
+ | `BRIDGE_JOB_TIMEOUT_SECONDS` | 60 | How long a tool call waits for the Mac |
363
+ | `READ_ONLY` | false | No sending, moving, deleting, or calendar, contact, reminder, note or file changes |
364
+ | `ALLOW_SEND` | true | false = agents can only save drafts |
365
+ | `SEND_REQUIRES_APPROVAL` | true | Queue outgoing mail for browser approval |
366
+ | `OUTBOX_TTL_SECONDS`, `OUTBOX_MAX` | 86400, 20 | Queue lifetime and size |
367
+ | `ALLOW_CALENDAR_INVITES` | false | Allow attendees (iCloud then emails invitations, updates and cancellations) |
368
+ | `SEND_ALLOWLIST` | empty | Only these addresses or domains may receive mail (`@example.org,friend@example.com`) |
369
+ | `MAX_RECIPIENTS` | 25 | Per message |
370
+ | `ALLOW_PERMANENT_DELETE` | false | Allow deleting mail from Trash |
371
+ | `SAVE_SENT_COPY` | true | Copy sent mail to Sent (iCloud doesn't do it itself) |
372
+ | `MAX_BODY_CHARS`, `MAX_ATTACHMENT_BYTES` | 30000, 5 MiB | Result size caps |
373
+ | `MCP_PUBLIC_URL`, `MCP_OWNER_PASSWORD` | required | Public https address; owner password (12+ characters) |
374
+ | `MCP_HOST`, `MCP_PORT`, `MCP_EXTRA_ALLOWED_HOSTS` | 0.0.0.0, 8000, empty | Bind address and extra allowed `Host` headers |
375
+ | `MCP_STATELESS` | true | No server-side MCP sessions, so a restart never breaks a connected client ("Missing session ID") |
376
+ | `TOOL_TIMEOUT_SECONDS` | 90 | A tool call running longer is abandoned with an error instead of hanging |
377
+ | `DATA_DIR` | `./data` (`/data` in Docker) | OAuth state and the outbox |
378
+ | `OAUTH_ALLOWED_REDIRECT_HOSTS` | `claude.ai,claude.com,localhost,127.0.0.1` | Clients that may register |
379
+ | `ACCESS_TOKEN_TTL`, `REFRESH_TOKEN_TTL` | 3600, 30 days | Token lifetimes (refresh tokens rotate) |
380
+ | `LOG_LEVEL` | INFO | |
381
+
382
+ </details>
383
+
384
+ ## iCloud quirks this project works around
385
+
386
+ These only show up against Apple's real servers, never against local test servers:
387
+
388
+ - **CalDAV** rejects UID-filtered queries (`412`), so events are fetched by resource name with a scan fallback. An attendee who is the account owner is rewritten to an internal path with the address in the `EMAIL` parameter.
389
+ - **IMAP** has no `MOVE`. Moving and deleting use COPY, flag `\Deleted`, then `UID EXPUNGE` of exactly those messages (never a plain `EXPUNGE`). iCloud doesn't file sent mail by itself.
390
+ - **CardDAV** discovery ends on a different host than it starts on (follow the returned links), returns the whole address book in one request, and stores about half of all emails in grouped `itemN.EMAIL` properties with labels in `itemN.X-ABLabel`.
391
+ - **Travel time** is a number Apple stores, not a live estimate. It is never recomputed, so an origin or travel mode without a duration is refused instead of silently doing nothing.
392
+
393
+ ## Limits
394
+
395
+ - Reminders, Notes and iCloud Drive need the Mac helper and a Mac that is on. Contact photos and notes are deliberately not exposed to agents, and deleting a contact is permanent.
396
+ - One identity: aliases can't be used as the From address. Attachments that aren't text come back as base64 and are size-capped.
397
+ - Each tool call opens a fresh connection, about 1.5 to 5 seconds per call against iCloud.
398
+ - Claude doesn't show custom icons for custom connectors yet ([open request](https://github.com/anthropics/claude-ai-mcp/issues/152)). The server serves and advertises the project logo anyway (`src/icloud_mcp/static/`), so clients that do show icons, and your browser tab on the approval and outbox pages, display it.
399
+
400
+ ## Troubleshooting
401
+
402
+ <details>
403
+ <summary><b>Server and connection</b></summary>
404
+
405
+ | Symptom | Fix |
406
+ |---|---|
407
+ | `selftest` fails to log in | The login name is the usual cause. Some accounts sign in to one service with a different name: set `IMAP_USERNAME`, `SMTP_USERNAME`, `CALDAV_USERNAME` or `CARDDAV_USERNAME` separately. Use an app-specific password, never your Apple Account password. |
408
+ | Claude can't reach the connector, or the approval page never appears | `MCP_PUBLIC_URL` must match the public address exactly, with no trailing slash, and your TLS front must keep the `Host` header. Make sure no login wall such as Cloudflare Access sits in front of the server. |
409
+ | The approval or outbox page won't accept your password | After 10 wrong passwords in 15 minutes the pages lock for everyone. Wait, then use the owner password from `.env`, not your Apple password. |
410
+ | New tools or changed settings don't show up in Claude | Claude caches tool definitions. Reconnect the connector in Claude's settings and start a new chat. |
411
+ | "Missing session ID" after the server restarted | Leave `MCP_STATELESS=true` (the default). If you turned it off, reconnect the connector after every restart. |
412
+ | A tool call times out | iCloud can be slow; a call is abandoned after `TOOL_TIMEOUT_SECONDS` (90 by default). Retry, and check the server logs if it keeps happening. |
413
+
414
+ </details>
415
+
416
+ <details>
417
+ <summary><b>Mail, calendar and contacts</b></summary>
418
+
419
+ | Symptom | Fix |
420
+ |---|---|
421
+ | Claude says it sent an email but nothing arrived | That is the approval step working. Open `https://<your-host>/outbox`, review the message and approve it. Queued mail expires after `OUTBOX_TTL_SECONDS`. |
422
+ | Adding a guest to an event is refused | Invitations are off by default. Set `ALLOW_CALENDAR_INVITES=true` if you want Claude to invite people. |
423
+ | Mail to a certain address is refused | Check `SEND_ALLOWLIST` and `MAX_RECIPIENTS`. |
424
+ | Sent mail doesn't appear in Sent | iCloud doesn't file sent mail by itself. Keep `SAVE_SENT_COPY=true` (the default). |
425
+
426
+ </details>
427
+
428
+ <details>
429
+ <summary><b>Mac helper: Reminders, Notes and iCloud Drive</b></summary>
430
+
431
+ | Symptom | Fix |
432
+ |---|---|
433
+ | Tools say the Mac helper is offline | The Mac must be on, awake, logged in and able to reach the bridge address (home network or VPN). Ask *"Is the Mac helper online?"*, and check `~/Library/Logs/icloud-mac-helper/helper.log` on the Mac. |
434
+ | The helper log shows "No route to host" | macOS blocks third-party Python from the local network. Use Apple's Python (the installer picks it), or allow it under Privacy & Security > Local Network. |
435
+ | Reminders are refused | Allow Full Access to Reminders for "iCloud Mac Helper (Reminders)" under Privacy & Security > Reminders, then run the helper's self-test. |
436
+ | Notes are refused ("not allowed to control") | Allow the helper's Python to control Notes under Privacy & Security > Automation. |
437
+ | iCloud Drive says the helper has no access | Give Full Disk Access to the Command Line Tools `Python.app`, and make sure the helper runs as that executable (re-run the installer). See the [Mac helper guide](mac-helper/README.md#icloud-drive). |
438
+ | Reading a Drive file says it is still downloading | The file was only in iCloud ("Optimise Mac Storage"). Its download has started; ask again in a minute. |
439
+
440
+ </details>
441
+
442
+ ## Contributing
443
+
444
+ Issues and pull requests are welcome.
445
+
446
+ - **Security problems:** please don't open a public issue. Follow the [security policy](https://github.com/epinethrone/icloud-mcp/blob/main/SECURITY.md) instead.
447
+ - **Before a pull request:** make sure `pytest tests --ignore=tests/integration` passes, and add tests for new behaviour. They run automatically on every pull request.
448
+ - **Anything that talks to iCloud:** run `selftest`, and try it by hand against a real account. Local test servers accept things iCloud doesn't.
449
+ - **New tools:** keep the safety defaults intact. Anything that sends, invites or deletes must stay behind the existing settings, and anything read from iCloud must be treated as data, never as instructions.
450
+
451
+ ## Development
452
+
453
+ ```bash
454
+ python -m venv .venv && . .venv/bin/activate
455
+ pip install -e ".[test]"
456
+ pytest tests --ignore=tests/integration # offline tests, no network
457
+ sudo apt install dovecot-imapd && dev/start_local_stack.sh
458
+ pytest tests # adds integration tests against local Dovecot, an SMTP sink and Radicale
459
+ ```
460
+
461
+ `dev/e2e_http.py` drives a running server over HTTP (OAuth plus tool calls). Local test servers accept things iCloud doesn't (see the quirks above), so treat `selftest` and a manual run against a real account as part of testing any change.
462
+
463
+ ## Acknowledgements
464
+
465
+ Built on the [MCP Python SDK](https://github.com/modelcontextprotocol/python-sdk), [IMAPClient](https://github.com/mjs/imapclient), [caldav](https://github.com/python-caldav/caldav), [icalendar](https://github.com/collective/icalendar), [html2text](https://github.com/Alir3z4/html2text), [python-dateutil](https://github.com/dateutil/dateutil), [Uvicorn](https://github.com/encode/uvicorn) and [HTTPX](https://github.com/encode/httpx). The Notes scripts are adapted from [MrGo2/icloud-mcp](https://github.com/MrGo2/icloud-mcp) (MIT).
466
+
467
+ ## License
468
+
469
+ [MIT](https://github.com/epinethrone/icloud-mcp/blob/main/LICENSE).
470
+
471
+ <div align="center">
472
+ <sub>Built for people who want an AI assistant for their Apple life without handing their Apple ID to anyone.</sub>
473
+ </div>