apple-mail-mcp 1.9.0 → 2.0.0

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 (38) hide show
  1. package/README.md +65 -5
  2. package/build/index.js +288 -193
  3. package/build/services/appleMailManager.d.ts +32 -7
  4. package/build/services/appleMailManager.d.ts.map +1 -1
  5. package/build/services/appleMailManager.js +256 -104
  6. package/build/services/imapClient.d.ts +50 -34
  7. package/build/services/imapClient.d.ts.map +1 -1
  8. package/build/services/imapClient.js +276 -45
  9. package/build/services/imapIdle.d.ts +58 -0
  10. package/build/services/imapIdle.d.ts.map +1 -0
  11. package/build/services/imapIdle.js +145 -0
  12. package/build/services/messageRouter.d.ts +16 -0
  13. package/build/services/messageRouter.d.ts.map +1 -0
  14. package/build/services/messageRouter.js +29 -0
  15. package/build/services/smtpMailer.d.ts +3 -2
  16. package/build/services/smtpMailer.d.ts.map +1 -1
  17. package/build/services/smtpMailer.js +11 -7
  18. package/build/services/templateStore.d.ts +18 -0
  19. package/build/services/templateStore.d.ts.map +1 -0
  20. package/build/services/templateStore.js +91 -0
  21. package/build/tools/doctor.d.ts +23 -0
  22. package/build/tools/doctor.d.ts.map +1 -0
  23. package/build/tools/doctor.js +74 -0
  24. package/build/tools/resourcesAndPrompts.d.ts +14 -0
  25. package/build/tools/resourcesAndPrompts.d.ts.map +1 -0
  26. package/build/tools/resourcesAndPrompts.js +109 -0
  27. package/build/tools/respond.d.ts +48 -0
  28. package/build/tools/respond.d.ts.map +1 -0
  29. package/build/tools/respond.js +95 -0
  30. package/build/tools/thread.d.ts +19 -0
  31. package/build/tools/thread.d.ts.map +1 -0
  32. package/build/tools/thread.js +32 -0
  33. package/build/types.d.ts +38 -0
  34. package/build/types.d.ts.map +1 -1
  35. package/build/utils/attachmentMaterialize.d.ts +9 -0
  36. package/build/utils/attachmentMaterialize.d.ts.map +1 -0
  37. package/build/utils/attachmentMaterialize.js +38 -0
  38. package/package.json +2 -1
package/README.md CHANGED
@@ -86,17 +86,21 @@ On first use, macOS will ask for permission to automate Mail.app. Click "OK" to
86
86
  | **List Messages** | List messages with pagination, sender filter, date display |
87
87
  | **Search Messages** | Search by sender, subject, content, date range, read/flagged status — across all accounts |
88
88
  | **Read Messages** | Get full email content (plain text or HTML) |
89
- | **Send Email** | Compose and send new emails (with optional file attachments) |
89
+ | **Send Email** | Compose and send new emails (attach by file path or inline base64 content) |
90
90
  | **Send Serial Email** | Mail merge — send personalized emails to a list of recipients with {{placeholder}} support |
91
- | **Create Draft** | Save emails to Drafts folder (with optional file attachments) |
91
+ | **Create Draft** | Save emails to Drafts folder (attach by file path or inline base64 content) |
92
92
  | **Reply** | Reply to messages (with reply-all support) |
93
93
  | **Forward** | Forward messages to new recipients |
94
+ | **Get Thread** | Group a conversation by normalized subject (across AppleScript or IMAP) |
94
95
  | **Mark Read/Unread** | Change read status (single or batch) |
95
96
  | **Flag/Unflag** | Flag or unflag messages (single or batch) |
96
97
  | **Delete Messages** | Move messages to trash (single or batch) |
97
98
  | **Move Messages** | Organize into mailboxes (single or batch) |
98
99
  | **List Attachments** | View attachment metadata (name, type, size) |
99
100
  | **Save Attachment** | Save attachments to disk |
101
+ | **Fetch Attachment** | Get an attachment's bytes as base64 (no disk write) |
102
+
103
+ Read/list/get tools also return **structured JSON** (`structuredContent`) alongside the text, so agents can consume results without parsing prose.
100
104
 
101
105
  ### Mailbox & Account Management
102
106
 
@@ -113,17 +117,25 @@ On first use, macOS will ask for permission to automate Mail.app. Click "OK" to
113
117
  |---------|-------------|
114
118
  | **List Rules** | View all mail rules and their enabled status |
115
119
  | **Enable/Disable Rules** | Toggle mail rules on or off |
120
+ | **Create/Delete Rules** | Create rules with conditions + actions, or delete by name |
116
121
  | **Search Contacts** | Look up contacts from Contacts.app by name |
117
- | **Email Templates** | Save, list, use, and delete reusable email templates |
122
+ | **Email Templates** | Save, list, use, and delete reusable email templates (persisted to disk across restarts) |
118
123
 
119
124
  ### Diagnostics
120
125
 
121
126
  | Feature | Description |
122
127
  |---------|-------------|
123
128
  | **Health Check** | Verify Mail.app connectivity |
129
+ | **Doctor** | Diagnose Mail permission, account state, and each IMAP/SMTP backend with actionable messages |
124
130
  | **Statistics** | Message and unread counts per account, recently received stats |
125
131
  | **Sync Status** | Check if Mail.app is actively syncing |
126
132
 
133
+ ### MCP resources & prompts
134
+
135
+ Resources expose read-only context the client can attach without a tool call:
136
+ `mail://accounts`, `mail://templates`, and `mail://mailboxes/{account}`. Prompts
137
+ package common workflows: `triage-inbox`, `compose-reply`, `weekly-summary`.
138
+
127
139
  ---
128
140
 
