apple-mail-mcp 1.0.0 → 1.2.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.
package/README.md CHANGED
@@ -77,24 +77,50 @@ On first use, macOS will ask for permission to automate Mail.app. Click "OK" to
77
77
 
78
78
  ## Features
79
79
 
80
+ ### Messages
81
+
80
82
  | Feature | Description |
81
83
  |---------|-------------|
82
- | **List Messages** | List messages in any mailbox |
83
- | **Search Messages** | Find emails by sender, subject, content |
84
- | **Read Messages** | Get full email content |
85
- | **Send Email** | Compose and send new emails |
86
- | **Create Draft** | Save emails to Drafts folder |
84
+ | **List Messages** | List messages with pagination, sender filter, date display |
85
+ | **Search Messages** | Search by sender, subject, content, date range, read/flagged status — across all accounts |
86
+ | **Read Messages** | Get full email content (plain text or HTML) |
87
+ | **Send Email** | Compose and send new emails (with optional file attachments) |
88
+ | **Send Serial Email** | Mail merge — send personalized emails to a list of recipients with {{placeholder}} support |
89
+ | **Create Draft** | Save emails to Drafts folder (with optional file attachments) |
87
90
  | **Reply** | Reply to messages (with reply-all support) |
88
91
  | **Forward** | Forward messages to new recipients |
89
- | **Mark Read/Unread** | Change read status |
90
- | **Flag/Unflag** | Flag or unflag messages |
91
- | **Delete Messages** | Move messages to trash |
92
- | **Move Messages** | Organize into mailboxes |
93
- | **List Mailboxes** | Show all folders with counts |
92
+ | **Mark Read/Unread** | Change read status (single or batch) |
93
+ | **Flag/Unflag** | Flag or unflag messages (single or batch) |
94
+ | **Delete Messages** | Move messages to trash (single or batch) |
95
+ | **Move Messages** | Organize into mailboxes (single or batch) |
96
+ | **List Attachments** | View attachment metadata (name, type, size) |
97
+ | **Save Attachment** | Save attachments to disk |
98
+
99
+ ### Mailbox & Account Management
100
+
101
+ | Feature | Description |
102
+ |---------|-------------|
103
+ | **List Mailboxes** | Show all folders with message/unread counts |
104
+ | **Create/Delete/Rename Mailbox** | Full mailbox lifecycle management |
94
105
  | **List Accounts** | Show configured accounts |
95
106
  | **Unread Count** | Get unread counts per mailbox |
107
+
108
+ ### Rules, Contacts & Templates
109
+
110
+ | Feature | Description |
111
+ |---------|-------------|
112
+ | **List Rules** | View all mail rules and their enabled status |
113
+ | **Enable/Disable Rules** | Toggle mail rules on or off |
114
+ | **Search Contacts** | Look up contacts from Contacts.app by name |
115
+ | **Email Templates** | Save, list, use, and delete reusable email templates |
116
+
117
+ ### Diagnostics
118
+
119
+ | Feature | Description |
120
+ |---------|-------------|
96
121
  | **Health Check** | Verify Mail.app connectivity |
97
- | **Statistics** | Message and unread counts |
122
+ | **Statistics** | Message and unread counts per account, recently received stats |
123
+ | **Sync Status** | Check if Mail.app is actively syncing |
98
124
 
99
125
  ---
100
126
 
@@ -106,13 +132,19 @@ This section documents all available tools. AI agents should use these tool name
106
132
 
107
133
  #### `search-messages`
108
134
 
109
- Search for messages matching criteria.
135
+ Search for messages matching criteria. Searches all accounts by default.
110
136
 
111
137
  | Parameter | Type | Required | Description |
112
138
  |-----------|------|----------|-------------|
113
139
  | `query` | string | No | Text to search in subject/sender |
140
+ | `from` | string | No | Filter by sender email address |
141
+ | `subject` | string | No | Filter by subject line |
114
142
  | `mailbox` | string | No | Mailbox to search in (default: INBOX) |
115
- | `account` | string | No | Account to search in |
143
+ | `account` | string | No | Account to search in (omit to search all accounts) |
144
+ | `isRead` | boolean | No | Filter by read status |
145
+ | `isFlagged` | boolean | No | Filter by flagged status |
146
+ | `dateFrom` | string | No | Start date filter (e.g., "January 1, 2026") |
147
+ | `dateTo` | string | No | End date filter (e.g., "March 1, 2026") |
116
148
  | `limit` | number | No | Max results (default: 50) |
117
149
 
118
150
  ---
@@ -124,8 +156,9 @@ Get the full content of a message.
124
156
  | Parameter | Type | Required | Description |
125
157
  |-----------|------|----------|-------------|
126
158
  | `id` | string | Yes | Message ID |
