omarshahine/apple-pim
About
Native macOS integration for Calendar, Reminders, and Contacts using EventKit and Contacts frameworks
Productivity & AutomationWhat you can do
- Calendar Management: List calendars, create/read/update/delete events, search by date/title, attendee support (add/replace attendees via CalDAV invitation emails), event availability including subscribed calendars. See Calendar store read path
- Reminder Management: List reminder lists, create/complete/update/delete reminders, search. Reads include sections, subtasks, tags, flags, rich links and attachments from the Reminders database; flags, subtasks, sections and tags can be written through opt-in, verified ReminderKit calls. See Reminders metadata
- Contact Management: List groups, create/read/update/delete contacts, search by name/email/phone, birthday support (with or without year)
- Mail Integration: List accounts/mailboxes, read/search/send/reply/move/delete messages, update flags, attachment support (metadata, save-to-disk, send/reply with attachments), verify sender authentication
Measured star growth
- in 24h
- 0
- in 7 days
- Collecting history
- in 15 days
- Collecting history
- in 1 month
- Collecting history
Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.
README.md
OriginalApple PIM: Calendar, Reminders, Contacts, Mail
PIM = Personal Information Manager.
GitHub: github.com/omarshahine/apple-pim
Native macOS integration for Calendar, Reminders, Contacts, and Mail using EventKit, Contacts, SQLite, and JXA frameworks. Works with Claude Code (via MCP) and OpenClaw (via native tool registration).
Features
- Calendar Management: List calendars, create/read/update/delete events, search by date/title, attendee support (add/replace attendees via CalDAV invitation emails), event availability including subscribed calendars. See Calendar store read path
- Reminder Management: List reminder lists, create/complete/update/delete reminders, search. Reads include sections, subtasks, tags, flags, rich links and attachments from the Reminders database; flags, subtasks, sections and tags can be written through opt-in, verified ReminderKit calls. See Reminders metadata
- Contact Management: List groups, create/read/update/delete contacts, search by name/email/phone, birthday support (with or without year)
- Mail Integration: List accounts/mailboxes, read/search/send/reply/move/delete messages, update flags, attachment support (metadata, save-to-disk, send/reply with attachments), verify sender authentication
- Fast Local Mail Reads: Read commands query Apple Mail's local Envelope Index (SQLite) directly — 10–200× faster than AppleScript automation, and they work even when Mail.app is closed. Automatic fallback to JXA when Full Disk Access isn't granted. See Direct SQLite read path
- Recurrence Rules: Create recurring events and reminders (daily, weekly, monthly, yearly)
- Batch Operations: Create multiple events or reminders in a single efficient transaction
- Per-Domain Control: Enable or disable entire domains (calendars, reminders, contacts, mail) independently
- Multi-Agent Isolation: Per-call config/profile overrides for workspace isolation
- Works with Claude Code and OpenClaw: Same Swift CLIs, different integration layers
Prerequisites
- macOS 13.0 or later
- Swift 5.9 or later (comes with Xcode 15+)
- Node.js 18+ for the MCP server; Node.js 22.13+ for the OpenClaw plugin (your OpenClaw host may require a newer version)
- Mail.app must be running for mail mutations, sends, and content search (it is not launched automatically). Mail reads use the local SQLite index and work with Mail.app closed.
Installation
Swift CLI Tools (Required for both platforms)
# Build the Swift CLIs
./setup.sh
# Optional: install to PATH for system-wide access
./setup.sh --install
# Add to your shell profile (if not already there)
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
The --install flag copies the binaries into ~/.local/bin/, so the
install keeps working even if you later move, rename, or clean this
checkout. After a rebuild, re-run ./setup.sh --install to refresh them.
Developing the CLIs themselves? ./setup.sh --install --link symlinks
instead, so every swift build -c release updates the installed commands
in place — at the cost that moving or renaming the repo breaks the links.
Verify any install with:
scripts/doctor.sh # add --fix to reap a stuck helper process
Claude Code Plugin
Inside Claude Code, run:
/plugin marketplace add omarshahine/apple-pim
/plugin install apple-pim@apple-pim
Then build the Swift CLIs (once, from a shell — the glob tolerates any marketplace name and version):
bash ~/.claude/plugins/cache/*/apple-pim/*/setup.sh --install
Restart Claude Code to load the MCP server. The pim-assistant agent triggers automatically when you mention scheduling, reminders, contacts, or email.
OpenClaw Plugin
# Install from ClawHub
openclaw plugins install apple-pim-cli
# Or install from npm
npm install -g apple-pim-cli
Under the hood, the plugin spawns native macOS Swift binaries (calendar-cli, reminder-cli, contacts-cli, mail-cli) that interact with EventKit, Contacts, and Mail.app via Apple's frameworks.
Prerequisites: Swift CLIs must be on PATH (run ./setup.sh --install first).
Optionally, configure the binary location if the CLIs are not on PATH:
# In your OpenClaw config:
# plugins.entries.apple-pim-cli.config.binDir = "/path/to/swift/.build/release"
Post-Installation (both platforms)
Grant permissions: On first use, macOS will prompt for Calendar, Reminders, and Contacts access. Grant these permissions in System Settings > Privacy & Security.
Mail.app Automation: For mail features, you also need to grant Automation permission:
- System Settings > Privacy & Security > Automation
- Allow Terminal (or your IDE) to control Mail.app
Full Disk Access (optional, recommended): Mail read commands use a fast
direct-SQLite path (see "Direct SQLite read path" below) that requires Full Disk
Access for Terminal (or the MCP host); without it, --engine auto silently
falls back to the slower Mail.app Automation path and --engine sqlite reports
the missing grant as an error. update, move, delete, batch-update and
batch-delete consult that same index for the message's row-id before
writing — the write itself always goes through Mail.app either way — so the
grant governs their lookup on the same terms, with Mail.app's
mailbox-by-mailbox scan as the auto fallback. Calendar uses the same grant to
read subscribed calendars' availability (see "Calendar store read path" below).
Development Installation
git clone https://github.com/omarshahine/apple-pim.git
cd apple-pim
./setup.sh
Then inside Claude Code, add the local checkout as a marketplace:
/plugin marketplace add /absolute/path/to/apple-pim
/plugin install apple-pim@apple-pim
For OpenClaw (loads TypeScript directly, no build step):
openclaw plugins install -l ./openclaw
Configuration
The plugin includes a full access control system (PIMConfig) that lets you restrict which calendars, reminder lists, and domains each agent can see. This is useful for:
- Access control — allowlist or blocklist specific calendars and reminder lists
- Privacy — hide calendars you don't need the agent to see
- Reducing noise — only show relevant reminder lists
- Avoiding conflicts — disable mail here if you use a separate email MCP
- Multi-agent setups — give each agent a profile with different access
- Read-only calendars — let agents see but not modify certain calendars
Interactive Setup (Claude Code)
/apple-pim:configure
CLI Config Commands
# Show current effective configuration
calendar-cli config show
reminder-cli config show
# Initialize config from available calendars/lists
calendar-cli config init
reminder-cli config init
Manual Configuration
Config files are stored at ~/.config/apple-pim/:
~/.config/apple-pim/
├── config.json # Base configuration
└── profiles/
├── work.json # Work agent profile
└── personal.json # Personal agent profile
Base config (~/.config/apple-pim/config.json):
{
"calendars": {
"enabled": true,
"mode": "allowlist",
"items": ["Personal", "Work"]
},
"reminders": {
"enabled": true,
"mode": "allowlist",
"items": ["Reminders", "Shopping"]
},
"contacts": {
"enabled": true,
"mode": "all",
"items": []
},
"mail": {
"enabled": true
},
"default_calendar": "Personal",
"default_reminder_list": "Reminders"
}
Configuration Options
| Option | Values | Description |
|---|---|---|
enabled |
true, false |
Enable or disable an entire domain |
mode |
allowlist, blocklist, all |
How to filter items (calendars/reminders/contacts) |
items |
List of names | Calendar/list names to allow or block (emoji prefixes are matched fuzzy) |
default_calendar |
Calendar name | Where new events are created when no calendar is specified |
default_reminder_list |
List name | Where new reminders are created when no list is specified |
Filter Modes
- allowlist: Only listed items are accessible
- blocklist: All EXCEPT listed items are accessible
- all: No filtering (default if no config file exists)
Filtering applies per domain: calendars filter by calendar name, reminders by list name, contacts by account container name (e.g. "iCloud", "Work Exchange", "Personal Gmail"). Use contacts-cli containers to see available account names.
Profiles
Profiles let you give different agents different access to your PIM data. Each profile overrides specific domain sections from the base config — fields not in the profile are inherited from the base.
Profile selection (in priority order):
--profile workCLI flag (on the subcommand)APPLE_PIM_PROFILE=workenvironment variable- Tool parameter
profile: "work"(OpenClaw only) - No profile — base config only
Example profile (~/.config/apple-pim/profiles/work.json):
{
"calendars": {
"enabled": true,
"mode": "allowlist",
"items": ["Work"]
},
"contacts": {
"enabled": true,
"mode": "allowlist",
"items": ["Work Exchange"]
},
"mail": {
"enabled": false
},
"default_calendar": "Work"
}
Domain Enable/Disable
Set enabled: false on any domain to disable it. When disabled, CLI commands for that domain return an access denied error.
Sender Authentication (mail auth-check)
The auth_check action verifies email sender identity by parsing DKIM and SPF results from Authentication-Results headers and cross-referencing against a trusted senders list.
Config file: ~/.config/apple-pim/trusted-senders.json
{
"version": 1,
"trustedSenders": [
{
"name": "Alice",
"emails": ["[email protected]"],
"expectedDkimDomains": ["example.com", "messagingengine.com"],
"requireSpf": true
},
{
"name": "Bob (relaxed SPF)",
"emails": ["[email protected]"],
"expectedDkimDomains": ["company.com"],
"requireSpf": false
}
]
}
Fields per sender:
| Field | Type | Default | Description |
|---|---|---|---|
name |
string | required | Display name for the verdict |
emails |
string[] | required | Email addresses to match (case-insensitive) |
expectedDkimDomains |
string[] | [] |
DKIM signing domains to accept (matches exact or subdomain) |
requireSpf |
boolean | true |
Require SPF pass for "verified" verdict |
expectedDkimDomains is what makes verified reachable: a DKIM signature from a domain you
listed for that sender is the only evidence that binds a mailbox to a signer. An enrolled
sender with no signing domains listed can never be verified, and auth-check says so in its
warnings.
Some receivers, including Gmail for some messages, report a DKIM pass and header.i
(the signing agent identity) without header.d (the signing domain). A pass without an
explicit signing domain cannot satisfy expectedDkimDomains. In this case auth-check
reports the DKIM pass with a warning explaining that the signer was not reported; it does
not infer the signing domain from header.i.
There is deliberately no requireDkim. SPF authenticates an envelope domain, so on any
shared domain (gmail.com, a company domain, a hosting provider) every user of it passes
aligned SPF and would authenticate as every other. Waiving DKIM would leave nothing
per-sender behind a verified verdict. requireSpf: false is still supported, because
relaying breaks SPF while DKIM survives it, and DKIM already carried the mailbox claim.
Existing config files carrying requireDkim still load; the key is ignored.
Verdicts:
| Verdict | Meaning |
|---|---|
verified |
DKIM and SPF checks pass per sender config |
suspicious |
Sender is trusted but authentication failed or domain mismatch |
untrusted |
Sender email not found in trusted-senders.json |
unknown |
Cannot determine (missing headers, parse failure, no config file) |
Usage:
# CLI
mail-cli auth-check --id "<[email protected]>"
mail-cli auth-check --id "<message-id>" --trusted-senders ~/custom/senders.json
# MCP tool
mcp__plugin_apple-pim_apple-pim__mail({ action: "auth_check", id: "<message-id>" })
# OpenClaw tool
apple_pim_mail({ action: "auth_check", id: "<message-id>" })
The --trusted-senders flag overrides the default config path. If the file doesn't exist, the verdict is unknown with a warning.
Date Output Format
Set APPLE_PIM_DATE_FORMAT to control how CalendarCLI formats dates in JSON output. This helps LLM agents avoid wasting tokens computing day-of-week from raw ISO dates.
| Preset | Example |
|---|---|
utc (default) |
2026-03-20T14:00:00Z |
local |
2026-03-20T07:00:00-07:00 |
day-utc |
Friday, 2026-03-20T14:00:00Z |
day-local |
Friday, 2026-03-20T07:00:00-07:00 |
# Set in your shell profile or agent environment
export APPLE_PIM_DATE_FORMAT=day-local
No env var = utc (current behavior, fully backwards compatible). CalendarCLI only; ReminderCLI uses a different date codepath.
Notes
- Config is read fresh on each CLI invocation — changes take effect immediately
- No config file = all domains enabled, all items accessible (backwards compatible)
- Existing malformed or unreadable config files cause an error; they never fall back to all-access defaults
- A domain left out of the base config keeps its default (enabled, mode
all); a section such as{"enabled": false}is complete, butitemswithout amodeis an error - Write operations to blocked calendars/lists fail with a descriptive error message
- Profile names are validated — path traversal attempts are rejected
Multi-Agent Setup
When running multiple agents, each can have its own profile or config directory for isolated PIM access. See docs/multi-agent-setup.md for the full guide.
Quick start: Create profiles in ~/.config/apple-pim/profiles/ and assign them per agent:
# Environment variable
APPLE_PIM_PROFILE=travel
# OpenClaw tool parameter (per-call isolation)
apple_pim_calendar({ action: "list", profile: "travel" })
apple_pim_calendar({ action: "list", configDir: "~/agents/travel/apple-pim" })
Usage
Claude Code Commands
/apple-pim:calendars list # List all calendars
/apple-pim:calendars events # Events for next 7 days
/apple-pim:calendars search "team meeting"
/apple-pim:reminders lists # List all reminder lists
/apple-pim:reminders items --filter overdue
/apple-pim:contacts search "John"
/apple-pim:mail messages --filter unread
Natural language works via the pim-assistant agent:
- "What's on my calendar tomorrow?"
- "Remind me to call the dentist"
- "What's John's email address?"
OpenClaw Tools
| Tool | Example |
|---|---|
apple_pim_calendar |
apple_pim_calendar({ action: "events", nextDays: 7 }) |
apple_pim_reminder |
apple_pim_reminder({ action: "items", filter: "today" }) |
apple_pim_contact |
apple_pim_contact({ action: "search", query: "John" }) |
apple_pim_mail |
apple_pim_mail({ action: "messages", filter: "unread" }) |
apple_pim_system |
apple_pim_system({ action: "status" }) |
Direct CLI
calendar-cli list
calendar-cli events --from today --to tomorrow
calendar-cli create --title "Lunch" --start "tomorrow 12pm" --duration 60
reminder-cli lists
reminder-cli items --list "Personal" --filter overdue
contacts-cli containers # List contact account containers
contacts-cli search "John"
contacts-cli search "John" --profile work # Scoped to work contacts only
mail-cli messages --mailbox INBOX --limit 10
mail-cli send --to "[email protected]" --subject "Hello" --body "Message"
mail-cli send --to "[email protected]" --subject "Report" --body "See attached" --attachment ~/report.pdf
mail-cli reply --id "<message-id>" --body "Thanks!"
mail-cli save-attachment --id "<message-id>" --dest-dir ~/Downloads
mail-cli auth-check --id "<message-id>"
# Native SMTP send (no Mail.app — see "Direct SMTP path" below)
mail-cli secrets set smtp.icloud.password
mail-cli smtp-send --to "[email protected]" --subject "Hello" \
--from "[email protected]" --html-file ./body.html
calendar-cli create --title "Meeting" --start "tomorrow 2pm" --attendees '[{"email":"[email protected]"}]'
Direct SQLite read path (--engine sqlite)
Read commands (accounts, mailboxes, messages, get, search) default to
--engine auto: they read Apple Mail's local Envelope Index SQLite database
(~/Library/Mail/V*/MailData/Envelope Index) directly, falling back to JXA if
the database isn't readable. Message bodies come straight from the on-disk
.emlx files. This is ~10–200× faster than the JXA path (subject search across
an 80k-message mailbox: ~80ms vs ~15s) and works even when Mail.app is not
running. Mutations (update, move, delete, send, reply) always go
through Mail.app — nothing here ever writes to Mail's database. update,
move, delete, batch-update and batch-delete do take --engine as well:
under auto they look the message up in the same read-only index first, so
Mail.app can be handed its row-id directly instead of scanning mailbox by
mailbox, and they fall back to that scan whenever the lookup cannot answer.
send and reply are unaffected.
- The database is only ever opened read-only (
SQLITE_OPEN_READONLY+PRAGMA query_only); the fast path never writes to Mail's data. - Requires Full Disk Access for the invoking process (Terminal or the MCP
host). Without it,
--engine autosilently uses JXA — checkmail-cli auth-status(envelopeIndex.readable) to see which path you get. --field contentsearch is not indexed locally and always uses JXA.- Force a specific path with
--engine sqliteor--engine jxa; responses from the fast path include"engine": "sqlite". The write-path lookup emits noenginekey:batch-updateandbatch-deletereport the locator built in_lookup.backend(sqliteonce an index opens,jxa-onlyotherwise) and the hit/fallback counts in_lookup.stats;update,moveanddeletecarry a per-message_lookupinsideresultonly underMAIL_CLI_DEBUG=1, with the same four counts in its_lookup.stats— one message per run, so they are that lookup's own.
Direct SMTP path (mail-cli smtp-send)
mail-cli send composes through Mail.app via JXA — which means the outgoing
message shows up in Mail.app's Sent folder, uses your configured accounts, and
inherits the system's send pipeline. Good default, but it has two real
limitations: it requires Mail.app to be running, and Mail 16 on iCloud-type
accounts silently drops AppleScript's html content property
(FB11734014) so HTML
sends arrive as empty plain text.
mail-cli smtp-send is the native Swift alternative: hand-rolled SMTP state
machine with a multipart/alternative MIME builder. No Mail.app dependency,
no third-party Swift deps. Two TLS transports:
- Implicit TLS (default) —
NWConnection+NWProtocolTLSon port 465 (iCloud, Gmail, Fastmail, most modern hosts). - STARTTLS —
--tls-mode starttls(defaults to port 587) for corporate Exchange, self-hosted Postfix, and university/ISP relays that only expose- Backed by a POSIX socket upgraded to TLS via Secure Transport, since
NWConnectioncan't upgrade plaintext → TLS in place.
- Backed by a POSIX socket upgraded to TLS via Secure Transport, since
When the HTML body is supplied without --body, a plain-text fallback is
auto-derived from the HTML so the message is always multipart/alternative
(better for screen readers, notification previews, and spam scoring).
Setup (one-time):
# Store an app-specific password (interactive, no echo).
# Apple ID → Sign-In and Security → App-Specific Passwords → Generate.
mail-cli secrets set smtp.icloud.password
# Or read from ~/.openclaw/secrets.json if the OpenClaw store exists.
# Password resolution: $SMTP_ICLOUD_PASSWORD → ~/.openclaw/secrets.json → ~/.config/apple-pim/secrets.json
# Set connection defaults so you don't pass --from on every call (optional):
mail-cli config set-smtp --username "[email protected]" # if/when the config command is added
# Until then, pass --from explicitly or put `smtp.username` in ~/.config/apple-pim/config.json.
Send:
# Dry run — prints rendered RFC 5322 bytes and exits 0:
mail-cli smtp-send --dry-run --to [email protected] --from [email protected] \
--subject "Dry run" --body "hello"
# Real send with HTML body and plain-text fallback:
mail-cli smtp-send --to [email protected] --from [email protected] \
--subject "Digest" --html-file ./body.html --body "Plain fallback"
# With attachment:
mail-cli smtp-send --to [email protected] --from [email protected] \
--subject "Report" --html-file ./body.html --attachment ~/report.pdf
# STARTTLS relay on port 587 (corporate Exchange / Postfix):
mail-cli smtp-send --tls-mode starttls --host smtp.work.example --port 587 \
--to [email protected] --from [email protected] --subject "Hi" --body "hello"
# Also APPEND the message to the IMAP Sent folder (default-on for iCloud):
mail-cli smtp-send --imap-append-sent --to [email protected] --from [email protected] \
--subject "Archived in Sent" --body "hi"
# Verbose mode logs the SMTP conversation to stderr (password redacted):
mail-cli smtp-send --verbose --to [email protected] --from [email protected] \
--subject "Debug" --body "hi"
STARTTLS, Sent-folder, and HTML fallback options:
| Flag | Effect |
|---|---|
--tls-mode implicit|starttls |
TLS transport. implicit (default) = port 465; starttls = port 587. Also settable via smtp.tls_mode in config. |
--tls-insecure-skip-verify |
Skip TLS cert verification (STARTTLS only; for self-signed test servers). |
--imap-append-sent / --no-imap-append-sent |
APPEND the sent message to the IMAP Sent folder so it appears in Mail.app/iCloud. Defaults on for iCloud SMTP (*.mail.me.com), off otherwise. Configure non-iCloud servers via the imap config block. |
IMAP Sent-folder config (~/.config/apple-pim/config.json) — only needed for non-iCloud, or to override defaults:
{
"imap": {
"host": "imap.mail.me.com",
"port": 993,
"sent_folder": "Sent Messages",
"username": "[email protected]",
"secret_key": "imap.icloud.password",
"append_sent": true
}
}
Folder names differ by provider: iCloud "Sent Messages", Gmail "[Gmail]/Sent Mail", generic "Sent". If imap.secret_key is omitted, the SMTP password is reused (iCloud uses the same app-specific password for both). APPEND failures are non-fatal — the message was already delivered by SMTP, so the failure surfaces as a warning plus an "imap_append": {"success": false, ...} field in the JSON result.
Secrets management:
mail-cli secrets set smtp.icloud.password # prompt silently
mail-cli secrets get smtp.icloud.password # print (for scripts)
mail-cli secrets list # keys only, never values
mail-cli secrets unset smtp.icloud.password
# Force the OpenClaw-shared store instead of the standalone one:
mail-cli secrets set smtp.icloud.password --store openclaw
Known Limitations
| Limitation | Detail |
|---|---|
| Sent-folder APPEND is opt-in for non-iCloud | --imap-append-sent APPENDs to the IMAP Sent folder (default-on for iCloud). For other providers you must configure the imap block. Without it, the message won't appear in Mail.app's Sent view and a stderr note is emitted. |
| AUTH LOGIN only | AUTH PLAIN / CRAM-MD5 / OAUTHBEARER not implemented. Sufficient for iCloud app-specific passwords. |
| App-specific password required for iCloud | The regular Apple ID password will return 535 5.7.8 Authentication failed. Generate one at appleid.apple.com → Sign-In and Security → App-Specific Passwords. |
--from must match the authenticated account |
iCloud (and most relays) will silently rewrite or reject messages whose From: doesn't match the authenticating user. |
Calendar store read path (--engine sqlite)
Every event includes availability, EventKit's EKEventAvailability: busy,
free, tentative, unavailable, or notSupported. EventKit returns
notSupported for a subscribed (ICS) calendar that does not support
availability, even when the feed publishes a busy status. For those events,
events, get and search default to --engine auto: they read the value
from the local Calendar store
(~/Library/Group Containers/group.com.apple.calendar/Calendar.sqlitedb) — the
feed's X-MICROSOFT-CDO-BUSYSTATUS or X-MICROSOFT-MSNCALENDAR-BUSYSTATUS
(FREE, TENTATIVE, BUSY, OOF map to free, tentative, busy,
unavailable), else the store's own availability value, else notSupported.
EventKit still finds and expands every event.
- The store is only ever opened read-only (
SQLITE_OPEN_READONLY+PRAGMA query_only). - Requires Full Disk Access for the invoking process (Terminal or the MCP
host) — check
calendar-cli auth-status(calendarStore.readable). On a host without it,events,getandsearchuse Apple PIM Helper when it is installed and has both Calendar access and Full Disk Access; every other command keeps its usual route. - The helper's answer is kept for the life of the MCP server or OpenClaw process, so a Full Disk Access grant made to the helper later takes effect after a restart; the host's own check runs once per MCP server process and on every OpenClaw tool call.
- Under
auto, an unreadable store or an unexpected layout keeps EventKit's value;--engine sqlitereports it as an error. - Force a specific path with
--engine sqliteor--engine eventkit; responses that read the store include"engine": "sqlite". The flag is CLI-only.
Reminders metadata (sections, subtasks, tags, flags)
EventKit has no API for sections, subtasks, tags, flags, urgent state, rich links
or attachments. reminder-cli reads them from the Reminders Core Data store
(~/Library/Group Containers/group.com.apple.reminders/Container_v1/Stores/Data-*.sqlite)
and can write a few of them through Apple's private ReminderKit framework.
Reads (on by default). items, get and search add these fields to each
reminder, and lists adds each list's sections:
| Field | Meaning |
|---|---|
flagged, urgent |
Reminders' flag and urgent state |
parentId, isSubtask, subtaskIds |
Subtask relationships (one level, as in Reminders) |
section |
{id, name} of the reminder's section, or null |
tags |
Tag names, without # |
richLinks |
URLs attached as rich links (distinct from url, EventKit's hidden field) |
attachments |
{type, filename, uti, size, width, height, path}; path is null when the file is not on this Mac |
- The store is only ever opened read-only (
SQLITE_OPEN_READONLY+PRAGMA query_only). Nothing in apple-pim writes it. - Requires Full Disk Access — check
reminder-cli auth-status(remindersStore.readable). On a host without it these commands use Apple PIM Helper when it is installed and can read the store, as calendar's store reads do. --metadata auto(default) adds a top-levelmetadataobject:{"available": true, "source": "reminders-store"}, or{"available": false, "reason": "..."}with the EventKit fields still returned.--metadata offskips the store;--metadata requiredfails without it. MCP/OpenClaw:metadata.
Private writes (off by default). Five commands write through ReminderKit, the framework Reminders.app itself uses, so changes sync through iCloud normally. They work only after you turn on one switch for this Mac:
reminder-cli config private-writes --on # or --off; no flag shows the state
That sets "privateWrites": true in the reminders section of
~/.config/apple-pim/config.json (or $APPLE_PIM_CONFIG_DIR), leaving every other
key as it was; you can also edit the file by hand or use /apple-pim:configure. A
profile with its own reminders section replaces the base one, so set it there too.
There is no per-call opt-in, and the tools cannot change the switch.
| CLI | Tool action | Does |
|---|---|---|
set-flag --id ID [--unflag] |
set_flag (flagged) |
Flag or unflag |
add-subtask --parent ID --title T |
add_subtask (parentId, title) |
Create a subtask (title only; use update for due/notes) |
move-subtask --id ID (--parent ID | --top-level) |
move_subtask (parentId / topLevel) |
Nest under a top-level reminder in the same list, or un-nest |
set-section --id ID --section NAME_OR_ID |
set_section (section) |
Put a reminder into a section of its own list |
set-tags --id ID [--add T]... [--remove T]... |
set_tags (addTags, removeTags) |
Add/remove tags |
ReminderKit is a private, unsupported framework that can change in any macOS update, so each write is guarded:
- With
reminders.privateWritesoff (the default), every command stops before touching Reminders and says how to turn it on. - PIMConfig list filtering applies to the reminder and, for subtasks, the parent.
- Preconditions are checked first (one level of subtasks, same list, section exists and is unambiguous). A write that would change nothing is skipped.
- Exactly one ReminderKit save. A save error is reported and never retried.
- The database is read back until it shows the change and the fields the operation must not touch are unchanged (for sections, every other reminder's section too). Otherwise the command fails with what it observed, without retrying. Because of this, private writes need Full Disk Access and refuse to run without it.
Not supported: removing a reminder from a section, smart lists, templates, groceries, list groups, image attachments, and moving reminders across lists. The ReminderKit calls follow remctl (MIT), which tests them against a live store on macOS 26 and 27.
Tools Reference
5 domain-level tools, each with an action parameter:
| Tool | Actions | Domain |
|---|---|---|
calendar / apple_pim_calendar |
list, events, get, search, create, update, delete, batch_create |
Calendar events via EventKit |
reminder / apple_pim_reminder |
lists, items, get, search, create, complete, update, delete, batch_create, batch_complete, batch_delete, plus opt-in private writes set_flag, add_subtask, move_subtask, set_section, set_tags |
Reminders via EventKit; sections/subtasks/tags read from the Reminders database, written through ReminderKit |
contact / apple_pim_contact |
containers, groups, list, search, get, create, update, delete |
Contacts framework |
mail / apple_pim_mail |
accounts, mailboxes, messages, get, search, send, reply, save_attachment, update, move, delete, batch_update, batch_delete, auth_check |
Mail.app via JXA/AppleScript |
apple-pim / apple_pim_system |
status, authorize, config_show, config_init |
Authorization & configuration |
The system status action returns each domain's OS permission state in
status.<domain>.permissionStatus. Use this field when checking access: hosts
may redact the legacy authorization field as a credential. That legacy field
remains available for existing consumers. unavailable (for example, Mail.app
closed) and error do not confirm authorized access.
Recurrence Rules
{
"frequency": "weekly",
"interval": 1,
"daysOfTheWeek": ["monday", "wednesday", "friday"],
"endDate": "2025-12-31"
}
Supported frequencies: daily, weekly, monthly, yearly
Batch Operations
{
"events": [
{"title": "Standup", "start": "2025-01-27 09:00"},
{"title": "Team Sync", "start": "2025-01-27 14:00"}
]
}
Architecture
The shared lib/ layer contains all handler logic, schemas, and sanitization. Both the MCP server and OpenClaw plugin are thin adapters over this shared code.
Claude Code <--MCP--> mcp-server/server.js ---+
|
OpenClaw <--tools--> openclaw/src/index.ts ----+--> lib/ (shared handlers, schemas, sanitize)
|
Direct CLI <--shell--> --------------------------+--> Swift CLIs (EventKit / Contacts / JXA)
|
PIMConfig
(~/.config/apple-pim/)
Directory Structure
apple-pim/
├── lib/ # Shared handler logic (used by MCP + OpenClaw)
│ ├── cli-runner.js # CLI spawn + binary discovery
│ ├── schemas.js # Tool JSON Schemas
│ ├── sanitize.js # Datamarking for prompt injection defense
│ ├── mail-format.js # Email markdown formatting
│ ├── tool-args.js # CLI argument builders
│ └── handlers/
│ ├── calendar.js # handleCalendar()
│ ├── reminder.js # handleReminder()
│ ├── contact.js # handleContact()
│ ├── mail.js # handleMail()
│ └── apple-pim.js # handleApplePim()
├── swift/ # Native Swift CLI tools
│ ├── Sources/
│ │ ├── PIMConfig/ # Shared config library
│ │ ├── CalendarCLI/ # EventKit calendar operations
│ │ ├── ReminderCLI/ # EventKit reminder operations
│ │ ├── ContactsCLI/ # Contacts framework operations
│ │ └── MailCLI/ # Mail.app via JXA
│ └── Tests/
├── mcp-server/ # Claude Code MCP adapter
│ ├── server.js # MCP tool registration (imports lib/)
│ ├── build.mjs # esbuild config
│ └── dist/server.js # Bundled artifact
├── openclaw/ # OpenClaw plugin package (NPM: apple-pim-cli)
│ ├── src/index.ts # Tool registration with per-call isolation
│ ├── openclaw.plugin.json # Plugin manifest + config schema
│ ├── lib -> ../lib # Symlink to shared code
│ └── skills/apple-pim/ # OpenClaw skill knowledge
├── evals/ # Agent eval framework (137 tests)
│ ├── helpers/ # Mock CLI, scenario runner, grading
│ ├── fixtures/ # Canned CLI JSON responses
│ ├── scenarios/ # YAML eval case definitions
│ └── tests/ # Vitest test files (4 categories)
├── commands/ # Claude Code slash commands
├── agents/ # pim-assistant agent
├── skills/ # Claude Code skill knowledge
├── docs/ # Documentation
│ └── multi-agent-setup.md # Multi-agent isolation guide
└── setup.sh # Build + install script
Troubleshooting
Permission Denied
Check System Settings > Privacy & Security:
- Calendars: Ensure Terminal/Claude Code has access
- Reminders: Ensure Terminal/Claude Code has access
- Contacts: Ensure Terminal/Claude Code has access
- Full Disk Access (subscribed calendars' availability; Reminders sections, subtasks, tags and flags, and private Reminders writes): grant it to Terminal/Claude Code, or to Apple PIM Helper.app; a grant made to the helper is seen after the MCP server or gateway restarts
You may need to restart your app after granting permissions.
Mail.app Issues
- Mail.app must be running — the plugin does not launch it automatically
- Automation permission — System Settings > Privacy & Security > Automation: allow Terminal to control Mail.app
- 30-second timeout — JXA scripts have a 30-second timeout. Use
--limitto reduce result count. For search, use--sinceto narrow by date (recommended for large mailboxes) - Message IDs — Mail tools use RFC 2822
messageId(stable across moves). Pass--mailboxand--accounthints for faster lookups
CLI Not Found
# Build and install to PATH
./setup.sh --install
# Verify
which calendar-cli
calendar-cli list
MCP Server Not Connecting (Claude Code)
- Ensure you ran
./setup.shto install npm dependencies - Check
/mcpin Claude Code to see server status - Restart Claude Code after installing the plugin
OpenClaw Tools Not Registering
- Verify CLIs are on PATH:
which calendar-cli - Check
openclaw plugins listfor the plugin - If not on PATH, set
binDirin plugin config
Date Parsing Issues
The CLI accepts various date formats:
- ISO 8601:
2024-01-15T14:30:00 - ISO 8601 with timezone offset:
2024-01-15T14:30:00-07:00,2024-01-15T14:30:00+05:30 - Date/time:
2024-01-15 14:30 - Date only:
2024-01-15 - Natural language:
today,tomorrow,next week,in 2 hours
Timezone offsets are preserved end-to-end through the CLI layer, so 2024-01-15T19:00:00-07:00 creates the event at the correct local time.
Development
Building the OpenClaw package with tsup 9 requires Node.js 22.18+ on the 22.x line, 24.11+ on the 24.x line, or 26+. This development requirement is separate from the plugin runtime minimum of 22.13. Install development dependencies using a current Node.js 24 LTS release: the OpenClaw SDK also enforces its own, newer installation requirement. CI installs on Node.js 24, then builds and tests the plugin on the minimum compiler version, 22.18.0.
Testing CLIs Directly
cd swift/.build/release
./calendar-cli list
./calendar-cli events --from today --to tomorrow
./reminder-cli lists
./reminder-cli items --list "Personal"
./contacts-cli search "John"
./mail-cli accounts
Using Profiles
# CLI flag
calendar-cli list --profile work
# Environment variable
export APPLE_PIM_PROFILE=work
calendar-cli events --from today --to tomorrow
# View effective config
calendar-cli config show --profile travel
Agent Evals
The eval framework tests how well the tool layer serves AI agents. The four core categories run against mock CLI fixtures with zero TCC permissions and no real macOS data. A separate model-in-the-loop suite (calendar-reasoning) exercises date/time reasoning with a real claude -p call graded by an LLM judge — it requires ANTHROPIC_API_KEY and is non-deterministic.
# Run all eval tests (mock + model-in-the-loop)
npm run eval
# Watch mode during development
npm run eval:watch
Eval categories:
| Category | Tests | What it verifies |
|---|---|---|
| Tool Call Correctness | 58 | CLI argument construction for every input variant |
| Response Interpretation | 22 | Verification visibility, datamarking, injection detection |
| Multi-turn Sequences | 8 | Correct tool call ordering for multi-step workflows |
| Safety Properties | 49 | Destructive warnings, ID validation, schema coverage |
| Calendar Reasoning (model) | 8 | Day-of-week math, cross-midnight events, query strategy (requires ANTHROPIC_API_KEY) |
To add new eval cases, edit YAML files in evals/scenarios/ and add fixture JSON in evals/fixtures/. No test code changes needed.
Rebuilding After Changes
# Swift CLIs
cd swift && swift build -c release
# MCP server bundle (after editing lib/ or mcp-server/)
cd mcp-server && npm run build
# OpenClaw loads .ts directly — no rebuild needed
License
MIT
Explore related projects
Loading…