129
141
  ## Tool Reference
@@ -214,7 +226,7 @@ Send a new email immediately.
214
226
  | `cc` | string[] | No | CC recipients |
215
227
  | `bcc` | string[] | No | BCC recipients |
216
228
  | `account` | string | No | Send from specific account (with `transport: "smtp"`, overrides the From address) |
217
- | `attachments` | string[] | No | Absolute file paths to attach, max 20 files (e.g., `["/Users/me/report.pdf"]`) |
229
+ | `attachments` | (string \| {filename, contentBase64})[] | No | Up to 20 attachments: absolute file paths (e.g., `"/Users/me/report.pdf"`) and/or inline `{filename, contentBase64}` objects for content not on disk |
218
230
  | `transport` | `"applescript"` \| `"smtp"` | No | Send transport (default `"applescript"`). Use `"smtp"` to send clean MIME directly, avoiding the macOS 15+ Mail.app `<blockquote>` wrapping — see [SMTP transport](#smtp-transport) |
219
231
 
220
232
  **Example:**
@@ -309,6 +321,20 @@ AppleScript.
309
321
  | `APPLE_MAIL_MCP_IMAP_PASSWORD` | No | — | Password (if set, used instead of the Keychain) |
310
322
  | `APPLE_MAIL_MCP_IMAP_KEYCHAIN_SERVICE` | No | — | Keychain item service/server name |
311
323
  | `APPLE_MAIL_MCP_IMAP_KEYCHAIN_ACCOUNT` | No | = user | Keychain item account |
324
+ | `APPLE_MAIL_MCP_IMAP_ACCOUNTS` | No | — | JSON array of **additional** IMAP accounts for multi-account setups (see below) |
325
+ | `APPLE_MAIL_MCP_IMAP_IDLE` | No | `0` | Set `1` to enable IMAP IDLE push notifications (new-mail alerts) for every configured account |
326
+ | `APPLE_MAIL_MCP_IMAP_IDLE_MS` | No | `60000` | Idle timeout (ms) before a pooled IMAP connection is closed |
327
+
328
+ **Multiple IMAP accounts (C2):** set `APPLE_MAIL_MCP_IMAP_ACCOUNTS` to a JSON array, e.g.
329
+ `[{"account":"Work","user":"me@co.com","host":"imap.co.com","keychainService":"imap.co.com"}]`.
330
+ Each entry accepts `account`, `user`, `host`, `port`, `password`, `keychainService`,
331
+ `keychainAccount`. Calls route to the account matching their `account` argument (or the
332
+ decoded `imap:` id), and each account keeps its own pooled connection.
333
+
334
+ **Push notifications (B5):** with `APPLE_MAIL_MCP_IMAP_IDLE=1`, the server watches each
335
+ account's INBOX and emits an MCP logging message + `notifications/resources/updated` for
336
+ `mail://mailboxes/{account}` when new mail arrives (real-time IDLE where the server
337
+ supports it, polling fallback otherwise).
312
338
 
313
339
  As with SMTP, the password is read from the macOS **Keychain** by default (use
314
340
  an app-specific password for Gmail/Workspace/iCloud), so no secret goes in
@@ -373,10 +399,44 @@ Save an email to Drafts without sending.
373
399
  | `cc` | string[] | No | CC recipients |
374
400
  | `bcc` | string[] | No | BCC recipients |
375
401
  | `account` | string | No | Account for draft |
376
- | `attachments` | string[] | No | Absolute file paths to attach, max 20 files |
402
+ | `attachments` | (string \| {filename, contentBase64})[] | No | Up to 20 attachments: absolute file paths and/or inline `{filename, contentBase64}` objects |
377
403
 
378
404
  **Returns:** Confirmation that draft was created.
379
405
 
406
+ #### `get-thread`
407
+
408
+ Group a conversation by normalized subject (across the AppleScript or IMAP backend).
409
+
410
+ | Parameter | Type | Required | Description |
411
+ |-----------|------|----------|-------------|
412
+ | `id` | string | Yes | A message ID in the conversation (numeric or `imap:…`) |
413
+ | `account` | string | No | Account to search (omit to search all) |
414
+ | `mailbox` | string | No | Mailbox to search (omit to search all) |
415
+ | `limit` | number | No | Max messages in the thread (default 50) |
416
+
417
+ **Returns:** The conversation's messages, oldest-first.
418
+
419
+ #### `fetch-attachment`
420
+
421
+ Return an attachment's bytes as base64 (the read counterpart to inline-base64 send).
422
+
423
+ | Parameter | Type | Required | Description |
424
+ |-----------|------|----------|-------------|
425
+ | `id` | string | Yes | Numeric message ID |
426
+ | `attachmentName` | string | Yes | Attachment filename (from `list-attachments`) |
427
+
428
+ **Returns:** The attachment bytes, base64-encoded (also in `structuredContent.contentBase64`).
429
+
430
+ #### `create-rule` / `delete-rule`
431
+
432
+ Create a Mail rule with conditions and actions, or delete a rule by name.
433
+
434
+ `create-rule` parameters: `name` (string), `conditions` (array of `{field: from|to|cc|subject|content, operator: contains|notContains|equals|beginsWith|endsWith, value}`), `actions` (`{markRead?, markFlagged?, delete?, moveTo?, moveToAccount?}`), `matchAll` (default true), `enabled` (default true). `delete-rule` parameters: `name`.
435
+
436
+ #### `doctor`
437
+
438
+ Run a full setup diagnostic: Mail.app automation permission, account state (flags disabled accounts), and each configured IMAP/SMTP backend, each reported as ok / warn / fail with an actionable message. No parameters.
439
+
380
440
  ---
381
441
 
382
442
  #### `reply-to-message`