159
+ | `preferHtml` | boolean | No | Return HTML source instead of plain text |
127
160
 
128
- **Returns:** Subject line and plain text body of the message.
161
+ **Returns:** Subject line and message body (plain text by default, HTML if `preferHtml` is true and HTML content is available).
129
162
 
130
163
  ---
131
164
 
@@ -138,8 +171,11 @@ List messages in a mailbox.
138
171
  | `mailbox` | string | No | Mailbox name (default: INBOX) |
139
172
  | `account` | string | No | Account name |
140
173
  | `limit` | number | No | Max messages (default: 50) |
174
+ | `offset` | number | No | Number of messages to skip (for pagination) |
175
+ | `from` | string | No | Filter by sender email address or name |
176
+ | `unreadOnly` | boolean | No | Only show unread messages |
141
177
 
142
- **Returns:** List of messages with ID, subject, sender, date, read status, and flagged status.
178
+ **Returns:** List of messages with ID, date, subject, and sender.
143
179
 
144
180
  ---
145
181
 
@@ -155,6 +191,7 @@ Send a new email immediately.
155
191
  | `cc` | string[] | No | CC recipients |
156
192
  | `bcc` | string[] | No | BCC recipients |
157
193
  | `account` | string | No | Send from specific account |
194
+ | `attachments` | string[] | No | Absolute file paths to attach (e.g., `["/Users/me/report.pdf"]`) |
158
195
 
159
196
  **Example:**
160
197
  ```json
@@ -162,12 +199,48 @@ Send a new email immediately.
162
199
  "to": ["colleague@company.com"],
163
200
  "subject": "Meeting Tomorrow",
164
201
  "body": "Hi, just confirming our meeting at 2pm tomorrow.",
165
- "account": "Work"
202
+ "account": "Work",
203
+ "attachments": ["/Users/me/Documents/agenda.pdf"]
166
204
  }
167
205
  ```
168
206
 
169
207
  ---
170
208
 
209
+ #### `send-serial-email`
210
+
211
+ Send individual personalized emails to a list of recipients (mail merge). Each recipient receives their own email — recipients don't see each other. Supports `{{placeholder}}` tokens in both subject and body.
212
+
213
+ | Parameter | Type | Required | Description |
214
+ |-----------|------|----------|-------------|
215
+ | `recipients` | object[] | Yes | List of recipients (see below) |
216
+ | `subject` | string | Yes | Email subject — use `{{Key}}` for placeholders |
217
+ | `body` | string | Yes | Email body — use `{{Key}}` for placeholders |
218
+ | `account` | string | No | Send from specific account |
219
+ | `delayMs` | number | No | Delay between sends in ms (default: 500) |
220
+
221
+ Each recipient object:
222
+
223
+ | Field | Type | Required | Description |
224
+ |-------|------|----------|-------------|
225
+ | `email` | string | Yes | Recipient email address |
226
+ | `variables` | object | Yes | Key-value pairs for placeholder replacement |
227
+
228
+ **Example:**
229
+ ```json
230
+ {
231
+ "recipients": [
232
+ { "email": "alice@example.com", "variables": { "Name": "Alice", "Company": "Acme" } },
233
+ { "email": "bob@example.com", "variables": { "Name": "Bob", "Company": "Globex" } }
234
+ ],
235
+ "subject": "Hello {{Name}}!",
236
+ "body": "Dear {{Name}},\n\nGreat to connect about {{Company}}.\n\nBest regards"
237
+ }
238
+ ```
239
+
240
+ **Returns:** Per-recipient success/failure results with a summary count.
241
+
242
+ ---
243
+
171
244
  #### `create-draft`
172
245
 
173
246
  Save an email to Drafts without sending.
@@ -180,6 +253,7 @@ Save an email to Drafts without sending.
180
253
  | `cc` | string[] | No | CC recipients |
181
254
  | `bcc` | string[] | No | BCC recipients |
182
255
  | `account` | string | No | Account for draft |
256
+ | `attachments` | string[] | No | Absolute file paths to attach |
183
257
 
184
258
  **Returns:** Confirmation that draft was created.
185
259
 
@@ -271,6 +345,62 @@ Move a message to a different mailbox.
271
345
 
272
346
  ---
273
347
 
