Skip to content

MCP host integration

icloud-mcp is a stdio MCP server. A compatible host starts the process and connects its standard input and output to JSON-RPC. The binary reads only its process environment. It does not read .env files or host configuration files.

  1. Follow the quick start.
  2. Give the host the absolute path to icloud-mcp.
  3. Pass each required environment variable as a string.
  4. Use stdio as the transport.
  5. Keep stdout exclusively for JSON-RPC.
  6. Send stderr to the host log collector.
  7. After an environment change, start the process again.

For the first deployment, choose one of the three read-only profiles below. Use icloud_capabilities to show the enabled domains, capabilities, and tool list. This call uses local configuration and makes no account request.

The local binary can return account data to the configured MCP host and model. Their policies govern onward transmission. Stdio is not a privacy boundary against that host or model. Review those policies before any account read.

Exactly 17 product environment variables:

Variable Default Contract
ICLOUD_EMAIL none Required Calendar/Contacts identity. file:// supported (regular file, <=4 KiB, mode 0600+).
ICLOUD_PASSWORD none Calendar/Contacts app-specific password, or Mail fallback when no separate Mail password is set. file:// as above.
ICLOUD_MCP_READ_ONLY false Global mutation kill switch.
ICLOUD_MCP_PERMISSIONS reads only Optional comma-separated capability list. Name every effect.
ICLOUD_MCP_RESOURCE_SCOPES all resources Optional action resource allowlists for Calendar paths, Contacts address books, Mail mailboxes, and Reminders lists.
ICLOUD_MCP_LOG_LEVEL info Stderr level. See the accepted forms below.
ICLOUD_MCP_DEFAULT_TZ UTC IANA zone for offset-less Calendar inputs and recurring-write fallback.
ICLOUD_MCP_ENABLE_CONTACTS false Contacts reads. Writes require contacts.write or contacts.delete.
ICLOUD_MCP_ENABLE_MAIL false Mail reads. Requires a Mail address and password.
ICLOUD_MAIL_ADDRESS none Full IMAP/SMTP address when Mail is on. file:// as above.
ICLOUD_MAIL_FROM ICLOUD_MAIL_ADDRESS Optional sender for From and MAIL FROM, such as an iCloud+ custom-domain address. Login stays on ICLOUD_MAIL_ADDRESS. ASCII only. file:// as above; an empty file is an error.
ICLOUD_MAIL_PASSWORD ICLOUD_PASSWORD Optional dedicated Mail app password. file:// as above.
ICLOUD_MCP_ENABLE_MAIL_WRITE false Compatibility gate. Mutation tools require mail.mutate or mail.trash.
ICLOUD_MCP_ENABLE_MAIL_SEND false Compatibility gate. Send tools require mail.send.
ICLOUD_MCP_SMTP_ALLOWED_RECIPIENTS none Required if send is on. Use exact addresses or literal *. Literal * causes a boot warning. Use exact addresses when possible.
ICLOUD_MCP_ENABLE_REMINDERS false Reminders reads on macOS 14 or later through the local helper. Writes require reminders.write or reminders.delete. Needs no Apple ID variable. See Reminders.
ICLOUD_MCP_DRAFTS_MAILBOX none Drafts mailbox for create_draft. The server uses it only when no mailbox has SPECIAL-USE \Drafts. Set Drafts for iCloud. Requires mail.drafts.

Booleans accept only unset, 0, false, 1, or true. Invalid values cause a boot failure. The server validates the configuration before network access. Hosts must pass these values as strings. Quote a boolean in YAML, for example ICLOUD_MCP_READ_ONLY: "false". An unquoted YAML boolean fails host validation before the server starts.

Mail write or send without Mail causes a boot error. Mail without an address or password also causes a boot error. Send without a recipient policy causes a boot error, including in read-only mode. The Mail write and send flags are compatibility gates only: they never grant a tool. Global read-only can coexist with them, but it prevents registration of any effect.

ICLOUD_MCP_RESOURCE_SCOPES uses action=value[,value] entries separated by ;. Actions are calendar.read, calendar.write, calendar.delete, contacts.read, contacts.write, contacts.delete, mail.read, mail.mutate, mail.archive, reminders.read, reminders.write, and reminders.delete. A single value * means unrestricted. Calendar values are paths. Contacts values are opaque identifiers or exact display names. Mail values are exact mailbox names. Reminders values are list identifiers, at most 50 for each action. A delete scope falls back to the write scope, then to the read scope. A write, delete, or mutate scope falls back to the domain read scope when unset. Ambiguous or stale Contacts names fail closed. Unknown, duplicate, empty, or malformed entries fail before network access.

