@jbctechsolutions/mcp-office365 3.0.0 → 4.0.1
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 +42 -65
- package/dist/approval/hash.d.ts +8 -8
- package/dist/approval/token-manager.d.ts +12 -6
- package/dist/approval/token-manager.d.ts.map +1 -1
- package/dist/approval/token-manager.js +11 -3
- package/dist/approval/token-manager.js.map +1 -1
- package/dist/approval/types.d.ts +7 -3
- package/dist/approval/types.d.ts.map +1 -1
- package/dist/cli.d.ts +4 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +18 -3
- package/dist/cli.js.map +1 -1
- package/dist/database/repository.d.ts +48 -48
- package/dist/database/repository.d.ts.map +1 -1
- package/dist/database/repository.js.map +1 -1
- package/dist/delta/mirror.d.ts +67 -0
- package/dist/delta/mirror.d.ts.map +1 -0
- package/dist/delta/mirror.js +183 -0
- package/dist/delta/mirror.js.map +1 -0
- package/dist/graph/auth/account-id.d.ts +19 -0
- package/dist/graph/auth/account-id.d.ts.map +1 -0
- package/dist/graph/auth/account-id.js +55 -0
- package/dist/graph/auth/account-id.js.map +1 -0
- package/dist/graph/auth/config.d.ts +1 -1
- package/dist/graph/auth/config.d.ts.map +1 -1
- package/dist/graph/auth/config.js +8 -0
- package/dist/graph/auth/config.js.map +1 -1
- package/dist/graph/auth/index.d.ts +1 -0
- package/dist/graph/auth/index.d.ts.map +1 -1
- package/dist/graph/auth/index.js +1 -0
- package/dist/graph/auth/index.js.map +1 -1
- package/dist/graph/client/graph-client.d.ts +105 -0
- package/dist/graph/client/graph-client.d.ts.map +1 -1
- package/dist/graph/client/graph-client.js +414 -18
- package/dist/graph/client/graph-client.js.map +1 -1
- package/dist/graph/client/immutable-id-middleware.d.ts +50 -0
- package/dist/graph/client/immutable-id-middleware.d.ts.map +1 -0
- package/dist/graph/client/immutable-id-middleware.js +137 -0
- package/dist/graph/client/immutable-id-middleware.js.map +1 -0
- package/dist/graph/content-readers.d.ts +0 -12
- package/dist/graph/content-readers.d.ts.map +1 -1
- package/dist/graph/content-readers.js +0 -21
- package/dist/graph/content-readers.js.map +1 -1
- package/dist/graph/index.d.ts +5 -6
- package/dist/graph/index.d.ts.map +1 -1
- package/dist/graph/index.js +5 -6
- package/dist/graph/index.js.map +1 -1
- package/dist/graph/mailbox-adapter.d.ts +15 -15
- package/dist/graph/mappers/contact-mapper.d.ts +4 -1
- package/dist/graph/mappers/contact-mapper.d.ts.map +1 -1
- package/dist/graph/mappers/contact-mapper.js +7 -3
- package/dist/graph/mappers/contact-mapper.js.map +1 -1
- package/dist/graph/mappers/email-mapper.d.ts.map +1 -1
- package/dist/graph/mappers/email-mapper.js +7 -4
- package/dist/graph/mappers/email-mapper.js.map +1 -1
- package/dist/graph/mappers/event-mapper.d.ts.map +1 -1
- package/dist/graph/mappers/event-mapper.js +6 -3
- package/dist/graph/mappers/event-mapper.js.map +1 -1
- package/dist/graph/mappers/folder-mapper.d.ts +0 -4
- package/dist/graph/mappers/folder-mapper.d.ts.map +1 -1
- package/dist/graph/mappers/folder-mapper.js +9 -19
- package/dist/graph/mappers/folder-mapper.js.map +1 -1
- package/dist/graph/mappers/index.d.ts +2 -2
- package/dist/graph/mappers/index.d.ts.map +1 -1
- package/dist/graph/mappers/index.js +2 -2
- package/dist/graph/mappers/index.js.map +1 -1
- package/dist/graph/mappers/task-mapper.d.ts +4 -2
- package/dist/graph/mappers/task-mapper.d.ts.map +1 -1
- package/dist/graph/mappers/task-mapper.js +7 -5
- package/dist/graph/mappers/task-mapper.js.map +1 -1
- package/dist/graph/mappers/utils.d.ts +0 -10
- package/dist/graph/mappers/utils.d.ts.map +1 -1
- package/dist/graph/mappers/utils.js +0 -19
- package/dist/graph/mappers/utils.js.map +1 -1
- package/dist/graph/repository.d.ts +400 -270
- package/dist/graph/repository.d.ts.map +1 -1
- package/dist/graph/repository.js +739 -1046
- package/dist/graph/repository.js.map +1 -1
- package/dist/ids/next-action.d.ts +29 -0
- package/dist/ids/next-action.d.ts.map +1 -0
- package/dist/ids/next-action.js +58 -0
- package/dist/ids/next-action.js.map +1 -0
- package/dist/ids/resolver.d.ts +2 -1
- package/dist/ids/resolver.d.ts.map +1 -1
- package/dist/ids/resolver.js +19 -4
- package/dist/ids/resolver.js.map +1 -1
- package/dist/ids/schema.d.ts +91 -0
- package/dist/ids/schema.d.ts.map +1 -0
- package/dist/ids/schema.js +131 -0
- package/dist/ids/schema.js.map +1 -0
- package/dist/ids/token.d.ts +7 -1
- package/dist/ids/token.d.ts.map +1 -1
- package/dist/ids/token.js +46 -7
- package/dist/ids/token.js.map +1 -1
- package/dist/index.d.ts +4 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +63 -100
- package/dist/index.js.map +1 -1
- package/dist/parsers/index.d.ts +0 -1
- package/dist/parsers/index.d.ts.map +1 -1
- package/dist/parsers/index.js +0 -1
- package/dist/parsers/index.js.map +1 -1
- package/dist/registry/all-tools.d.ts.map +1 -1
- package/dist/registry/all-tools.js +8 -4
- package/dist/registry/all-tools.js.map +1 -1
- package/dist/registry/context.d.ts +1 -7
- package/dist/registry/context.d.ts.map +1 -1
- package/dist/registry/context.js +0 -11
- package/dist/registry/context.js.map +1 -1
- package/dist/registry/elicit-links.d.ts +35 -0
- package/dist/registry/elicit-links.d.ts.map +1 -0
- package/dist/registry/elicit-links.js +102 -0
- package/dist/registry/elicit-links.js.map +1 -0
- package/dist/registry/elicitor.d.ts +24 -0
- package/dist/registry/elicitor.d.ts.map +1 -0
- package/dist/registry/elicitor.js +51 -0
- package/dist/registry/elicitor.js.map +1 -0
- package/dist/registry/index.d.ts +2 -2
- package/dist/registry/index.d.ts.map +1 -1
- package/dist/registry/index.js +1 -1
- package/dist/registry/index.js.map +1 -1
- package/dist/registry/registry.d.ts +11 -0
- package/dist/registry/registry.d.ts.map +1 -1
- package/dist/registry/registry.js +87 -0
- package/dist/registry/registry.js.map +1 -1
- package/dist/registry/types.d.ts +61 -13
- package/dist/registry/types.d.ts.map +1 -1
- package/dist/state/delta-store.d.ts +85 -0
- package/dist/state/delta-store.d.ts.map +1 -0
- package/dist/state/delta-store.js +124 -0
- package/dist/state/delta-store.js.map +1 -0
- package/dist/state/schema.d.ts +2 -3
- package/dist/state/schema.d.ts.map +1 -1
- package/dist/state/schema.js +26 -3
- package/dist/state/schema.js.map +1 -1
- package/dist/state/store.d.ts +3 -0
- package/dist/state/store.d.ts.map +1 -1
- package/dist/state/store.js +4 -0
- package/dist/state/store.js.map +1 -1
- package/dist/tools/calendar-graph.d.ts.map +1 -1
- package/dist/tools/calendar-graph.js +10 -9
- package/dist/tools/calendar-graph.js.map +1 -1
- package/dist/tools/calendar-permissions.d.ts +7 -7
- package/dist/tools/calendar-permissions.d.ts.map +1 -1
- package/dist/tools/calendar-permissions.js +7 -4
- package/dist/tools/calendar-permissions.js.map +1 -1
- package/dist/tools/calendar.d.ts +14 -114
- package/dist/tools/calendar.d.ts.map +1 -1
- package/dist/tools/calendar.js +41 -202
- package/dist/tools/calendar.js.map +1 -1
- package/dist/tools/categories.d.ts +4 -4
- package/dist/tools/categories.d.ts.map +1 -1
- package/dist/tools/categories.js +5 -2
- package/dist/tools/categories.js.map +1 -1
- package/dist/tools/checklist-items.d.ts +9 -9
- package/dist/tools/checklist-items.d.ts.map +1 -1
- package/dist/tools/checklist-items.js +8 -5
- package/dist/tools/checklist-items.js.map +1 -1
- package/dist/tools/contact-folders.d.ts +2 -2
- package/dist/tools/contact-folders.d.ts.map +1 -1
- package/dist/tools/contact-folders.js +5 -2
- package/dist/tools/contact-folders.js.map +1 -1
- package/dist/tools/contacts-graph.d.ts +1 -1
- package/dist/tools/contacts-graph.d.ts.map +1 -1
- package/dist/tools/contacts-graph.js +8 -6
- package/dist/tools/contacts-graph.js.map +1 -1
- package/dist/tools/contacts.d.ts +9 -44
- package/dist/tools/contacts.d.ts.map +1 -1
- package/dist/tools/contacts.js +23 -131
- package/dist/tools/contacts.js.map +1 -1
- package/dist/tools/excel.d.ts +10 -10
- package/dist/tools/excel.d.ts.map +1 -1
- package/dist/tools/excel.js +9 -6
- package/dist/tools/excel.js.map +1 -1
- package/dist/tools/focused-overrides.d.ts +4 -4
- package/dist/tools/focused-overrides.d.ts.map +1 -1
- package/dist/tools/focused-overrides.js +5 -2
- package/dist/tools/focused-overrides.js.map +1 -1
- package/dist/tools/index.d.ts +4 -5
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +4 -6
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/linked-resources.d.ts +7 -7
- package/dist/tools/linked-resources.d.ts.map +1 -1
- package/dist/tools/linked-resources.js +7 -4
- package/dist/tools/linked-resources.js.map +1 -1
- package/dist/tools/mail-graph.d.ts.map +1 -1
- package/dist/tools/mail-graph.js +21 -12
- package/dist/tools/mail-graph.js.map +1 -1
- package/dist/tools/mail-rules.d.ts +8 -8
- package/dist/tools/mail-rules.d.ts.map +1 -1
- package/dist/tools/mail-rules.js +7 -7
- package/dist/tools/mail-rules.js.map +1 -1
- package/dist/tools/mail-send.d.ts +27 -27
- package/dist/tools/mail-send.d.ts.map +1 -1
- package/dist/tools/mail-send.js +30 -19
- package/dist/tools/mail-send.js.map +1 -1
- package/dist/tools/mail.d.ts +22 -79
- package/dist/tools/mail.d.ts.map +1 -1
- package/dist/tools/mail.js +45 -293
- package/dist/tools/mail.js.map +1 -1
- package/dist/tools/mailbox-organization.d.ts +34 -37
- package/dist/tools/mailbox-organization.d.ts.map +1 -1
- package/dist/tools/mailbox-organization.js +72 -64
- package/dist/tools/mailbox-organization.js.map +1 -1
- package/dist/tools/meetings.d.ts +14 -14
- package/dist/tools/meetings.d.ts.map +1 -1
- package/dist/tools/meetings.js +8 -6
- package/dist/tools/meetings.js.map +1 -1
- package/dist/tools/onedrive.d.ts +16 -16
- package/dist/tools/onedrive.d.ts.map +1 -1
- package/dist/tools/onedrive.js +16 -11
- package/dist/tools/onedrive.js.map +1 -1
- package/dist/tools/onenote.d.ts +63 -0
- package/dist/tools/onenote.d.ts.map +1 -0
- package/dist/tools/onenote.js +221 -0
- package/dist/tools/onenote.js.map +1 -0
- package/dist/tools/planner-visualization.d.ts +5 -5
- package/dist/tools/planner-visualization.d.ts.map +1 -1
- package/dist/tools/planner-visualization.js +5 -4
- package/dist/tools/planner-visualization.js.map +1 -1
- package/dist/tools/planner.d.ts +59 -39
- package/dist/tools/planner.d.ts.map +1 -1
- package/dist/tools/planner.js +48 -23
- package/dist/tools/planner.js.map +1 -1
- package/dist/tools/shared-mailbox.d.ts +164 -0
- package/dist/tools/shared-mailbox.d.ts.map +1 -0
- package/dist/tools/shared-mailbox.js +318 -0
- package/dist/tools/shared-mailbox.js.map +1 -0
- package/dist/tools/sharepoint-lists.d.ts +131 -0
- package/dist/tools/sharepoint-lists.d.ts.map +1 -0
- package/dist/tools/sharepoint-lists.js +246 -0
- package/dist/tools/sharepoint-lists.js.map +1 -0
- package/dist/tools/sharepoint.d.ts +14 -14
- package/dist/tools/sharepoint.d.ts.map +1 -1
- package/dist/tools/sharepoint.js +11 -9
- package/dist/tools/sharepoint.js.map +1 -1
- package/dist/tools/task-attachments.d.ts +7 -7
- package/dist/tools/task-attachments.d.ts.map +1 -1
- package/dist/tools/task-attachments.js +7 -4
- package/dist/tools/task-attachments.js.map +1 -1
- package/dist/tools/task-lists.d.ts +3 -3
- package/dist/tools/task-lists.d.ts.map +1 -1
- package/dist/tools/task-lists.js +10 -6
- package/dist/tools/task-lists.js.map +1 -1
- package/dist/tools/tasks-graph.d.ts +2 -2
- package/dist/tools/tasks-graph.d.ts.map +1 -1
- package/dist/tools/tasks-graph.js +6 -4
- package/dist/tools/tasks-graph.js.map +1 -1
- package/dist/tools/tasks.d.ts +8 -43
- package/dist/tools/tasks.d.ts.map +1 -1
- package/dist/tools/tasks.js +19 -122
- package/dist/tools/tasks.js.map +1 -1
- package/dist/tools/teams.d.ts +46 -46
- package/dist/tools/teams.d.ts.map +1 -1
- package/dist/tools/teams.js +34 -26
- package/dist/tools/teams.js.map +1 -1
- package/dist/tools/what-changed.d.ts +48 -0
- package/dist/tools/what-changed.d.ts.map +1 -0
- package/dist/tools/what-changed.js +149 -0
- package/dist/tools/what-changed.js.map +1 -0
- package/dist/types/calendar.d.ts +1 -1
- package/dist/types/calendar.d.ts.map +1 -1
- package/dist/types/calendar.js.map +1 -1
- package/dist/types/contacts.d.ts +1 -1
- package/dist/types/contacts.d.ts.map +1 -1
- package/dist/types/contacts.js.map +1 -1
- package/dist/types/mail.d.ts +1 -1
- package/dist/types/mail.d.ts.map +1 -1
- package/dist/types/mail.js.map +1 -1
- package/dist/utils/errors.d.ts +15 -34
- package/dist/utils/errors.d.ts.map +1 -1
- package/dist/utils/errors.js +13 -49
- package/dist/utils/errors.js.map +1 -1
- package/dist/visualization/types.d.ts +4 -4
- package/package.json +3 -4
- package/dist/applescript/account-repository.d.ts +0 -30
- package/dist/applescript/account-repository.d.ts.map +0 -1
- package/dist/applescript/account-repository.js +0 -38
- package/dist/applescript/account-repository.js.map +0 -1
- package/dist/applescript/account-scripts.d.ts +0 -21
- package/dist/applescript/account-scripts.d.ts.map +0 -1
- package/dist/applescript/account-scripts.js +0 -180
- package/dist/applescript/account-scripts.js.map +0 -1
- package/dist/applescript/calendar-manager.d.ts +0 -44
- package/dist/applescript/calendar-manager.d.ts.map +0 -1
- package/dist/applescript/calendar-manager.js +0 -92
- package/dist/applescript/calendar-manager.js.map +0 -1
- package/dist/applescript/calendar-writer.d.ts +0 -36
- package/dist/applescript/calendar-writer.d.ts.map +0 -1
- package/dist/applescript/calendar-writer.js +0 -94
- package/dist/applescript/calendar-writer.js.map +0 -1
- package/dist/applescript/content-readers.d.ts +0 -114
- package/dist/applescript/content-readers.d.ts.map +0 -1
- package/dist/applescript/content-readers.js +0 -328
- package/dist/applescript/content-readers.js.map +0 -1
- package/dist/applescript/executor.d.ts +0 -60
- package/dist/applescript/executor.d.ts.map +0 -1
- package/dist/applescript/executor.js +0 -173
- package/dist/applescript/executor.js.map +0 -1
- package/dist/applescript/index.d.ts +0 -20
- package/dist/applescript/index.d.ts.map +0 -1
- package/dist/applescript/index.js +0 -29
- package/dist/applescript/index.js.map +0 -1
- package/dist/applescript/mail-sender.d.ts +0 -38
- package/dist/applescript/mail-sender.d.ts.map +0 -1
- package/dist/applescript/mail-sender.js +0 -67
- package/dist/applescript/mail-sender.js.map +0 -1
- package/dist/applescript/parser.d.ts +0 -235
- package/dist/applescript/parser.d.ts.map +0 -1
- package/dist/applescript/parser.js +0 -496
- package/dist/applescript/parser.js.map +0 -1
- package/dist/applescript/repository.d.ts +0 -64
- package/dist/applescript/repository.d.ts.map +0 -1
- package/dist/applescript/repository.js +0 -444
- package/dist/applescript/repository.js.map +0 -1
- package/dist/applescript/scripts.d.ts +0 -265
- package/dist/applescript/scripts.d.ts.map +0 -1
- package/dist/applescript/scripts.js +0 -1483
- package/dist/applescript/scripts.js.map +0 -1
- package/dist/parsers/olk15.d.ts +0 -87
- package/dist/parsers/olk15.d.ts.map +0 -1
- package/dist/parsers/olk15.js +0 -368
- package/dist/parsers/olk15.js.map +0 -1
- package/dist/tools/accounts.d.ts +0 -37
- package/dist/tools/accounts.d.ts.map +0 -1
- package/dist/tools/accounts.js +0 -68
- package/dist/tools/accounts.js.map +0 -1
- package/dist/tools/calendar-apple.d.ts +0 -39
- package/dist/tools/calendar-apple.d.ts.map +0 -1
- package/dist/tools/calendar-apple.js +0 -159
- package/dist/tools/calendar-apple.js.map +0 -1
- package/dist/tools/mail-apple.d.ts +0 -40
- package/dist/tools/mail-apple.d.ts.map +0 -1
- package/dist/tools/mail-apple.js +0 -146
- package/dist/tools/mail-apple.js.map +0 -1
- package/dist/tools/notes.d.ts +0 -86
- package/dist/tools/notes.d.ts.map +0 -1
- package/dist/tools/notes.js +0 -202
- package/dist/tools/notes.js.map +0 -1
package/dist/tools/mail.d.ts
CHANGED
|
@@ -2,39 +2,36 @@
|
|
|
2
2
|
* Copyright (c) 2026 JBC Tech Solutions, LLC
|
|
3
3
|
* Licensed under the MIT License. See LICENSE file in the project root.
|
|
4
4
|
*/
|
|
5
|
+
/**
|
|
6
|
+
* Mail-related MCP tools.
|
|
7
|
+
*
|
|
8
|
+
* Provides tools for listing folders, emails, and searching.
|
|
9
|
+
*/
|
|
5
10
|
import { z } from 'zod';
|
|
6
|
-
import type { IRepository } from '../database/repository.js';
|
|
7
|
-
import type { Folder, EmailSummary, Email, AttachmentInfo } from '../types/index.js';
|
|
8
|
-
import type { IAttachmentReader } from '../applescript/content-readers.js';
|
|
9
11
|
import type { ToolDefinition } from '../registry/types.js';
|
|
10
12
|
import type { GraphMailTools } from './mail-graph.js';
|
|
11
|
-
import type { AppleMailTools } from './mail-apple.js';
|
|
12
13
|
declare module '../registry/types.js' {
|
|
13
14
|
interface GraphToolsets {
|
|
14
15
|
mailGraph: GraphMailTools;
|
|
15
16
|
}
|
|
16
|
-
interface AppleScriptToolsets {
|
|
17
|
-
mail: AppleMailTools;
|
|
18
|
-
}
|
|
19
17
|
}
|
|
20
18
|
export declare const ListFoldersInput: z.ZodObject<{}, z.core.$strict>;
|
|
21
19
|
/**
|
|
22
20
|
* Canonical (advertised) input for the `list_folders` tool. The Graph backend
|
|
23
|
-
* ignores `account_id` and returns the default mailbox's folders
|
|
24
|
-
* AppleScript backend uses it to support multi-account grouping.
|
|
21
|
+
* ignores `account_id` and returns the default mailbox's folders.
|
|
25
22
|
*/
|
|
26
23
|
export declare const ListFoldersToolInput: z.ZodObject<{
|
|
27
24
|
account_id: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodArray<z.ZodNumber>, z.ZodLiteral<"all">]>>;
|
|
28
25
|
}, z.core.$strict>;
|
|
29
26
|
export declare const ListEmailsInput: z.ZodObject<{
|
|
30
|
-
folder_id: z.
|
|
27
|
+
folder_id: z.ZodString;
|
|
31
28
|
limit: z.ZodDefault<z.ZodNumber>;
|
|
32
29
|
offset: z.ZodDefault<z.ZodNumber>;
|
|
33
30
|
unread_only: z.ZodDefault<z.ZodBoolean>;
|
|
34
31
|
}, z.core.$strict>;
|
|
35
32
|
export declare const SearchEmailsInput: z.ZodObject<{
|
|
36
33
|
query: z.ZodString;
|
|
37
|
-
folder_id: z.ZodOptional<z.
|
|
34
|
+
folder_id: z.ZodOptional<z.ZodString>;
|
|
38
35
|
limit: z.ZodDefault<z.ZodNumber>;
|
|
39
36
|
}, z.core.$strict>;
|
|
40
37
|
/**
|
|
@@ -61,38 +58,38 @@ export declare const SearchEmailsAdvancedInput: z.ZodObject<{
|
|
|
61
58
|
limit: z.ZodDefault<z.ZodNumber>;
|
|
62
59
|
}, z.core.$strict>;
|
|
63
60
|
export declare const GetEmailInput: z.ZodObject<{
|
|
64
|
-
email_id: z.
|
|
61
|
+
email_id: z.ZodString;
|
|
65
62
|
include_body: z.ZodDefault<z.ZodBoolean>;
|
|
66
63
|
strip_html: z.ZodDefault<z.ZodBoolean>;
|
|
67
64
|
}, z.core.$strict>;
|
|
68
65
|
export declare const GetEmailsInput: z.ZodObject<{
|
|
69
|
-
email_ids: z.ZodArray<z.
|
|
66
|
+
email_ids: z.ZodArray<z.ZodString>;
|
|
70
67
|
include_body: z.ZodDefault<z.ZodBoolean>;
|
|
71
68
|
strip_html: z.ZodDefault<z.ZodBoolean>;
|
|
72
69
|
}, z.core.$strict>;
|
|
73
70
|
export declare const ListConversationInput: z.ZodObject<{
|
|
74
|
-
message_id: z.
|
|
71
|
+
message_id: z.ZodString;
|
|
75
72
|
limit: z.ZodDefault<z.ZodNumber>;
|
|
76
73
|
}, z.core.$strict>;
|
|
77
74
|
export declare const GetUnreadCountInput: z.ZodObject<{
|
|
78
|
-
folder_id: z.ZodOptional<z.
|
|
75
|
+
folder_id: z.ZodOptional<z.ZodString>;
|
|
79
76
|
}, z.core.$strict>;
|
|
80
77
|
export declare const ListAttachmentsInput: z.ZodObject<{
|
|
81
|
-
email_id: z.
|
|
78
|
+
email_id: z.ZodString;
|
|
82
79
|
}, z.core.$strict>;
|
|
83
80
|
export declare const DownloadAttachmentInput: z.ZodObject<{
|
|
84
|
-
email_id: z.
|
|
85
|
-
|
|
81
|
+
email_id: z.ZodString;
|
|
82
|
+
attachment_id: z.ZodString;
|
|
86
83
|
save_path: z.ZodString;
|
|
87
84
|
}, z.core.$strict>;
|
|
88
85
|
export declare const CheckNewEmailsInput: z.ZodObject<{
|
|
89
|
-
folder_id: z.
|
|
86
|
+
folder_id: z.ZodString;
|
|
90
87
|
}, z.core.$strict>;
|
|
91
88
|
export declare const GetMessageHeadersInput: z.ZodObject<{
|
|
92
|
-
email_id: z.
|
|
89
|
+
email_id: z.ZodString;
|
|
93
90
|
}, z.core.$strict>;
|
|
94
91
|
export declare const GetMessageMimeInput: z.ZodObject<{
|
|
95
|
-
email_id: z.
|
|
92
|
+
email_id: z.ZodString;
|
|
96
93
|
}, z.core.$strict>;
|
|
97
94
|
export declare const GetMailTipsInput: z.ZodObject<{
|
|
98
95
|
email_addresses: z.ZodArray<z.ZodString>;
|
|
@@ -113,7 +110,8 @@ export type GetMessageHeadersParams = z.infer<typeof GetMessageHeadersInput>;
|
|
|
113
110
|
export type GetMessageMimeParams = z.infer<typeof GetMessageMimeInput>;
|
|
114
111
|
export type GetMailTipsParams = z.infer<typeof GetMailTipsInput>;
|
|
115
112
|
/**
|
|
116
|
-
* Interface for reading email body content from data files.
|
|
113
|
+
* Interface for reading email body content from data files. Implemented by the
|
|
114
|
+
* Graph content reader.
|
|
117
115
|
*/
|
|
118
116
|
export interface IContentReader {
|
|
119
117
|
/**
|
|
@@ -123,63 +121,8 @@ export interface IContentReader {
|
|
|
123
121
|
readEmailBody(dataFilePath: string | null): string | null;
|
|
124
122
|
}
|
|
125
123
|
/**
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*/
|
|
129
|
-
export declare const nullContentReader: IContentReader;
|
|
130
|
-
/**
|
|
131
|
-
* Mail tools implementation with dependency injection.
|
|
132
|
-
*/
|
|
133
|
-
export declare class MailTools {
|
|
134
|
-
private readonly repository;
|
|
135
|
-
private readonly contentReader;
|
|
136
|
-
private readonly attachmentReader?;
|
|
137
|
-
constructor(repository: IRepository, contentReader?: IContentReader, attachmentReader?: IAttachmentReader | undefined);
|
|
138
|
-
/**
|
|
139
|
-
* Lists all mail folders with message and unread counts.
|
|
140
|
-
*/
|
|
141
|
-
listFolders(_params: ListFoldersParams): Folder[];
|
|
142
|
-
/**
|
|
143
|
-
* Lists emails in a folder with pagination.
|
|
144
|
-
*/
|
|
145
|
-
listEmails(params: ListEmailsParams): EmailSummary[];
|
|
146
|
-
/**
|
|
147
|
-
* Searches emails by subject, sender, or preview.
|
|
148
|
-
*/
|
|
149
|
-
searchEmails(params: SearchEmailsParams): EmailSummary[];
|
|
150
|
-
/**
|
|
151
|
-
* Gets a single email by ID with optional body content.
|
|
152
|
-
*/
|
|
153
|
-
getEmail(params: GetEmailParams): (Email & {
|
|
154
|
-
attachments: AttachmentInfo[];
|
|
155
|
-
}) | null;
|
|
156
|
-
/**
|
|
157
|
-
* Gets the unread email count.
|
|
158
|
-
*/
|
|
159
|
-
getUnreadCount(params: GetUnreadCountParams): {
|
|
160
|
-
count: number;
|
|
161
|
-
};
|
|
162
|
-
/**
|
|
163
|
-
* Lists attachment metadata for an email.
|
|
164
|
-
*/
|
|
165
|
-
listAttachments(params: ListAttachmentsParams): AttachmentInfo[];
|
|
166
|
-
/**
|
|
167
|
-
* Downloads/saves an attachment to disk.
|
|
168
|
-
*/
|
|
169
|
-
downloadAttachment(params: DownloadAttachmentParams): {
|
|
170
|
-
name: string;
|
|
171
|
-
savedTo: string;
|
|
172
|
-
size: number;
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* Creates mail tools with the given repository.
|
|
177
|
-
*/
|
|
178
|
-
export declare function createMailTools(repository: IRepository, contentReader?: IContentReader, attachmentReader?: IAttachmentReader): MailTools;
|
|
179
|
-
/**
|
|
180
|
-
* Registry tool definitions for the mail READ domain. Each handler branches on
|
|
181
|
-
* the active backend: Graph delegates to GraphMailTools; AppleScript delegates
|
|
182
|
-
* to AppleMailTools. Both toolsets return MCP content directly.
|
|
124
|
+
* Registry tool definitions for the mail READ domain. Each handler delegates
|
|
125
|
+
* to GraphMailTools, which returns MCP content directly.
|
|
183
126
|
*/
|
|
184
127
|
export declare const SendEmailInput: z.ZodObject<{
|
|
185
128
|
to: z.ZodArray<z.ZodString>;
|
package/dist/tools/mail.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mail.d.ts","sourceRoot":"","sources":["../../src/tools/mail.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"mail.d.ts","sourceRoot":"","sources":["../../src/tools/mail.ts"],"names":[],"mappings":"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"}
|
package/dist/tools/mail.js
CHANGED
|
@@ -7,23 +7,23 @@
|
|
|
7
7
|
*
|
|
8
8
|
* Provides tools for listing folders, emails, and searching.
|
|
9
9
|
*/
|
|
10
|
-
import { existsSync } from 'fs';
|
|
11
|
-
import { dirname } from 'path';
|
|
12
10
|
import { z } from 'zod';
|
|
13
|
-
import { MAX_ATTACHMENT_DOWNLOAD_SIZE } from '../types/mail.js';
|
|
14
|
-
import { appleTimestampToIso } from '../utils/dates.js';
|
|
15
|
-
import { extractPlainText } from '../parsers/html-stripper.js';
|
|
16
|
-
import { NotFoundError, ValidationError, AttachmentTooLargeError, AttachmentSaveError } from '../utils/errors.js';
|
|
17
11
|
import { defineTool } from '../registry/define-tool.js';
|
|
18
|
-
import { requireGraphToolset
|
|
12
|
+
import { requireGraphToolset } from '../registry/context.js';
|
|
13
|
+
import { Id } from '../ids/schema.js';
|
|
19
14
|
// =============================================================================
|
|
20
15
|
// Input Schemas
|
|
21
16
|
// =============================================================================
|
|
17
|
+
/**
|
|
18
|
+
* Shared email/message id schema (U6): the canonical `em_` message-id schema.
|
|
19
|
+
* A raw Graph id is also accepted; a legacy numeric id is a validation error
|
|
20
|
+
* (numeric strings still route to resolveId → NUMERIC_ID_UNSUPPORTED).
|
|
21
|
+
*/
|
|
22
|
+
const EmailIdSchema = Id.message;
|
|
22
23
|
export const ListFoldersInput = z.strictObject({});
|
|
23
24
|
/**
|
|
24
25
|
* Canonical (advertised) input for the `list_folders` tool. The Graph backend
|
|
25
|
-
* ignores `account_id` and returns the default mailbox's folders
|
|
26
|
-
* AppleScript backend uses it to support multi-account grouping.
|
|
26
|
+
* ignores `account_id` and returns the default mailbox's folders.
|
|
27
27
|
*/
|
|
28
28
|
export const ListFoldersToolInput = z.strictObject({
|
|
29
29
|
account_id: z
|
|
@@ -32,7 +32,7 @@ export const ListFoldersToolInput = z.strictObject({
|
|
|
32
32
|
.describe('Account filter: number (specific account), array (multiple accounts), "all" (all accounts), or omit for default account'),
|
|
33
33
|
});
|
|
34
34
|
export const ListEmailsInput = z.strictObject({
|
|
35
|
-
folder_id:
|
|
35
|
+
folder_id: Id.folder.describe('The folder to list emails from — a `fd_` token from list_folders.'),
|
|
36
36
|
limit: z
|
|
37
37
|
.number()
|
|
38
38
|
.int()
|
|
@@ -45,12 +45,7 @@ export const ListEmailsInput = z.strictObject({
|
|
|
45
45
|
});
|
|
46
46
|
export const SearchEmailsInput = z.strictObject({
|
|
47
47
|
query: z.string().min(1).describe('Search query (searches subject, sender, and preview)'),
|
|
48
|
-
folder_id:
|
|
49
|
-
.number()
|
|
50
|
-
.int()
|
|
51
|
-
.positive()
|
|
52
|
-
.optional()
|
|
53
|
-
.describe('Optional folder ID to limit search to'),
|
|
48
|
+
folder_id: Id.folder.optional().describe('Optional folder to limit search to — a `fd_` token from list_folders.'),
|
|
54
49
|
limit: z
|
|
55
50
|
.number()
|
|
56
51
|
.int()
|
|
@@ -79,278 +74,53 @@ export const SearchEmailsAdvancedInput = z.strictObject({
|
|
|
79
74
|
limit: z.number().int().min(1).max(100).default(50).describe('Maximum results (1-100)'),
|
|
80
75
|
});
|
|
81
76
|
export const GetEmailInput = z.strictObject({
|
|
82
|
-
email_id:
|
|
77
|
+
email_id: EmailIdSchema.describe('The email ID to retrieve'),
|
|
83
78
|
include_body: z.boolean().default(true).describe('Include the email body in the response'),
|
|
84
79
|
strip_html: z.boolean().default(true).describe('Strip HTML tags from the body'),
|
|
85
80
|
});
|
|
86
81
|
export const GetEmailsInput = z.strictObject({
|
|
87
|
-
email_ids: z.array(
|
|
82
|
+
email_ids: z.array(EmailIdSchema).min(1).max(25)
|
|
88
83
|
.describe('Array of email IDs to fetch (max 25)'),
|
|
89
84
|
include_body: z.boolean().default(false).describe('Include full email body'),
|
|
90
85
|
strip_html: z.boolean().default(false).describe('Strip HTML tags from body'),
|
|
91
86
|
});
|
|
92
87
|
export const ListConversationInput = z.strictObject({
|
|
93
|
-
message_id:
|
|
88
|
+
message_id: EmailIdSchema.describe('Any message ID from the conversation thread'),
|
|
94
89
|
limit: z.number().int().min(1).max(100).default(25).describe('Maximum messages to return'),
|
|
95
90
|
});
|
|
96
91
|
export const GetUnreadCountInput = z.strictObject({
|
|
97
92
|
folder_id: z
|
|
98
|
-
.
|
|
99
|
-
.
|
|
100
|
-
.positive()
|
|
93
|
+
.string()
|
|
94
|
+
.min(1)
|
|
101
95
|
.optional()
|
|
102
96
|
.describe('Optional folder ID to get unread count for'),
|
|
103
97
|
});
|
|
104
98
|
export const ListAttachmentsInput = z.strictObject({
|
|
105
|
-
email_id:
|
|
99
|
+
email_id: EmailIdSchema.describe('The email ID to list attachments for'),
|
|
106
100
|
});
|
|
107
101
|
export const DownloadAttachmentInput = z.strictObject({
|
|
108
|
-
email_id:
|
|
109
|
-
|
|
102
|
+
email_id: EmailIdSchema.describe('The email ID containing the attachment'),
|
|
103
|
+
attachment_id: Id.attachment,
|
|
110
104
|
save_path: z.string().min(1).describe('Absolute file path where the attachment should be saved'),
|
|
111
105
|
});
|
|
112
106
|
export const CheckNewEmailsInput = z.strictObject({
|
|
113
|
-
folder_id:
|
|
107
|
+
folder_id: Id.folder.describe('Folder to check for new emails — a `fd_` token from list_folders.'),
|
|
114
108
|
});
|
|
115
109
|
export const GetMessageHeadersInput = z.strictObject({
|
|
116
|
-
email_id:
|
|
110
|
+
email_id: EmailIdSchema.describe('Email ID'),
|
|
117
111
|
});
|
|
118
112
|
export const GetMessageMimeInput = z.strictObject({
|
|
119
|
-
email_id:
|
|
113
|
+
email_id: EmailIdSchema.describe('Email ID'),
|
|
120
114
|
});
|
|
121
115
|
export const GetMailTipsInput = z.strictObject({
|
|
122
116
|
email_addresses: z.array(z.string().email()).min(1).max(20).describe('Email addresses to check'),
|
|
123
117
|
});
|
|
124
118
|
// =============================================================================
|
|
125
|
-
//
|
|
126
|
-
// =============================================================================
|
|
127
|
-
/**
|
|
128
|
-
* Transforms a database folder row to domain Folder type.
|
|
129
|
-
*/
|
|
130
|
-
function transformFolder(row) {
|
|
131
|
-
return {
|
|
132
|
-
id: row.id,
|
|
133
|
-
name: row.name ?? 'Unnamed',
|
|
134
|
-
parentId: row.parentId,
|
|
135
|
-
specialType: row.specialType,
|
|
136
|
-
folderType: row.folderType,
|
|
137
|
-
accountId: row.accountId,
|
|
138
|
-
messageCount: row.messageCount,
|
|
139
|
-
unreadCount: row.unreadCount,
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Transforms a database email row to domain EmailSummary type.
|
|
144
|
-
*/
|
|
145
|
-
function transformEmailSummary(row) {
|
|
146
|
-
return {
|
|
147
|
-
id: row.id,
|
|
148
|
-
folderId: row.folderId,
|
|
149
|
-
subject: row.subject,
|
|
150
|
-
sender: row.sender,
|
|
151
|
-
senderAddress: row.senderAddress,
|
|
152
|
-
preview: row.preview,
|
|
153
|
-
isRead: row.isRead === 1,
|
|
154
|
-
timeReceived: appleTimestampToIso(row.timeReceived),
|
|
155
|
-
timeSent: appleTimestampToIso(row.timeSent),
|
|
156
|
-
hasAttachment: row.hasAttachment === 1,
|
|
157
|
-
priority: row.priority,
|
|
158
|
-
flagStatus: row.flagStatus,
|
|
159
|
-
categories: parseCategories(row.categories),
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Parses categories from the database buffer.
|
|
164
|
-
* Outlook stores categories as a null-delimited or comma-delimited buffer.
|
|
165
|
-
*/
|
|
166
|
-
function parseCategories(buffer) {
|
|
167
|
-
if (buffer == null || buffer.length === 0) {
|
|
168
|
-
return [];
|
|
169
|
-
}
|
|
170
|
-
try {
|
|
171
|
-
const text = buffer.toString('utf-8');
|
|
172
|
-
// Categories may be stored as null-delimited or comma-delimited strings
|
|
173
|
-
const categories = text.includes('\0')
|
|
174
|
-
? text.split('\0').filter(s => s.length > 0)
|
|
175
|
-
: text.split(',').map(s => s.trim()).filter(s => s.length > 0);
|
|
176
|
-
return categories;
|
|
177
|
-
}
|
|
178
|
-
catch {
|
|
179
|
-
return [];
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
* Transforms a database email row to domain Email type.
|
|
184
|
-
*/
|
|
185
|
-
function transformEmail(row, body, stripHtml) {
|
|
186
|
-
const summary = transformEmailSummary(row);
|
|
187
|
-
// Process the body
|
|
188
|
-
let processedBody = null;
|
|
189
|
-
let htmlBody = null;
|
|
190
|
-
if (body != null) {
|
|
191
|
-
htmlBody = body;
|
|
192
|
-
processedBody = stripHtml ? extractPlainText(body) : body;
|
|
193
|
-
}
|
|
194
|
-
return {
|
|
195
|
-
...summary,
|
|
196
|
-
recipients: row.recipients,
|
|
197
|
-
displayTo: row.displayTo,
|
|
198
|
-
toAddresses: row.toAddresses,
|
|
199
|
-
ccAddresses: row.ccAddresses,
|
|
200
|
-
size: row.size,
|
|
201
|
-
messageId: row.messageId ?? null,
|
|
202
|
-
conversationId: row.conversationId ?? null,
|
|
203
|
-
body: processedBody,
|
|
204
|
-
htmlBody: stripHtml ? null : htmlBody,
|
|
205
|
-
};
|
|
206
|
-
}
|
|
207
|
-
/**
|
|
208
|
-
* Default content reader that returns null (body reading not implemented yet).
|
|
209
|
-
* Will be replaced with OLK15 parser implementation.
|
|
210
|
-
*/
|
|
211
|
-
export const nullContentReader = {
|
|
212
|
-
readEmailBody: () => null,
|
|
213
|
-
};
|
|
214
|
-
// =============================================================================
|
|
215
|
-
// Mail Tools Class
|
|
119
|
+
// Registry Definitions (v3 registry-driven architecture)
|
|
216
120
|
// =============================================================================
|
|
217
121
|
/**
|
|
218
|
-
*
|
|
219
|
-
|
|
220
|
-
export class MailTools {
|
|
221
|
-
repository;
|
|
222
|
-
contentReader;
|
|
223
|
-
attachmentReader;
|
|
224
|
-
constructor(repository, contentReader = nullContentReader, attachmentReader) {
|
|
225
|
-
this.repository = repository;
|
|
226
|
-
this.contentReader = contentReader;
|
|
227
|
-
this.attachmentReader = attachmentReader;
|
|
228
|
-
}
|
|
229
|
-
/**
|
|
230
|
-
* Lists all mail folders with message and unread counts.
|
|
231
|
-
*/
|
|
232
|
-
listFolders(_params) {
|
|
233
|
-
const rows = this.repository.listFolders();
|
|
234
|
-
return rows.map(transformFolder);
|
|
235
|
-
}
|
|
236
|
-
/**
|
|
237
|
-
* Lists emails in a folder with pagination.
|
|
238
|
-
*/
|
|
239
|
-
listEmails(params) {
|
|
240
|
-
const { folder_id, limit, offset, unread_only } = params;
|
|
241
|
-
const rows = unread_only
|
|
242
|
-
? this.repository.listUnreadEmails(folder_id, limit, offset)
|
|
243
|
-
: this.repository.listEmails(folder_id, limit, offset);
|
|
244
|
-
return rows.map(transformEmailSummary);
|
|
245
|
-
}
|
|
246
|
-
/**
|
|
247
|
-
* Searches emails by subject, sender, or preview.
|
|
248
|
-
*/
|
|
249
|
-
searchEmails(params) {
|
|
250
|
-
const { query, folder_id, limit } = params;
|
|
251
|
-
const rows = folder_id != null
|
|
252
|
-
? this.repository.searchEmailsInFolder(folder_id, query, limit)
|
|
253
|
-
: this.repository.searchEmails(query, limit);
|
|
254
|
-
return rows.map(transformEmailSummary);
|
|
255
|
-
}
|
|
256
|
-
/**
|
|
257
|
-
* Gets a single email by ID with optional body content.
|
|
258
|
-
*/
|
|
259
|
-
getEmail(params) {
|
|
260
|
-
const { email_id, include_body, strip_html } = params;
|
|
261
|
-
const row = this.repository.getEmail(email_id);
|
|
262
|
-
if (row == null) {
|
|
263
|
-
return null;
|
|
264
|
-
}
|
|
265
|
-
// Get body content if requested
|
|
266
|
-
let body = null;
|
|
267
|
-
if (include_body && row.dataFilePath != null) {
|
|
268
|
-
body = this.contentReader.readEmailBody(row.dataFilePath);
|
|
269
|
-
}
|
|
270
|
-
// Get attachment metadata if available
|
|
271
|
-
let attachments = [];
|
|
272
|
-
if (this.attachmentReader != null && row.hasAttachment === 1) {
|
|
273
|
-
attachments = this.attachmentReader.listAttachments(email_id);
|
|
274
|
-
}
|
|
275
|
-
return {
|
|
276
|
-
...transformEmail(row, body, strip_html),
|
|
277
|
-
attachments,
|
|
278
|
-
};
|
|
279
|
-
}
|
|
280
|
-
/**
|
|
281
|
-
* Gets the unread email count.
|
|
282
|
-
*/
|
|
283
|
-
getUnreadCount(params) {
|
|
284
|
-
const { folder_id } = params;
|
|
285
|
-
const count = folder_id != null
|
|
286
|
-
? this.repository.getUnreadCountByFolder(folder_id)
|
|
287
|
-
: this.repository.getUnreadCount();
|
|
288
|
-
return { count };
|
|
289
|
-
}
|
|
290
|
-
/**
|
|
291
|
-
* Lists attachment metadata for an email.
|
|
292
|
-
*/
|
|
293
|
-
listAttachments(params) {
|
|
294
|
-
if (this.attachmentReader == null) {
|
|
295
|
-
return [];
|
|
296
|
-
}
|
|
297
|
-
const { email_id } = params;
|
|
298
|
-
const row = this.repository.getEmail(email_id);
|
|
299
|
-
if (row == null) {
|
|
300
|
-
throw new NotFoundError('Email', email_id);
|
|
301
|
-
}
|
|
302
|
-
return this.attachmentReader.listAttachments(email_id);
|
|
303
|
-
}
|
|
304
|
-
/**
|
|
305
|
-
* Downloads/saves an attachment to disk.
|
|
306
|
-
*/
|
|
307
|
-
downloadAttachment(params) {
|
|
308
|
-
if (this.attachmentReader == null) {
|
|
309
|
-
throw new ValidationError('Attachment reader not available');
|
|
310
|
-
}
|
|
311
|
-
const { email_id, attachment_index, save_path } = params;
|
|
312
|
-
const row = this.repository.getEmail(email_id);
|
|
313
|
-
if (row == null) {
|
|
314
|
-
throw new NotFoundError('Email', email_id);
|
|
315
|
-
}
|
|
316
|
-
// Validate save path directory exists
|
|
317
|
-
const dir = dirname(save_path);
|
|
318
|
-
if (!existsSync(dir)) {
|
|
319
|
-
throw new ValidationError(`Directory does not exist: ${dir}`);
|
|
320
|
-
}
|
|
321
|
-
// Get attachment list to validate index and check size
|
|
322
|
-
const attachments = this.attachmentReader.listAttachments(email_id);
|
|
323
|
-
const attachment = attachments.find(a => a.index === attachment_index);
|
|
324
|
-
if (attachment == null) {
|
|
325
|
-
throw new NotFoundError('Attachment', attachment_index);
|
|
326
|
-
}
|
|
327
|
-
if (attachment.size > MAX_ATTACHMENT_DOWNLOAD_SIZE) {
|
|
328
|
-
throw new AttachmentTooLargeError(attachment.name, attachment.size, MAX_ATTACHMENT_DOWNLOAD_SIZE);
|
|
329
|
-
}
|
|
330
|
-
const result = this.attachmentReader.saveAttachment(email_id, attachment_index, save_path);
|
|
331
|
-
if (!result.success) {
|
|
332
|
-
throw new AttachmentSaveError(attachment.name, result.error ?? 'Unknown error');
|
|
333
|
-
}
|
|
334
|
-
return {
|
|
335
|
-
name: result.name ?? attachment.name,
|
|
336
|
-
savedTo: result.savedTo ?? save_path,
|
|
337
|
-
size: result.fileSize ?? attachment.size,
|
|
338
|
-
};
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
/**
|
|
342
|
-
* Creates mail tools with the given repository.
|
|
343
|
-
*/
|
|
344
|
-
export function createMailTools(repository, contentReader = nullContentReader, attachmentReader) {
|
|
345
|
-
return new MailTools(repository, contentReader, attachmentReader);
|
|
346
|
-
}
|
|
347
|
-
// =============================================================================
|
|
348
|
-
// Registry Definitions (v3 registry-driven architecture, U2 — dual backend)
|
|
349
|
-
// =============================================================================
|
|
350
|
-
/**
|
|
351
|
-
* Registry tool definitions for the mail READ domain. Each handler branches on
|
|
352
|
-
* the active backend: Graph delegates to GraphMailTools; AppleScript delegates
|
|
353
|
-
* to AppleMailTools. Both toolsets return MCP content directly.
|
|
122
|
+
* Registry tool definitions for the mail READ domain. Each handler delegates
|
|
123
|
+
* to GraphMailTools, which returns MCP content directly.
|
|
354
124
|
*/
|
|
355
125
|
export const SendEmailInput = z.strictObject({
|
|
356
126
|
to: z.array(z.string()).min(1).describe('Recipient email addresses'),
|
|
@@ -379,12 +149,10 @@ export function mailToolDefinitions() {
|
|
|
379
149
|
annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: true },
|
|
380
150
|
destructive: true,
|
|
381
151
|
presets: ['mail'],
|
|
382
|
-
backends: ['graph'
|
|
383
|
-
//
|
|
384
|
-
//
|
|
385
|
-
handler: (
|
|
386
|
-
? { content: [{ type: 'text', text: 'Direct send_email is not available on the Graph backend; use prepare_send_email then confirm_send_email.' }], isError: true }
|
|
387
|
-
: requireAppleScriptToolset(ctx, 'mail').sendEmail(params),
|
|
152
|
+
backends: ['graph'],
|
|
153
|
+
// Direct send is not available on the Graph backend — clients use the
|
|
154
|
+
// two-phase prepare_send_email/confirm_send_email.
|
|
155
|
+
handler: () => ({ content: [{ type: 'text', text: 'Direct send_email is not available on the Graph backend; use prepare_send_email then confirm_send_email.' }], isError: true }),
|
|
388
156
|
}),
|
|
389
157
|
defineTool({
|
|
390
158
|
name: 'list_folders',
|
|
@@ -393,10 +161,8 @@ export function mailToolDefinitions() {
|
|
|
393
161
|
annotations: { readOnlyHint: true },
|
|
394
162
|
destructive: false,
|
|
395
163
|
presets: ['mail'],
|
|
396
|
-
backends: ['graph'
|
|
397
|
-
handler: (ctx, params) => ctx
|
|
398
|
-
? requireGraphToolset(ctx, 'mailGraph').listFolders(params)
|
|
399
|
-
: requireAppleScriptToolset(ctx, 'mail').listFolders(params),
|
|
164
|
+
backends: ['graph'],
|
|
165
|
+
handler: (ctx, params) => requireGraphToolset(ctx, 'mailGraph').listFolders(params),
|
|
400
166
|
}),
|
|
401
167
|
defineTool({
|
|
402
168
|
name: 'list_emails',
|
|
@@ -405,10 +171,8 @@ export function mailToolDefinitions() {
|
|
|
405
171
|
annotations: { readOnlyHint: true },
|
|
406
172
|
destructive: false,
|
|
407
173
|
presets: ['mail'],
|
|
408
|
-
backends: ['graph'
|
|
409
|
-
handler: (ctx, params) => ctx
|
|
410
|
-
? requireGraphToolset(ctx, 'mailGraph').listEmails(params)
|
|
411
|
-
: requireAppleScriptToolset(ctx, 'mail').listEmails(params),
|
|
174
|
+
backends: ['graph'],
|
|
175
|
+
handler: (ctx, params) => requireGraphToolset(ctx, 'mailGraph').listEmails(params),
|
|
412
176
|
}),
|
|
413
177
|
defineTool({
|
|
414
178
|
name: 'search_emails',
|
|
@@ -417,10 +181,8 @@ export function mailToolDefinitions() {
|
|
|
417
181
|
annotations: { readOnlyHint: true },
|
|
418
182
|
destructive: false,
|
|
419
183
|
presets: ['mail'],
|
|
420
|
-
backends: ['graph'
|
|
421
|
-
handler: (ctx, params) => ctx
|
|
422
|
-
? requireGraphToolset(ctx, 'mailGraph').searchEmails(params)
|
|
423
|
-
: requireAppleScriptToolset(ctx, 'mail').searchEmails(params),
|
|
184
|
+
backends: ['graph'],
|
|
185
|
+
handler: (ctx, params) => requireGraphToolset(ctx, 'mailGraph').searchEmails(params),
|
|
424
186
|
}),
|
|
425
187
|
defineTool({
|
|
426
188
|
name: 'get_email',
|
|
@@ -429,10 +191,8 @@ export function mailToolDefinitions() {
|
|
|
429
191
|
annotations: { readOnlyHint: true },
|
|
430
192
|
destructive: false,
|
|
431
193
|
presets: ['mail'],
|
|
432
|
-
backends: ['graph'
|
|
433
|
-
handler: (ctx, params) => ctx
|
|
434
|
-
? requireGraphToolset(ctx, 'mailGraph').getEmail(params)
|
|
435
|
-
: requireAppleScriptToolset(ctx, 'mail').getEmail(params),
|
|
194
|
+
backends: ['graph'],
|
|
195
|
+
handler: (ctx, params) => requireGraphToolset(ctx, 'mailGraph').getEmail(params),
|
|
436
196
|
}),
|
|
437
197
|
defineTool({
|
|
438
198
|
name: 'get_emails',
|
|
@@ -441,10 +201,8 @@ export function mailToolDefinitions() {
|
|
|
441
201
|
annotations: { readOnlyHint: true },
|
|
442
202
|
destructive: false,
|
|
443
203
|
presets: ['mail'],
|
|
444
|
-
backends: ['graph'
|
|
445
|
-
handler: (ctx, params) => ctx
|
|
446
|
-
? requireGraphToolset(ctx, 'mailGraph').getEmails(params)
|
|
447
|
-
: requireAppleScriptToolset(ctx, 'mail').getEmails(params),
|
|
204
|
+
backends: ['graph'],
|
|
205
|
+
handler: (ctx, params) => requireGraphToolset(ctx, 'mailGraph').getEmails(params),
|
|
448
206
|
}),
|
|
449
207
|
defineTool({
|
|
450
208
|
name: 'get_unread_count',
|
|
@@ -453,10 +211,8 @@ export function mailToolDefinitions() {
|
|
|
453
211
|
annotations: { readOnlyHint: true },
|
|
454
212
|
destructive: false,
|
|
455
213
|
presets: ['mail'],
|
|
456
|
-
backends: ['graph'
|
|
457
|
-
handler: (ctx, params) => ctx
|
|
458
|
-
? requireGraphToolset(ctx, 'mailGraph').getUnreadCount(params)
|
|
459
|
-
: requireAppleScriptToolset(ctx, 'mail').getUnreadCount(params),
|
|
214
|
+
backends: ['graph'],
|
|
215
|
+
handler: (ctx, params) => requireGraphToolset(ctx, 'mailGraph').getUnreadCount(params),
|
|
460
216
|
}),
|
|
461
217
|
defineTool({
|
|
462
218
|
name: 'list_attachments',
|
|
@@ -465,10 +221,8 @@ export function mailToolDefinitions() {
|
|
|
465
221
|
annotations: { readOnlyHint: true },
|
|
466
222
|
destructive: false,
|
|
467
223
|
presets: ['mail'],
|
|
468
|
-
backends: ['graph'
|
|
469
|
-
handler: (ctx, params) => ctx
|
|
470
|
-
? requireGraphToolset(ctx, 'mailGraph').listAttachments(params)
|
|
471
|
-
: requireAppleScriptToolset(ctx, 'mail').listAttachments(params),
|
|
224
|
+
backends: ['graph'],
|
|
225
|
+
handler: (ctx, params) => requireGraphToolset(ctx, 'mailGraph').listAttachments(params),
|
|
472
226
|
}),
|
|
473
227
|
defineTool({
|
|
474
228
|
name: 'download_attachment',
|
|
@@ -477,10 +231,8 @@ export function mailToolDefinitions() {
|
|
|
477
231
|
annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: true },
|
|
478
232
|
destructive: false,
|
|
479
233
|
presets: ['mail'],
|
|
480
|
-
backends: ['graph'
|
|
481
|
-
handler: (ctx, params) => ctx
|
|
482
|
-
? requireGraphToolset(ctx, 'mailGraph').downloadAttachment(params)
|
|
483
|
-
: requireAppleScriptToolset(ctx, 'mail').downloadAttachment(params),
|
|
234
|
+
backends: ['graph'],
|
|
235
|
+
handler: (ctx, params) => requireGraphToolset(ctx, 'mailGraph').downloadAttachment(params),
|
|
484
236
|
}),
|
|
485
237
|
// ---- Graph-only reads ----
|
|
486
238
|
defineTool({
|