348
+ #### `list-attachments`
349
+
350
+ List attachments on a message.
351
+
352
+ | Parameter | Type | Required | Description |
353
+ |-----------|------|----------|-------------|
354
+ | `id` | string | Yes | Message ID |
355
+
356
+ **Returns:** List of attachments with name, MIME type, and size.
357
+
358
+ ---
359
+
360
+ #### `save-attachment`
361
+
362
+ Save a message attachment to disk.
363
+
364
+ | Parameter | Type | Required | Description |
365
+ |-----------|------|----------|-------------|
366
+ | `id` | string | Yes | Message ID |
367
+ | `attachmentName` | string | Yes | Filename of the attachment |
368
+ | `savePath` | string | Yes | Directory to save to |
369
+
370
+ ---
371
+
372
+ ### Batch Operations
373
+
374
+ All batch operations accept an array of message IDs and return per-item success/failure results.
375
+
376
+ #### `batch-delete-messages`
377
+
378
+ | Parameter | Type | Required | Description |
379
+ |-----------|------|----------|-------------|
380
+ | `ids` | string[] | Yes | Message IDs to delete |
381
+
382
+ #### `batch-move-messages`
383
+
384
+ | Parameter | Type | Required | Description |
385
+ |-----------|------|----------|-------------|
386
+ | `ids` | string[] | Yes | Message IDs to move |
387
+ | `mailbox` | string | Yes | Destination mailbox |
388
+ | `account` | string | No | Account containing mailbox |
389
+
390
+ #### `batch-mark-as-read` / `batch-mark-as-unread`
391
+
392
+ | Parameter | Type | Required | Description |
393
+ |-----------|------|----------|-------------|
394
+ | `ids` | string[] | Yes | Message IDs |
395
+
396
+ #### `batch-flag-messages` / `batch-unflag-messages`
397
+
398
+ | Parameter | Type | Required | Description |
399
+ |-----------|------|----------|-------------|
400
+ | `ids` | string[] | Yes | Message IDs |
401
+
402
+ ---
403
+
274
404
  ### Mailbox Operations
275
405
 
276
406
  #### `list-mailboxes`
@@ -281,7 +411,7 @@ List all mailboxes for an account.
281
411
  |-----------|------|----------|-------------|
282
412
  | `account` | string | No | Account to list from |
283
413
 
284
- **Returns:** List of mailbox names with unread counts.
414
+ **Returns:** List of mailbox names with message and unread counts.
285
415
 
286
416
  ---
287
417
 
@@ -296,6 +426,40 @@ Get unread message count.
296
426
 
297
427
  ---
298
428
 
429
+ #### `create-mailbox`
430
+
431
+ Create a new mailbox.
432
+
433
+ | Parameter | Type | Required | Description |
434
+ |-----------|------|----------|-------------|
435
+ | `name` | string | Yes | Mailbox name |
436
+ | `account` | string | No | Account to create in |
437
+
438
+ ---
439
+
440
+ #### `delete-mailbox`
441
+
442
+ Delete a mailbox.
443
+
444
+ | Parameter | Type | Required | Description |
445
+ |-----------|------|----------|-------------|
446
+ | `name` | string | Yes | Mailbox name |
447
+ | `account` | string | No | Account containing mailbox |
448
+
449
+ ---
450
+
451
+ #### `rename-mailbox`
452
+
453
+ Rename a mailbox (creates new, moves messages, deletes old).
454
+
455
+ | Parameter | Type | Required | Description |
456
+ |-----------|------|----------|-------------|
457
+ | `oldName` | string | Yes | Current mailbox name |
458
+ | `newName` | string | Yes | New mailbox name |
459
+ | `account` | string | No | Account containing mailbox |
460
+
461
+ ---
462
+
299
463
  ### Account Operations
300
464
 
301
465
  #### `list-accounts`
@@ -304,7 +468,105 @@ List all configured Mail accounts.
304
468
 
305
469
  **Parameters:** None
306
470
 