ICLOUD_MCP_PERMISSIONS accepts calendar.read, calendar.write, calendar.delete, calendar.schedule, contacts.read, contacts.write, contacts.delete, mail.read, mail.mutate, mail.trash, mail.send, mail.archive, mail.attachments.read, mail.attachments.send, mail.drafts, reminders.read, reminders.write, and reminders.delete. The attachment and draft tokens need mail.read. mail.attachments.send also needs mail.send. Unknown, duplicate, or empty tokens cause a boot error. A Contacts, Mail, or Reminders token needs its domain switch. A list with only reminders.* tokens needs no Apple ID email or password. An unset or empty value grants reads only for the enabled domains. Name every effect. The Mail write and send flags do not add one. Global read-only still removes every mutation and send tool. calendar.schedule is a separate operator grant for group-scheduled mutations. It requires calendar.write or calendar.delete and still needs the per-call acknowledge_scheduling acknowledgement and a fresh strong ETag. A model with only calendar.write cannot self-authorize those mutations.

The server trims log levels and ignores case. It accepts debug or -4, info, warn, warning, or 2, and error or 4. Unset or unrecognized values use info.

Enabled domains start independently. Calendar and Contacts discovery runs on the first call for that domain. A temporary Calendar outage does not stop Mail or Contacts. Mail-only operation does not require Calendar credentials or Calendar discovery. Reminders start no helper at boot: the first Reminders tool call or icloud_capabilities starts it on demand.

Use -version to print the version. The optional -health 127.0.0.1:port flag serves /healthz and /status on loopback. Both endpoints return JSON with domains and rate limits. Enabled domains start as not_checked; health polling does not create hidden network traffic. The optional -audit-format=json|text flag selects the mutation audit format on stderr. The default format is json.

These complete JSON files use Claude Desktop’s mcpServers stdio shape. Merge exactly one icloud entry into your host configuration. Replace the absolute command and secret paths. Do not put passwords in JSON. Each secret file must be regular, at most 4 KiB, and mode 0600 or stricter. The binary does not expand ~ or shell variables in paths.

Profile Explicit permissions Resources
Calendar calendar.read All calendars, reads only
Calendar and Contacts calendar.read,contacts.read All calendars and address books, reads only
Mail mail.read Exact mailbox INBOX

All three set ICLOUD_MCP_READ_ONLY=true. No mutation or send tool is registered. They also set an explicit permission list. Unrelated optional gates cannot add capabilities to that list. Contacts and Mail permission tokens still require their domain gate; a missing gate causes a boot error, not implicit access.

Mail-only uses ICLOUD_MAIL_ADDRESS and a separate ICLOUD_MAIL_PASSWORD. It needs neither ICLOUD_EMAIL nor ICLOUD_PASSWORD. It constructs no Calendar or Contacts client. Calendar and Contacts share the configured identity but keep separate credential copies and transports. Mail keeps its own credentials and transports.

Replace INBOX only with an exact authorized mailbox name. Optional read scopes use the same grammar described above.

Effectful opt-in, not a first-run recommendation

Section titled “Effectful opt-in, not a first-run recommendation”
Profile Explicit permissions Authorized effects
Scoped Calendar writes calendar.read,calendar.write Create and update in selected calendars; no delete
Exact-recipient Mail send mail.send Send only to the exact recipient policy; no reads, reply, IMAP mutation, or Sent APPEND

Both deliberately set ICLOUD_MCP_READ_ONLY=false. Select one only after you authorize its effects. A host approval prompt does not replace server-side scopes.

The Calendar example sets both read and write scopes to /cal/allowed/. This synthetic path is not an account path. First obtain paths with the read-only Calendar profile and an authorized list_calendars call. Copy the exact selected paths into both scope entries. Use commas to select more than one calendar. Do not use * for a mutation scope. A scope restricts an existing capability; it never grants the capability. Global read-only still removes these write tools.

The send example uses the non-deliverable placeholder recipient@example.invalid. Replace it with exact recipients that you explicitly authorize. Each To, Cc, and Bcc recipient must match. Mixed allowed and forbidden recipients fail before SMTP submission. Never use *. The profile does not enable reply_message, Mail reads, or Sent archival. Render real mail with the canonical template workflow described in Mail compatibility and authorize each submission.

With explicit permissions, mail.send replaces the legacy send switch as the capability grant. This example also sets the send switch to show deliberate intent. Removing that switch alone does not revoke an explicit mail.send grant. Remove the permission or enable global read-only to revoke it, then restart.

Run these commands from a source checkout with the documented Go toolchain and Python 3. Choose a new absolute evidence directory outside the checkout:

Terminal window
GOMAXPROCS=4 GOFLAGS=-p=4 python3 cmd/icloud-mcp/setup_profiles_test.py \
--output /absolute/private/evidence/profiles-run-1
GOMAXPROCS=4 go test -p 4 -race -json ./internal/mcptools ./cmd/icloud-mcp \
-run '^TestSetupProfiles' -count=1 -timeout=120s \
> /absolute/private/evidence/profiles-tests.jsonl

The Python check builds the actual binary. It reads the committed JSON, substitutes only synthetic secret paths and the test binary, then initializes MCP over stdio. It checks tools/list, icloud_capabilities, disabled-tool calls, and clean exit. It uses an isolated HOME and synthetic mode-0600 secret files. It never calls a live account tool or -doctor. Dependencies must already be available for a fully disconnected build. Keep the result JSON, transcripts, and fixture identities private.

The Go scenarios load the same files and clear inherited ICLOUD_* values. They verify exact manifests, unrelated gates, missing domain gates, safe read-only defaults, explicit profiles, and denied effects. Genuine handlers and services use counted synthetic DAV and verified STARTTLS Mail peers. Allowed writes and send must act exactly once; forbidden resources and recipients must fail before backend access without disclosure.

This validates offline host JSON, CLI startup, and MCP behavior. It does not prove a desktop GUI installation, Apple compatibility, or distribution installation. After configuring your real host, compare tools/list with icloud_capabilities.tools before any account call. Verify the enabled domains and capabilityGroups, not only the tool count. icloud_capabilities does not display resource paths or recipients; review those exact values in your local configuration as well.

-doctor is a separate authenticated read-only network operation, not an offline profile validator. It runs bounded probes and exits. Each enabled domain has a 10-second timeout. Exit status is 0 when all enabled domains are ready, 1 on a failed probe, and 2 for an invalid output format.

The diagnostic discovers Calendar collections and Contacts address books. For Mail, it lists mailboxes and can select one read-only to inspect capabilities. It does not apply MCP resource filtering to these discovery probes. It never submits SMTP, verifies recipient delivery, or makes account changes. It prints no identities, passwords, secret paths, or resource names.

Only run it after separate authorization for those diagnostic reads. For the unrestricted Calendar read-only profile, use the same identity and permissions:

Terminal window
env -i \
ICLOUD_EMAIL=file:///Users/you/.config/icloud-mcp/email \
ICLOUD_PASSWORD=file:///Users/you/.config/icloud-mcp/password \
ICLOUD_MCP_READ_ONLY=true ICLOUD_MCP_PERMISSIONS=calendar.read \
/Users/you/go/bin/icloud-mcp -doctor -doctor-format=json

Replace only the absolute paths. Contacts diagnostics also need the Contacts read permission and domain gate. For scoped Calendar or Mail profiles, doctor can discover outside the MCP resource allowlist. Do not treat its output as scope conformance. Do not run doctor under the send-only profile: it would attempt IMAP diagnostics despite the absence of mail.read. Validate send capabilities locally instead. Use a separately authorized read configuration if broader network diagnostics are needed. Do not remove scopes or add permissions merely to make a diagnostic pass.

The v1.0.0 default is read-only. With no ICLOUD_MCP_PERMISSIONS, an unset ICLOUD_MCP_READ_ONLY, and any credential set, the server exposes no effectful Calendar, Contacts, or Mail tool.

  • A domain switch enables reads only. ICLOUD_MCP_ENABLE_CONTACTS, ICLOUD_MCP_ENABLE_MAIL, ICLOUD_MCP_ENABLE_MAIL_WRITE, and ICLOUD_MCP_ENABLE_MAIL_SEND never grant an effect.
  • ICLOUD_MCP_READ_ONLY=false does not grant an effect.
  • Name each effect in ICLOUD_MCP_PERMISSIONS, then keep the required domain gate and any exact recipient or resource scope.
  • ICLOUD_MCP_READ_ONLY=true still removes every mutation and send, even when the permission list names one.

Migration from a v0.x configuration that relied on implicit writes:

# before: write tools appeared without ICLOUD_MCP_PERMISSIONS
ICLOUD_MCP_READ_ONLY=false
# after: name the exact Calendar effects
ICLOUD_MCP_READ_ONLY=false
ICLOUD_MCP_PERMISSIONS=calendar.read,calendar.write,calendar.delete