307
- **Returns:** List of account names (e.g., "iCloud", "Gmail", "Exchange").
471
+ **Returns:** List of account names and email addresses.
472
+
473
+ ---
474
+
475
+ ### Rules
476
+
477
+ #### `list-rules`
478
+
479
+ List all mail rules.
480
+
481
+ **Parameters:** None
482
+
483
+ **Returns:** List of rule names and enabled status.
484
+
485
+ ---
486
+
487
+ #### `enable-rule` / `disable-rule`
488
+
489
+ Enable or disable a mail rule.
490
+
491
+ | Parameter | Type | Required | Description |
492
+ |-----------|------|----------|-------------|
493
+ | `name` | string | Yes | Rule name |
494
+
495
+ ---
496
+
497
+ ### Contacts
498
+
499
+ #### `search-contacts`
500
+
501
+ Search contacts in Contacts.app.
502
+
503
+ | Parameter | Type | Required | Description |
504
+ |-----------|------|----------|-------------|
505
+ | `query` | string | Yes | Name to search for |
506
+ | `limit` | number | No | Max results (default: 10) |
507
+
508
+ **Returns:** List of contacts with name, email addresses, and phone numbers.
509
+
510
+ ---
511
+
512
+ ### Templates
513
+
514
+ Email templates are stored in memory for the duration of the server session.
515
+
516
+ #### `save-template`
517
+
518
+ Save or update an email template.
519
+
520
+ | Parameter | Type | Required | Description |
521
+ |-----------|------|----------|-------------|
522
+ | `name` | string | Yes | Template name |
523
+ | `subject` | string | Yes | Default subject line |
524
+ | `body` | string | Yes | Template body |
525
+ | `to` | string[] | No | Default recipients |
526
+ | `cc` | string[] | No | Default CC recipients |
527
+ | `id` | string | No | Template ID (for updating) |
528
+
529
+ ---
530
+
531
+ #### `list-templates`
532
+
533
+ List all saved templates.
534
+
535
+ **Parameters:** None
536
+
537
+ ---
538
+
539
+ #### `get-template`
540
+
541
+ Get a template by ID.
542
+
543
+ | Parameter | Type | Required | Description |
544
+ |-----------|------|----------|-------------|
545
+ | `id` | string | Yes | Template ID |
546
+
547
+ ---
548
+
549
+ #### `delete-template`
550
+
551
+ Delete a template.
552
+
553
+ | Parameter | Type | Required | Description |
554
+ |-----------|------|----------|-------------|
555
+ | `id` | string | Yes | Template ID |
556
+
557
+ ---
558
+
559
+ #### `use-template`
560
+
561
+ Create a draft from a template, with optional overrides.
562
+
563
+ | Parameter | Type | Required | Description |
564
+ |-----------|------|----------|-------------|
565
+ | `id` | string | Yes | Template ID |
566
+ | `to` | string[] | No | Override recipients |
567
+ | `cc` | string[] | No | Override CC |
568
+ | `subject` | string | No | Override subject |
569
+ | `body` | string | No | Override body |
308
570
 
309
571
  ---
310
572
 
@@ -322,11 +584,21 @@ Verify Mail.app connectivity and permissions.
322
584
 
323
585
  #### `get-mail-stats`
324
586
 
325
- Get mail statistics (total messages, unread counts per account).
587
+ Get mail statistics.
588
+
589
+ **Parameters:** None
590
+
591
+ **Returns:** Total and per-account message/unread counts, plus recently received stats (24h, 7d, 30d).
592
+
593
+ ---
594
+
595
+ #### `get-sync-status`
596
+
597
+ Check Mail.app sync activity.
326
598
 
327
599
  **Parameters:** None
328
600
 
329
- **Returns:** Total counts and per-account breakdown.
601
+ **Returns:** Whether sync is detected, pending uploads, recent activity, and seconds since last change.
330
602
 
331
603
  ---
332
604
 
@@ -350,7 +622,7 @@ AI: [calls get-message with id="..."]
350
622
 
351
623
  ### Working with Accounts
352
624
 
353
- By default, operations use the first configured account. To work with specific accounts:
625
+ By default, operations use Mail.app's configured default send account. Search operations check all accounts when no account is specified. To work with specific accounts:
354
626
 
355
627
  ```
356
628
  User: "What email accounts do I have?"
@@ -373,6 +645,19 @@ User: "Send it"
373
645
  AI: [User opens Mail.app and sends manually, or AI calls send-email]
374
646
  ```
375
647
 
648
+ ### Sending Personalized Emails (Mail Merge)
649
+
650
+ ```
651
+ User: "Send a personalized email to Alice (alice@acme.com), Bob (bob@globex.com),
652
+ and Carol (carol@initech.com). Subject: 'Project Update for {{Company}}',
653
+ Body: 'Hi {{Name}}, here is the latest update for {{Company}}.'"
654
+ AI: [calls send-serial-email with recipients, subject template, and body template]
655
+ "Successfully sent 3 email(s):
656
+ - alice@acme.com: sent
657
+ - bob@globex.com: sent
658
+ - carol@initech.com: sent"
659
+ ```
660
+
376
661
  ### Organizing Messages
377
662
 
378
663
  ```
@@ -429,10 +714,10 @@ If installed from source, use this configuration:
429
714
  | Limitation | Reason |
430
715
  |------------|--------|
431
716
  | macOS only | Apple Mail and AppleScript are macOS-specific |
432
- | Plain text only | Email body is plain text; HTML formatting not supported |
433
- | No attachments | Cannot add or read attachments via AppleScript |
434
- | Message ID scope | Message IDs are searched across all mailboxes (may be slow with large mailboxes) |
717
+ | No sending HTML email | Emails are sent as plain text; reading HTML content is supported |
718
+ | Attachments require absolute paths | File attachments must use full absolute paths (e.g., `/Users/me/file.pdf`) |
435
719
  | No smart mailboxes | Cannot access Smart Mailboxes via AppleScript |
720
+ | In-memory templates | Email templates are not persisted across server restarts |
436
721
 
437
722
  ### Backslash Escaping (Important for AI Agents)
438
723