Contacts add contacts.write or contacts.delete; Mail adds mail.mutate, mail.trash, mail.send, or mail.archive. Keep ICLOUD_MCP_READ_ONLY=true for read-only users. Validate the resulting manifest before an authorized operation.

  • Calendar input start and end accept RFC3339 with an offset. They also accept wall-clock values without an offset in ICLOUD_MCP_DEFAULT_TZ. Use values without an offset for the user’s local time. Recurring creates and creates with an explicit timezone write TZID and VTIMEZONE. Non-recurring timed creates default to UTC Z on the wire. All-day creates use VALUE=DATE.
  • Calendar output uses RFC3339 for timed events. It always includes an explicit numeric offset in ICLOUD_MCP_DEFAULT_TZ, never bare Z. All-day dates use YYYY-MM-DD. See calendar_capabilities.outputFormat.
  • Contacts birthdays: write YYYY-MM-DD only.
  • Mail search: since inclusive, before exclusive (YYYY-MM-DD).

Host field names differ. Use the host’s custom stdio server option. The following JSON object shows the required process configuration:

{
"mcpServers": {
"icloud": {
"command": "/Users/you/.local/bin/icloud-mcp",
"env": {
"ICLOUD_EMAIL": "file:///private/path/icloud-email",
"ICLOUD_PASSWORD": "file:///private/path/icloud-password",
"ICLOUD_MCP_READ_ONLY": "true",
"ICLOUD_MCP_PERMISSIONS": "calendar.read",
"ICLOUD_MCP_ENABLE_CONTACTS": "false",
"ICLOUD_MCP_ENABLE_MAIL": "false",
"ICLOUD_MCP_ENABLE_MAIL_WRITE": "false",
"ICLOUD_MCP_ENABLE_MAIL_SEND": "false",
"ICLOUD_MCP_DEFAULT_TZ": "Europe/Paris"
}
}
}
}

Use absolute paths for the binary and secret files. Each secret file must be a regular file of 4 KiB or less. Its mode must be 0600 or stricter.

Pass boolean values as strings. For YAML hosts, quote every boolean:

ICLOUD_MCP_READ_ONLY: "true"
ICLOUD_MCP_ENABLE_CONTACTS: "false"

An unquoted YAML boolean becomes a host-side boolean. Some hosts reject it before the server starts. See the configuration reference for all 17 product variables.

Stdio transports reserve stdout for MCP traffic. The server writes operational logs and mutation audit records to stderr. Mutation audits use JSON by default.

A supervisor can enable the optional loopback health endpoint:

Terminal window
icloud-mcp -health 127.0.0.1:8797
curl --fail http://127.0.0.1:8797/healthz

The endpoint returns JSON status, enabled domains, and rate limits. The listener accepts loopback addresses only. Give each process a different port.

One process uses one iCloud identity. Start a separate process for each account. Give each process a separate environment and server name.

Use separate secret files for each account. A host uses the server name to identify each tool set.

  • For Calendar writes, use wall-clock values without an offset. Set ICLOUD_MCP_DEFAULT_TZ to the owner’s IANA time zone.
  • Calendar responses use RFC3339 with an explicit offset in that zone. See calendar_capabilities.outputFormat.
  • For create_event and create_contact, use client_uid or its idempotency_key alias as the resource UID.
  • For update_event and update_contact, use idempotency_key with a strong etag.
  • Known update results stay for 15 minutes. Uncertain results stay until process exit. See the update contract.
  • Match the structured code field. See error-codes.md.
  • Obey retry_after_seconds for rate_limited and unavailable errors.
  • After an outcome_unknown update, read the resource before you select a new key.
  • If the update cache is full, keep the key and wait for capacity.

MCP annotations are untrusted hints, not an authorization boundary. The server still enforces permissions, ETag preconditions, and allowlists on every call.

  • Treat destructiveHint=true as a request for explicit confirmation. This includes update_event, update_contact, update_reminder, every delete, move, trash, and send tool, because a call can clear, replace, remove, or permanently deliver data.
  • destructiveHint=false marks additive creates and the reversible flag delta.
  • idempotentHint=false means a repeated call can have an additional effect. Calendar and Contact updates change SEQUENCE, DTSTAMP, ETag, or synchronization state. A repeated conditional write can also fail with concurrent_modification.
  • delete_event and delete_contact are idempotent in outcome: the resource stays absent. A repeated call can still return not_found or an ETag precondition error.
  • send_message and reply_message are never automatically retried, and their idempotency_key is process-local and time-bounded.