google-tools-mcp 1.0.0 → 1.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/LICENSE +21 -0
- package/README.md +237 -0
- package/dist/auth.js +2 -0
- package/dist/clients.js +16 -0
- package/dist/tools/calendar/getBusy.js +64 -0
- package/dist/tools/calendar/getEvents.js +140 -0
- package/dist/tools/calendar/getFree.js +225 -0
- package/dist/tools/calendar/index.js +19 -0
- package/dist/tools/calendar/listCalendars.js +38 -0
- package/dist/tools/calendar/listRecurringInstances.js +81 -0
- package/dist/tools/calendar/manageCalendar.js +121 -0
- package/dist/tools/calendar/manageEvent.js +250 -0
- package/dist/tools/calendar/moveEvent.js +60 -0
- package/dist/tools/drafts.js +165 -0
- package/dist/tools/gmail/drafts.js +165 -165
- package/dist/tools/gmail/labels.js +103 -103
- package/dist/tools/gmail/messages.js +448 -448
- package/dist/tools/gmail/settings.js +528 -528
- package/dist/tools/gmail/threads.js +145 -145
- package/dist/tools/index.js +8 -0
- package/dist/tools/labels.js +103 -0
- package/dist/tools/messages.js +448 -0
- package/dist/tools/settings.js +528 -0
- package/dist/tools/threads.js +145 -0
- package/package.json +1 -1
|
@@ -1,528 +1,528 @@
|
|
|
1
|
-
// Gmail Settings tools (settings, delegates, filters, forwarding, send-as, S/MIME)
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
import { getGmailClient } from '../../clients.js';
|
|
4
|
-
|
|
5
|
-
export function register(server) {
|
|
6
|
-
// --- Core Settings ---
|
|
7
|
-
|
|
8
|
-
server.addTool({
|
|
9
|
-
name: 'get_auto_forwarding',
|
|
10
|
-
description: 'Gets auto-forwarding settings',
|
|
11
|
-
parameters: z.object({}),
|
|
12
|
-
execute: async () => {
|
|
13
|
-
const gmail = await getGmailClient();
|
|
14
|
-
const { data } = await gmail.users.settings.getAutoForwarding({ userId: 'me' });
|
|
15
|
-
return JSON.stringify(data);
|
|
16
|
-
},
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
server.addTool({
|
|
20
|
-
name: 'update_auto_forwarding',
|
|
21
|
-
description: 'Updates automatic forwarding settings',
|
|
22
|
-
parameters: z.object({
|
|
23
|
-
enabled: z.boolean().describe("Whether all incoming mail is automatically forwarded"),
|
|
24
|
-
emailAddress: z.string().describe("Email address to forward to"),
|
|
25
|
-
disposition: z.enum(['leaveInInbox', 'archive', 'trash', 'markRead']).describe("What to do with forwarded messages"),
|
|
26
|
-
}),
|
|
27
|
-
execute: async (params) => {
|
|
28
|
-
const gmail = await getGmailClient();
|
|
29
|
-
const { data } = await gmail.users.settings.updateAutoForwarding({ userId: 'me', requestBody: params });
|
|
30
|
-
return JSON.stringify(data);
|
|
31
|
-
},
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
server.addTool({
|
|
35
|
-
name: 'get_imap',
|
|
36
|
-
description: 'Gets IMAP settings',
|
|
37
|
-
parameters: z.object({}),
|
|
38
|
-
execute: async () => {
|
|
39
|
-
const gmail = await getGmailClient();
|
|
40
|
-
const { data } = await gmail.users.settings.getImap({ userId: 'me' });
|
|
41
|
-
return JSON.stringify(data);
|
|
42
|
-
},
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
server.addTool({
|
|
46
|
-
name: 'update_imap',
|
|
47
|
-
description: 'Updates IMAP settings',
|
|
48
|
-
parameters: z.object({
|
|
49
|
-
enabled: z.boolean().describe("Whether IMAP is enabled"),
|
|
50
|
-
expungeBehavior: z.enum(['archive', 'trash', 'deleteForever']).optional().describe("Action on deleted+expunged messages"),
|
|
51
|
-
maxFolderSize: z.number().optional().describe("Max messages accessible through IMAP"),
|
|
52
|
-
}),
|
|
53
|
-
execute: async (params) => {
|
|
54
|
-
const gmail = await getGmailClient();
|
|
55
|
-
const { data } = await gmail.users.settings.updateImap({ userId: 'me', requestBody: params });
|
|
56
|
-
return JSON.stringify(data);
|
|
57
|
-
},
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
server.addTool({
|
|
61
|
-
name: 'get_language',
|
|
62
|
-
description: 'Gets language settings',
|
|
63
|
-
parameters: z.object({}),
|
|
64
|
-
execute: async () => {
|
|
65
|
-
const gmail = await getGmailClient();
|
|
66
|
-
const { data } = await gmail.users.settings.getLanguage({ userId: 'me' });
|
|
67
|
-
return JSON.stringify(data);
|
|
68
|
-
},
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
server.addTool({
|
|
72
|
-
name: 'update_language',
|
|
73
|
-
description: 'Updates language settings',
|
|
74
|
-
parameters: z.object({
|
|
75
|
-
displayLanguage: z.string().describe("Language to display Gmail in (RFC 3066 Language Tag)"),
|
|
76
|
-
}),
|
|
77
|
-
execute: async (params) => {
|
|
78
|
-
const gmail = await getGmailClient();
|
|
79
|
-
const { data } = await gmail.users.settings.updateLanguage({ userId: 'me', requestBody: params });
|
|
80
|
-
return JSON.stringify(data);
|
|
81
|
-
},
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
server.addTool({
|
|
85
|
-
name: 'get_pop',
|
|
86
|
-
description: 'Gets POP settings',
|
|
87
|
-
parameters: z.object({}),
|
|
88
|
-
execute: async () => {
|
|
89
|
-
const gmail = await getGmailClient();
|
|
90
|
-
const { data } = await gmail.users.settings.getPop({ userId: 'me' });
|
|
91
|
-
return JSON.stringify(data);
|
|
92
|
-
},
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
server.addTool({
|
|
96
|
-
name: 'update_pop',
|
|
97
|
-
description: 'Updates POP settings',
|
|
98
|
-
parameters: z.object({
|
|
99
|
-
accessWindow: z.enum(['disabled', 'allMail', 'fromNowOn']).describe("Range of messages accessible via POP"),
|
|
100
|
-
disposition: z.enum(['archive', 'trash', 'leaveInInbox']).describe("Action after POP fetch"),
|
|
101
|
-
}),
|
|
102
|
-
execute: async (params) => {
|
|
103
|
-
const gmail = await getGmailClient();
|
|
104
|
-
const { data } = await gmail.users.settings.updatePop({ userId: 'me', requestBody: params });
|
|
105
|
-
return JSON.stringify(data);
|
|
106
|
-
},
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
server.addTool({
|
|
110
|
-
name: 'get_vacation',
|
|
111
|
-
description: 'Get vacation responder settings',
|
|
112
|
-
parameters: z.object({}),
|
|
113
|
-
execute: async () => {
|
|
114
|
-
const gmail = await getGmailClient();
|
|
115
|
-
const { data } = await gmail.users.settings.getVacation({ userId: 'me' });
|
|
116
|
-
return JSON.stringify(data);
|
|
117
|
-
},
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
server.addTool({
|
|
121
|
-
name: 'update_vacation',
|
|
122
|
-
description: 'Update vacation responder settings',
|
|
123
|
-
parameters: z.object({
|
|
124
|
-
enableAutoReply: z.boolean().describe("Whether the vacation responder is enabled"),
|
|
125
|
-
responseSubject: z.string().optional().describe("Subject line for auto-reply"),
|
|
126
|
-
responseBodyPlainText: z.string().describe("Response body in plain text"),
|
|
127
|
-
restrictToContacts: z.boolean().optional().describe("Only send to contacts"),
|
|
128
|
-
restrictToDomain: z.boolean().optional().describe("Only send to same domain"),
|
|
129
|
-
startTime: z.string().optional().describe("Start time (epoch ms)"),
|
|
130
|
-
endTime: z.string().optional().describe("End time (epoch ms)"),
|
|
131
|
-
}),
|
|
132
|
-
execute: async (params) => {
|
|
133
|
-
const gmail = await getGmailClient();
|
|
134
|
-
const { data } = await gmail.users.settings.updateVacation({ userId: 'me', requestBody: params });
|
|
135
|
-
return JSON.stringify(data);
|
|
136
|
-
},
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
// --- Delegates ---
|
|
140
|
-
|
|
141
|
-
server.addTool({
|
|
142
|
-
name: 'add_delegate',
|
|
143
|
-
description: 'Adds a delegate to the specified account',
|
|
144
|
-
parameters: z.object({
|
|
145
|
-
delegateEmail: z.string().describe("Email address of delegate to add"),
|
|
146
|
-
}),
|
|
147
|
-
execute: async (params) => {
|
|
148
|
-
const gmail = await getGmailClient();
|
|
149
|
-
const { data } = await gmail.users.settings.delegates.create({ userId: 'me', requestBody: { delegateEmail: params.delegateEmail } });
|
|
150
|
-
return JSON.stringify(data);
|
|
151
|
-
},
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
server.addTool({
|
|
155
|
-
name: 'remove_delegate',
|
|
156
|
-
description: 'Removes the specified delegate',
|
|
157
|
-
parameters: z.object({
|
|
158
|
-
delegateEmail: z.string().describe("Email address of delegate to remove"),
|
|
159
|
-
}),
|
|
160
|
-
execute: async (params) => {
|
|
161
|
-
const gmail = await getGmailClient();
|
|
162
|
-
const { data } = await gmail.users.settings.delegates.delete({ userId: 'me', delegateEmail: params.delegateEmail });
|
|
163
|
-
return JSON.stringify(data || { success: true });
|
|
164
|
-
},
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
server.addTool({
|
|
168
|
-
name: 'get_delegate',
|
|
169
|
-
description: 'Gets the specified delegate',
|
|
170
|
-
parameters: z.object({
|
|
171
|
-
delegateEmail: z.string().describe("The email address of the delegate"),
|
|
172
|
-
}),
|
|
173
|
-
execute: async (params) => {
|
|
174
|
-
const gmail = await getGmailClient();
|
|
175
|
-
const { data } = await gmail.users.settings.delegates.get({ userId: 'me', delegateEmail: params.delegateEmail });
|
|
176
|
-
return JSON.stringify(data);
|
|
177
|
-
},
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
server.addTool({
|
|
181
|
-
name: 'list_delegates',
|
|
182
|
-
description: 'Lists the delegates for the specified account',
|
|
183
|
-
parameters: z.object({}),
|
|
184
|
-
execute: async () => {
|
|
185
|
-
const gmail = await getGmailClient();
|
|
186
|
-
const { data } = await gmail.users.settings.delegates.list({ userId: 'me' });
|
|
187
|
-
return JSON.stringify(data);
|
|
188
|
-
},
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
// --- Filters ---
|
|
192
|
-
|
|
193
|
-
server.addTool({
|
|
194
|
-
name: 'create_filter',
|
|
195
|
-
description: 'Creates a filter',
|
|
196
|
-
parameters: z.object({
|
|
197
|
-
criteria: z.object({
|
|
198
|
-
from: z.string().optional().describe("Sender's display name or email"),
|
|
199
|
-
to: z.string().optional().describe("Recipient's display name or email"),
|
|
200
|
-
subject: z.string().optional().describe("Case-insensitive phrase in subject"),
|
|
201
|
-
query: z.string().optional().describe("Gmail search query for filter criteria"),
|
|
202
|
-
negatedQuery: z.string().optional().describe("Query for criteria the message must NOT match"),
|
|
203
|
-
hasAttachment: z.boolean().optional().describe("Whether the message has any attachment"),
|
|
204
|
-
excludeChats: z.boolean().optional().describe("Exclude chats from results"),
|
|
205
|
-
size: z.number().optional().describe("Size of RFC822 message in bytes"),
|
|
206
|
-
sizeComparison: z.enum(['smaller', 'larger']).optional().describe("Size comparison operator"),
|
|
207
|
-
}).describe("Filter criteria"),
|
|
208
|
-
action: z.object({
|
|
209
|
-
addLabelIds: z.array(z.string()).optional().describe("Labels to add"),
|
|
210
|
-
removeLabelIds: z.array(z.string()).optional().describe("Labels to remove"),
|
|
211
|
-
forward: z.string().optional().describe("Email to forward to"),
|
|
212
|
-
}).describe("Actions on matching messages"),
|
|
213
|
-
}),
|
|
214
|
-
execute: async (params) => {
|
|
215
|
-
const gmail = await getGmailClient();
|
|
216
|
-
const { data } = await gmail.users.settings.filters.create({ userId: 'me', requestBody: params });
|
|
217
|
-
return JSON.stringify(data);
|
|
218
|
-
},
|
|
219
|
-
});
|
|
220
|
-
|
|
221
|
-
server.addTool({
|
|
222
|
-
name: 'delete_filter',
|
|
223
|
-
description: 'Deletes a filter',
|
|
224
|
-
parameters: z.object({
|
|
225
|
-
id: z.string().describe("The ID of the filter to delete"),
|
|
226
|
-
}),
|
|
227
|
-
execute: async (params) => {
|
|
228
|
-
const gmail = await getGmailClient();
|
|
229
|
-
const { data } = await gmail.users.settings.filters.delete({ userId: 'me', id: params.id });
|
|
230
|
-
return JSON.stringify(data || { success: true });
|
|
231
|
-
},
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
server.addTool({
|
|
235
|
-
name: 'get_filter',
|
|
236
|
-
description: 'Gets a filter',
|
|
237
|
-
parameters: z.object({
|
|
238
|
-
id: z.string().describe("The ID of the filter to retrieve"),
|
|
239
|
-
}),
|
|
240
|
-
execute: async (params) => {
|
|
241
|
-
const gmail = await getGmailClient();
|
|
242
|
-
const { data } = await gmail.users.settings.filters.get({ userId: 'me', id: params.id });
|
|
243
|
-
return JSON.stringify(data);
|
|
244
|
-
},
|
|
245
|
-
});
|
|
246
|
-
|
|
247
|
-
server.addTool({
|
|
248
|
-
name: 'list_filters',
|
|
249
|
-
description: 'Lists the message filters of a Gmail user',
|
|
250
|
-
parameters: z.object({}),
|
|
251
|
-
execute: async () => {
|
|
252
|
-
const gmail = await getGmailClient();
|
|
253
|
-
const { data } = await gmail.users.settings.filters.list({ userId: 'me' });
|
|
254
|
-
return JSON.stringify(data);
|
|
255
|
-
},
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
// --- Forwarding Addresses ---
|
|
259
|
-
|
|
260
|
-
server.addTool({
|
|
261
|
-
name: 'create_forwarding_address',
|
|
262
|
-
description: 'Creates a forwarding address',
|
|
263
|
-
parameters: z.object({
|
|
264
|
-
forwardingEmail: z.string().describe("An email address to forward messages to"),
|
|
265
|
-
}),
|
|
266
|
-
execute: async (params) => {
|
|
267
|
-
const gmail = await getGmailClient();
|
|
268
|
-
const { data } = await gmail.users.settings.forwardingAddresses.create({ userId: 'me', requestBody: params });
|
|
269
|
-
return JSON.stringify(data);
|
|
270
|
-
},
|
|
271
|
-
});
|
|
272
|
-
|
|
273
|
-
server.addTool({
|
|
274
|
-
name: 'delete_forwarding_address',
|
|
275
|
-
description: 'Deletes the specified forwarding address',
|
|
276
|
-
parameters: z.object({
|
|
277
|
-
forwardingEmail: z.string().describe("The forwarding address to delete"),
|
|
278
|
-
}),
|
|
279
|
-
execute: async (params) => {
|
|
280
|
-
const gmail = await getGmailClient();
|
|
281
|
-
const { data } = await gmail.users.settings.forwardingAddresses.delete({ userId: 'me', forwardingEmail: params.forwardingEmail });
|
|
282
|
-
return JSON.stringify(data || { success: true });
|
|
283
|
-
},
|
|
284
|
-
});
|
|
285
|
-
|
|
286
|
-
server.addTool({
|
|
287
|
-
name: 'get_forwarding_address',
|
|
288
|
-
description: 'Gets the specified forwarding address',
|
|
289
|
-
parameters: z.object({
|
|
290
|
-
forwardingEmail: z.string().describe("The forwarding address to retrieve"),
|
|
291
|
-
}),
|
|
292
|
-
execute: async (params) => {
|
|
293
|
-
const gmail = await getGmailClient();
|
|
294
|
-
const { data } = await gmail.users.settings.forwardingAddresses.get({ userId: 'me', forwardingEmail: params.forwardingEmail });
|
|
295
|
-
return JSON.stringify(data);
|
|
296
|
-
},
|
|
297
|
-
});
|
|
298
|
-
|
|
299
|
-
server.addTool({
|
|
300
|
-
name: 'list_forwarding_addresses',
|
|
301
|
-
description: 'Lists the forwarding addresses for the specified account',
|
|
302
|
-
parameters: z.object({}),
|
|
303
|
-
execute: async () => {
|
|
304
|
-
const gmail = await getGmailClient();
|
|
305
|
-
const { data } = await gmail.users.settings.forwardingAddresses.list({ userId: 'me' });
|
|
306
|
-
return JSON.stringify(data);
|
|
307
|
-
},
|
|
308
|
-
});
|
|
309
|
-
|
|
310
|
-
// --- Send-As Aliases ---
|
|
311
|
-
|
|
312
|
-
server.addTool({
|
|
313
|
-
name: 'create_send_as',
|
|
314
|
-
description: 'Creates a custom send-as alias',
|
|
315
|
-
parameters: z.object({
|
|
316
|
-
sendAsEmail: z.string().describe("Email address for the 'From:' header"),
|
|
317
|
-
displayName: z.string().optional().describe("Name for the 'From:' header"),
|
|
318
|
-
replyToAddress: z.string().optional().describe("Email for 'Reply-To:' header"),
|
|
319
|
-
signature: z.string().optional().describe("Optional HTML signature"),
|
|
320
|
-
isPrimary: z.boolean().optional().describe("Whether this is the primary address"),
|
|
321
|
-
treatAsAlias: z.boolean().optional().describe("Whether Gmail treats this as an alias"),
|
|
322
|
-
}),
|
|
323
|
-
execute: async (params) => {
|
|
324
|
-
const gmail = await getGmailClient();
|
|
325
|
-
const { data } = await gmail.users.settings.sendAs.create({ userId: 'me', requestBody: params });
|
|
326
|
-
return JSON.stringify(data);
|
|
327
|
-
},
|
|
328
|
-
});
|
|
329
|
-
|
|
330
|
-
server.addTool({
|
|
331
|
-
name: 'delete_send_as',
|
|
332
|
-
description: 'Deletes the specified send-as alias',
|
|
333
|
-
parameters: z.object({
|
|
334
|
-
sendAsEmail: z.string().describe("The send-as alias to delete"),
|
|
335
|
-
}),
|
|
336
|
-
execute: async (params) => {
|
|
337
|
-
const gmail = await getGmailClient();
|
|
338
|
-
const { data } = await gmail.users.settings.sendAs.delete({ userId: 'me', sendAsEmail: params.sendAsEmail });
|
|
339
|
-
return JSON.stringify(data || { success: true });
|
|
340
|
-
},
|
|
341
|
-
});
|
|
342
|
-
|
|
343
|
-
server.addTool({
|
|
344
|
-
name: 'get_send_as',
|
|
345
|
-
description: 'Gets the specified send-as alias',
|
|
346
|
-
parameters: z.object({
|
|
347
|
-
sendAsEmail: z.string().describe("The send-as alias to retrieve"),
|
|
348
|
-
}),
|
|
349
|
-
execute: async (params) => {
|
|
350
|
-
const gmail = await getGmailClient();
|
|
351
|
-
const { data } = await gmail.users.settings.sendAs.get({ userId: 'me', sendAsEmail: params.sendAsEmail });
|
|
352
|
-
return JSON.stringify(data);
|
|
353
|
-
},
|
|
354
|
-
});
|
|
355
|
-
|
|
356
|
-
server.addTool({
|
|
357
|
-
name: 'list_send_as',
|
|
358
|
-
description: 'Lists the send-as aliases for the specified account',
|
|
359
|
-
parameters: z.object({}),
|
|
360
|
-
execute: async () => {
|
|
361
|
-
const gmail = await getGmailClient();
|
|
362
|
-
const { data } = await gmail.users.settings.sendAs.list({ userId: 'me' });
|
|
363
|
-
return JSON.stringify(data);
|
|
364
|
-
},
|
|
365
|
-
});
|
|
366
|
-
|
|
367
|
-
server.addTool({
|
|
368
|
-
name: 'patch_send_as',
|
|
369
|
-
description: 'Patches the specified send-as alias',
|
|
370
|
-
parameters: z.object({
|
|
371
|
-
sendAsEmail: z.string().describe("The send-as alias to update"),
|
|
372
|
-
displayName: z.string().optional().describe("Name for the 'From:' header"),
|
|
373
|
-
replyToAddress: z.string().optional().describe("Email for 'Reply-To:' header"),
|
|
374
|
-
signature: z.string().optional().describe("Optional HTML signature"),
|
|
375
|
-
isPrimary: z.boolean().optional().describe("Whether this is the primary address"),
|
|
376
|
-
treatAsAlias: z.boolean().optional().describe("Whether Gmail treats this as an alias"),
|
|
377
|
-
}),
|
|
378
|
-
execute: async (params) => {
|
|
379
|
-
const { sendAsEmail, ...patchData } = params;
|
|
380
|
-
const gmail = await getGmailClient();
|
|
381
|
-
const { data } = await gmail.users.settings.sendAs.patch({ userId: 'me', sendAsEmail, requestBody: patchData });
|
|
382
|
-
return JSON.stringify(data);
|
|
383
|
-
},
|
|
384
|
-
});
|
|
385
|
-
|
|
386
|
-
server.addTool({
|
|
387
|
-
name: 'update_send_as',
|
|
388
|
-
description: 'Updates a send-as alias',
|
|
389
|
-
parameters: z.object({
|
|
390
|
-
sendAsEmail: z.string().describe("The send-as alias to update"),
|
|
391
|
-
displayName: z.string().optional().describe("Name for the 'From:' header"),
|
|
392
|
-
replyToAddress: z.string().optional().describe("Email for 'Reply-To:' header"),
|
|
393
|
-
signature: z.string().optional().describe("Optional HTML signature"),
|
|
394
|
-
isPrimary: z.boolean().optional().describe("Whether this is the primary address"),
|
|
395
|
-
treatAsAlias: z.boolean().optional().describe("Whether Gmail treats this as an alias"),
|
|
396
|
-
}),
|
|
397
|
-
execute: async (params) => {
|
|
398
|
-
const { sendAsEmail, ...updateData } = params;
|
|
399
|
-
const gmail = await getGmailClient();
|
|
400
|
-
const { data } = await gmail.users.settings.sendAs.update({ userId: 'me', sendAsEmail, requestBody: updateData });
|
|
401
|
-
return JSON.stringify(data);
|
|
402
|
-
},
|
|
403
|
-
});
|
|
404
|
-
|
|
405
|
-
server.addTool({
|
|
406
|
-
name: 'verify_send_as',
|
|
407
|
-
description: 'Sends a verification email to the specified send-as alias',
|
|
408
|
-
parameters: z.object({
|
|
409
|
-
sendAsEmail: z.string().describe("The send-as alias to verify"),
|
|
410
|
-
}),
|
|
411
|
-
execute: async (params) => {
|
|
412
|
-
const gmail = await getGmailClient();
|
|
413
|
-
const { data } = await gmail.users.settings.sendAs.verify({ userId: 'me', sendAsEmail: params.sendAsEmail });
|
|
414
|
-
return JSON.stringify(data || { success: true });
|
|
415
|
-
},
|
|
416
|
-
});
|
|
417
|
-
|
|
418
|
-
// --- S/MIME ---
|
|
419
|
-
|
|
420
|
-
server.addTool({
|
|
421
|
-
name: 'delete_smime_info',
|
|
422
|
-
description: 'Deletes the specified S/MIME config for a send-as alias',
|
|
423
|
-
parameters: z.object({
|
|
424
|
-
sendAsEmail: z.string().describe("The email address in the 'From:' header"),
|
|
425
|
-
id: z.string().describe("The S/MIME config ID"),
|
|
426
|
-
}),
|
|
427
|
-
execute: async (params) => {
|
|
428
|
-
const gmail = await getGmailClient();
|
|
429
|
-
const { data } = await gmail.users.settings.sendAs.smimeInfo.delete({ userId: 'me', sendAsEmail: params.sendAsEmail, id: params.id });
|
|
430
|
-
return JSON.stringify(data || { success: true });
|
|
431
|
-
},
|
|
432
|
-
});
|
|
433
|
-
|
|
434
|
-
server.addTool({
|
|
435
|
-
name: 'get_smime_info',
|
|
436
|
-
description: 'Gets the specified S/MIME config for a send-as alias',
|
|
437
|
-
parameters: z.object({
|
|
438
|
-
sendAsEmail: z.string().describe("The email address in the 'From:' header"),
|
|
439
|
-
id: z.string().describe("The S/MIME config ID"),
|
|
440
|
-
}),
|
|
441
|
-
execute: async (params) => {
|
|
442
|
-
const gmail = await getGmailClient();
|
|
443
|
-
const { data } = await gmail.users.settings.sendAs.smimeInfo.get({ userId: 'me', sendAsEmail: params.sendAsEmail, id: params.id });
|
|
444
|
-
return JSON.stringify(data);
|
|
445
|
-
},
|
|
446
|
-
});
|
|
447
|
-
|
|
448
|
-
server.addTool({
|
|
449
|
-
name: 'insert_smime_info',
|
|
450
|
-
description: 'Insert (upload) S/MIME config for a send-as alias',
|
|
451
|
-
parameters: z.object({
|
|
452
|
-
sendAsEmail: z.string().describe("The email address in the 'From:' header"),
|
|
453
|
-
encryptedKeyPassword: z.string().describe("Encrypted key password"),
|
|
454
|
-
pkcs12: z.string().describe("PKCS#12 format key pair and certificate chain"),
|
|
455
|
-
}),
|
|
456
|
-
execute: async (params) => {
|
|
457
|
-
const gmail = await getGmailClient();
|
|
458
|
-
const { data } = await gmail.users.settings.sendAs.smimeInfo.insert({ userId: 'me', sendAsEmail: params.sendAsEmail, requestBody: params });
|
|
459
|
-
return JSON.stringify(data);
|
|
460
|
-
},
|
|
461
|
-
});
|
|
462
|
-
|
|
463
|
-
server.addTool({
|
|
464
|
-
name: 'list_smime_info',
|
|
465
|
-
description: 'Lists S/MIME configs for a send-as alias',
|
|
466
|
-
parameters: z.object({
|
|
467
|
-
sendAsEmail: z.string().describe("The email address in the 'From:' header"),
|
|
468
|
-
}),
|
|
469
|
-
execute: async (params) => {
|
|
470
|
-
const gmail = await getGmailClient();
|
|
471
|
-
const { data } = await gmail.users.settings.sendAs.smimeInfo.list({ userId: 'me', sendAsEmail: params.sendAsEmail });
|
|
472
|
-
return JSON.stringify(data);
|
|
473
|
-
},
|
|
474
|
-
});
|
|
475
|
-
|
|
476
|
-
server.addTool({
|
|
477
|
-
name: 'set_default_smime_info',
|
|
478
|
-
description: 'Sets the default S/MIME config for a send-as alias',
|
|
479
|
-
parameters: z.object({
|
|
480
|
-
sendAsEmail: z.string().describe("The email address in the 'From:' header"),
|
|
481
|
-
id: z.string().describe("The S/MIME config ID"),
|
|
482
|
-
}),
|
|
483
|
-
execute: async (params) => {
|
|
484
|
-
const gmail = await getGmailClient();
|
|
485
|
-
const { data } = await gmail.users.settings.sendAs.smimeInfo.setDefault({ userId: 'me', sendAsEmail: params.sendAsEmail, id: params.id });
|
|
486
|
-
return JSON.stringify(data || { success: true });
|
|
487
|
-
},
|
|
488
|
-
});
|
|
489
|
-
|
|
490
|
-
// --- Profile & Watch ---
|
|
491
|
-
|
|
492
|
-
server.addTool({
|
|
493
|
-
name: 'get_profile',
|
|
494
|
-
description: 'Get the current user\'s Gmail profile',
|
|
495
|
-
parameters: z.object({}),
|
|
496
|
-
execute: async () => {
|
|
497
|
-
const gmail = await getGmailClient();
|
|
498
|
-
const { data } = await gmail.users.getProfile({ userId: 'me' });
|
|
499
|
-
return JSON.stringify(data);
|
|
500
|
-
},
|
|
501
|
-
});
|
|
502
|
-
|
|
503
|
-
server.addTool({
|
|
504
|
-
name: 'watch_mailbox',
|
|
505
|
-
description: 'Watch for changes to the user\'s mailbox via Cloud Pub/Sub',
|
|
506
|
-
parameters: z.object({
|
|
507
|
-
topicName: z.string().describe("Cloud Pub/Sub topic to publish notifications to"),
|
|
508
|
-
labelIds: z.array(z.string()).optional().describe("Label IDs to restrict notifications to"),
|
|
509
|
-
labelFilterAction: z.enum(['include', 'exclude']).optional().describe("Whether to include or exclude specified labels"),
|
|
510
|
-
}),
|
|
511
|
-
execute: async (params) => {
|
|
512
|
-
const gmail = await getGmailClient();
|
|
513
|
-
const { data } = await gmail.users.watch({ userId: 'me', requestBody: params });
|
|
514
|
-
return JSON.stringify(data);
|
|
515
|
-
},
|
|
516
|
-
});
|
|
517
|
-
|
|
518
|
-
server.addTool({
|
|
519
|
-
name: 'stop_mail_watch',
|
|
520
|
-
description: 'Stop receiving push notifications for the user\'s mailbox',
|
|
521
|
-
parameters: z.object({}),
|
|
522
|
-
execute: async () => {
|
|
523
|
-
const gmail = await getGmailClient();
|
|
524
|
-
const { data } = await gmail.users.stop({ userId: 'me' });
|
|
525
|
-
return JSON.stringify(data || { success: true });
|
|
526
|
-
},
|
|
527
|
-
});
|
|
528
|
-
}
|
|
1
|
+
// Gmail Settings tools (settings, delegates, filters, forwarding, send-as, S/MIME)
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { getGmailClient } from '../../clients.js';
|
|
4
|
+
|
|
5
|
+
export function register(server) {
|
|
6
|
+
// --- Core Settings ---
|
|
7
|
+
|
|
8
|
+
server.addTool({
|
|
9
|
+
name: 'get_auto_forwarding',
|
|
10
|
+
description: 'Gets auto-forwarding settings',
|
|
11
|
+
parameters: z.object({}),
|
|
12
|
+
execute: async () => {
|
|
13
|
+
const gmail = await getGmailClient();
|
|
14
|
+
const { data } = await gmail.users.settings.getAutoForwarding({ userId: 'me' });
|
|
15
|
+
return JSON.stringify(data);
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
server.addTool({
|
|
20
|
+
name: 'update_auto_forwarding',
|
|
21
|
+
description: 'Updates automatic forwarding settings',
|
|
22
|
+
parameters: z.object({
|
|
23
|
+
enabled: z.boolean().describe("Whether all incoming mail is automatically forwarded"),
|
|
24
|
+
emailAddress: z.string().describe("Email address to forward to"),
|
|
25
|
+
disposition: z.enum(['leaveInInbox', 'archive', 'trash', 'markRead']).describe("What to do with forwarded messages"),
|
|
26
|
+
}),
|
|
27
|
+
execute: async (params) => {
|
|
28
|
+
const gmail = await getGmailClient();
|
|
29
|
+
const { data } = await gmail.users.settings.updateAutoForwarding({ userId: 'me', requestBody: params });
|
|
30
|
+
return JSON.stringify(data);
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
server.addTool({
|
|
35
|
+
name: 'get_imap',
|
|
36
|
+
description: 'Gets IMAP settings',
|
|
37
|
+
parameters: z.object({}),
|
|
38
|
+
execute: async () => {
|
|
39
|
+
const gmail = await getGmailClient();
|
|
40
|
+
const { data } = await gmail.users.settings.getImap({ userId: 'me' });
|
|
41
|
+
return JSON.stringify(data);
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
server.addTool({
|
|
46
|
+
name: 'update_imap',
|
|
47
|
+
description: 'Updates IMAP settings',
|
|
48
|
+
parameters: z.object({
|
|
49
|
+
enabled: z.boolean().describe("Whether IMAP is enabled"),
|
|
50
|
+
expungeBehavior: z.enum(['archive', 'trash', 'deleteForever']).optional().describe("Action on deleted+expunged messages"),
|
|
51
|
+
maxFolderSize: z.number().optional().describe("Max messages accessible through IMAP"),
|
|
52
|
+
}),
|
|
53
|
+
execute: async (params) => {
|
|
54
|
+
const gmail = await getGmailClient();
|
|
55
|
+
const { data } = await gmail.users.settings.updateImap({ userId: 'me', requestBody: params });
|
|
56
|
+
return JSON.stringify(data);
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
server.addTool({
|
|
61
|
+
name: 'get_language',
|
|
62
|
+
description: 'Gets language settings',
|
|
63
|
+
parameters: z.object({}),
|
|
64
|
+
execute: async () => {
|
|
65
|
+
const gmail = await getGmailClient();
|
|
66
|
+
const { data } = await gmail.users.settings.getLanguage({ userId: 'me' });
|
|
67
|
+
return JSON.stringify(data);
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
server.addTool({
|
|
72
|
+
name: 'update_language',
|
|
73
|
+
description: 'Updates language settings',
|
|
74
|
+
parameters: z.object({
|
|
75
|
+
displayLanguage: z.string().describe("Language to display Gmail in (RFC 3066 Language Tag)"),
|
|
76
|
+
}),
|
|
77
|
+
execute: async (params) => {
|
|
78
|
+
const gmail = await getGmailClient();
|
|
79
|
+
const { data } = await gmail.users.settings.updateLanguage({ userId: 'me', requestBody: params });
|
|
80
|
+
return JSON.stringify(data);
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
server.addTool({
|
|
85
|
+
name: 'get_pop',
|
|
86
|
+
description: 'Gets POP settings',
|
|
87
|
+
parameters: z.object({}),
|
|
88
|
+
execute: async () => {
|
|
89
|
+
const gmail = await getGmailClient();
|
|
90
|
+
const { data } = await gmail.users.settings.getPop({ userId: 'me' });
|
|
91
|
+
return JSON.stringify(data);
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
server.addTool({
|
|
96
|
+
name: 'update_pop',
|
|
97
|
+
description: 'Updates POP settings',
|
|
98
|
+
parameters: z.object({
|
|
99
|
+
accessWindow: z.enum(['disabled', 'allMail', 'fromNowOn']).describe("Range of messages accessible via POP"),
|
|
100
|
+
disposition: z.enum(['archive', 'trash', 'leaveInInbox']).describe("Action after POP fetch"),
|
|
101
|
+
}),
|
|
102
|
+
execute: async (params) => {
|
|
103
|
+
const gmail = await getGmailClient();
|
|
104
|
+
const { data } = await gmail.users.settings.updatePop({ userId: 'me', requestBody: params });
|
|
105
|
+
return JSON.stringify(data);
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
server.addTool({
|
|
110
|
+
name: 'get_vacation',
|
|
111
|
+
description: 'Get vacation responder settings',
|
|
112
|
+
parameters: z.object({}),
|
|
113
|
+
execute: async () => {
|
|
114
|
+
const gmail = await getGmailClient();
|
|
115
|
+
const { data } = await gmail.users.settings.getVacation({ userId: 'me' });
|
|
116
|
+
return JSON.stringify(data);
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
server.addTool({
|
|
121
|
+
name: 'update_vacation',
|
|
122
|
+
description: 'Update vacation responder settings',
|
|
123
|
+
parameters: z.object({
|
|
124
|
+
enableAutoReply: z.boolean().describe("Whether the vacation responder is enabled"),
|
|
125
|
+
responseSubject: z.string().optional().describe("Subject line for auto-reply"),
|
|
126
|
+
responseBodyPlainText: z.string().describe("Response body in plain text"),
|
|
127
|
+
restrictToContacts: z.boolean().optional().describe("Only send to contacts"),
|
|
128
|
+
restrictToDomain: z.boolean().optional().describe("Only send to same domain"),
|
|
129
|
+
startTime: z.string().optional().describe("Start time (epoch ms)"),
|
|
130
|
+
endTime: z.string().optional().describe("End time (epoch ms)"),
|
|
131
|
+
}),
|
|
132
|
+
execute: async (params) => {
|
|
133
|
+
const gmail = await getGmailClient();
|
|
134
|
+
const { data } = await gmail.users.settings.updateVacation({ userId: 'me', requestBody: params });
|
|
135
|
+
return JSON.stringify(data);
|
|
136
|
+
},
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
// --- Delegates ---
|
|
140
|
+
|
|
141
|
+
server.addTool({
|
|
142
|
+
name: 'add_delegate',
|
|
143
|
+
description: 'Adds a delegate to the specified account',
|
|
144
|
+
parameters: z.object({
|
|
145
|
+
delegateEmail: z.string().describe("Email address of delegate to add"),
|
|
146
|
+
}),
|
|
147
|
+
execute: async (params) => {
|
|
148
|
+
const gmail = await getGmailClient();
|
|
149
|
+
const { data } = await gmail.users.settings.delegates.create({ userId: 'me', requestBody: { delegateEmail: params.delegateEmail } });
|
|
150
|
+
return JSON.stringify(data);
|
|
151
|
+
},
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
server.addTool({
|
|
155
|
+
name: 'remove_delegate',
|
|
156
|
+
description: 'Removes the specified delegate',
|
|
157
|
+
parameters: z.object({
|
|
158
|
+
delegateEmail: z.string().describe("Email address of delegate to remove"),
|
|
159
|
+
}),
|
|
160
|
+
execute: async (params) => {
|
|
161
|
+
const gmail = await getGmailClient();
|
|
162
|
+
const { data } = await gmail.users.settings.delegates.delete({ userId: 'me', delegateEmail: params.delegateEmail });
|
|
163
|
+
return JSON.stringify(data || { success: true });
|
|
164
|
+
},
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
server.addTool({
|
|
168
|
+
name: 'get_delegate',
|
|
169
|
+
description: 'Gets the specified delegate',
|
|
170
|
+
parameters: z.object({
|
|
171
|
+
delegateEmail: z.string().describe("The email address of the delegate"),
|
|
172
|
+
}),
|
|
173
|
+
execute: async (params) => {
|
|
174
|
+
const gmail = await getGmailClient();
|
|
175
|
+
const { data } = await gmail.users.settings.delegates.get({ userId: 'me', delegateEmail: params.delegateEmail });
|
|
176
|
+
return JSON.stringify(data);
|
|
177
|
+
},
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
server.addTool({
|
|
181
|
+
name: 'list_delegates',
|
|
182
|
+
description: 'Lists the delegates for the specified account',
|
|
183
|
+
parameters: z.object({}),
|
|
184
|
+
execute: async () => {
|
|
185
|
+
const gmail = await getGmailClient();
|
|
186
|
+
const { data } = await gmail.users.settings.delegates.list({ userId: 'me' });
|
|
187
|
+
return JSON.stringify(data);
|
|
188
|
+
},
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
// --- Filters ---
|
|
192
|
+
|
|
193
|
+
server.addTool({
|
|
194
|
+
name: 'create_filter',
|
|
195
|
+
description: 'Creates a filter',
|
|
196
|
+
parameters: z.object({
|
|
197
|
+
criteria: z.object({
|
|
198
|
+
from: z.string().optional().describe("Sender's display name or email"),
|
|
199
|
+
to: z.string().optional().describe("Recipient's display name or email"),
|
|
200
|
+
subject: z.string().optional().describe("Case-insensitive phrase in subject"),
|
|
201
|
+
query: z.string().optional().describe("Gmail search query for filter criteria"),
|
|
202
|
+
negatedQuery: z.string().optional().describe("Query for criteria the message must NOT match"),
|
|
203
|
+
hasAttachment: z.boolean().optional().describe("Whether the message has any attachment"),
|
|
204
|
+
excludeChats: z.boolean().optional().describe("Exclude chats from results"),
|
|
205
|
+
size: z.number().optional().describe("Size of RFC822 message in bytes"),
|
|
206
|
+
sizeComparison: z.enum(['smaller', 'larger']).optional().describe("Size comparison operator"),
|
|
207
|
+
}).describe("Filter criteria"),
|
|
208
|
+
action: z.object({
|
|
209
|
+
addLabelIds: z.array(z.string()).optional().describe("Labels to add"),
|
|
210
|
+
removeLabelIds: z.array(z.string()).optional().describe("Labels to remove"),
|
|
211
|
+
forward: z.string().optional().describe("Email to forward to"),
|
|
212
|
+
}).describe("Actions on matching messages"),
|
|
213
|
+
}),
|
|
214
|
+
execute: async (params) => {
|
|
215
|
+
const gmail = await getGmailClient();
|
|
216
|
+
const { data } = await gmail.users.settings.filters.create({ userId: 'me', requestBody: params });
|
|
217
|
+
return JSON.stringify(data);
|
|
218
|
+
},
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
server.addTool({
|
|
222
|
+
name: 'delete_filter',
|
|
223
|
+
description: 'Deletes a filter',
|
|
224
|
+
parameters: z.object({
|
|
225
|
+
id: z.string().describe("The ID of the filter to delete"),
|
|
226
|
+
}),
|
|
227
|
+
execute: async (params) => {
|
|
228
|
+
const gmail = await getGmailClient();
|
|
229
|
+
const { data } = await gmail.users.settings.filters.delete({ userId: 'me', id: params.id });
|
|
230
|
+
return JSON.stringify(data || { success: true });
|
|
231
|
+
},
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
server.addTool({
|
|
235
|
+
name: 'get_filter',
|
|
236
|
+
description: 'Gets a filter',
|
|
237
|
+
parameters: z.object({
|
|
238
|
+
id: z.string().describe("The ID of the filter to retrieve"),
|
|
239
|
+
}),
|
|
240
|
+
execute: async (params) => {
|
|
241
|
+
const gmail = await getGmailClient();
|
|
242
|
+
const { data } = await gmail.users.settings.filters.get({ userId: 'me', id: params.id });
|
|
243
|
+
return JSON.stringify(data);
|
|
244
|
+
},
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
server.addTool({
|
|
248
|
+
name: 'list_filters',
|
|
249
|
+
description: 'Lists the message filters of a Gmail user',
|
|
250
|
+
parameters: z.object({}),
|
|
251
|
+
execute: async () => {
|
|
252
|
+
const gmail = await getGmailClient();
|
|
253
|
+
const { data } = await gmail.users.settings.filters.list({ userId: 'me' });
|
|
254
|
+
return JSON.stringify(data);
|
|
255
|
+
},
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
// --- Forwarding Addresses ---
|
|
259
|
+
|
|
260
|
+
server.addTool({
|
|
261
|
+
name: 'create_forwarding_address',
|
|
262
|
+
description: 'Creates a forwarding address',
|
|
263
|
+
parameters: z.object({
|
|
264
|
+
forwardingEmail: z.string().describe("An email address to forward messages to"),
|
|
265
|
+
}),
|
|
266
|
+
execute: async (params) => {
|
|
267
|
+
const gmail = await getGmailClient();
|
|
268
|
+
const { data } = await gmail.users.settings.forwardingAddresses.create({ userId: 'me', requestBody: params });
|
|
269
|
+
return JSON.stringify(data);
|
|
270
|
+
},
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
server.addTool({
|
|
274
|
+
name: 'delete_forwarding_address',
|
|
275
|
+
description: 'Deletes the specified forwarding address',
|
|
276
|
+
parameters: z.object({
|
|
277
|
+
forwardingEmail: z.string().describe("The forwarding address to delete"),
|
|
278
|
+
}),
|
|
279
|
+
execute: async (params) => {
|
|
280
|
+
const gmail = await getGmailClient();
|
|
281
|
+
const { data } = await gmail.users.settings.forwardingAddresses.delete({ userId: 'me', forwardingEmail: params.forwardingEmail });
|
|
282
|
+
return JSON.stringify(data || { success: true });
|
|
283
|
+
},
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
server.addTool({
|
|
287
|
+
name: 'get_forwarding_address',
|
|
288
|
+
description: 'Gets the specified forwarding address',
|
|
289
|
+
parameters: z.object({
|
|
290
|
+
forwardingEmail: z.string().describe("The forwarding address to retrieve"),
|
|
291
|
+
}),
|
|
292
|
+
execute: async (params) => {
|
|
293
|
+
const gmail = await getGmailClient();
|
|
294
|
+
const { data } = await gmail.users.settings.forwardingAddresses.get({ userId: 'me', forwardingEmail: params.forwardingEmail });
|
|
295
|
+
return JSON.stringify(data);
|
|
296
|
+
},
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
server.addTool({
|
|
300
|
+
name: 'list_forwarding_addresses',
|
|
301
|
+
description: 'Lists the forwarding addresses for the specified account',
|
|
302
|
+
parameters: z.object({}),
|
|
303
|
+
execute: async () => {
|
|
304
|
+
const gmail = await getGmailClient();
|
|
305
|
+
const { data } = await gmail.users.settings.forwardingAddresses.list({ userId: 'me' });
|
|
306
|
+
return JSON.stringify(data);
|
|
307
|
+
},
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
// --- Send-As Aliases ---
|
|
311
|
+
|
|
312
|
+
server.addTool({
|
|
313
|
+
name: 'create_send_as',
|
|
314
|
+
description: 'Creates a custom send-as alias',
|
|
315
|
+
parameters: z.object({
|
|
316
|
+
sendAsEmail: z.string().describe("Email address for the 'From:' header"),
|
|
317
|
+
displayName: z.string().optional().describe("Name for the 'From:' header"),
|
|
318
|
+
replyToAddress: z.string().optional().describe("Email for 'Reply-To:' header"),
|
|
319
|
+
signature: z.string().optional().describe("Optional HTML signature"),
|
|
320
|
+
isPrimary: z.boolean().optional().describe("Whether this is the primary address"),
|
|
321
|
+
treatAsAlias: z.boolean().optional().describe("Whether Gmail treats this as an alias"),
|
|
322
|
+
}),
|
|
323
|
+
execute: async (params) => {
|
|
324
|
+
const gmail = await getGmailClient();
|
|
325
|
+
const { data } = await gmail.users.settings.sendAs.create({ userId: 'me', requestBody: params });
|
|
326
|
+
return JSON.stringify(data);
|
|
327
|
+
},
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
server.addTool({
|
|
331
|
+
name: 'delete_send_as',
|
|
332
|
+
description: 'Deletes the specified send-as alias',
|
|
333
|
+
parameters: z.object({
|
|
334
|
+
sendAsEmail: z.string().describe("The send-as alias to delete"),
|
|
335
|
+
}),
|
|
336
|
+
execute: async (params) => {
|
|
337
|
+
const gmail = await getGmailClient();
|
|
338
|
+
const { data } = await gmail.users.settings.sendAs.delete({ userId: 'me', sendAsEmail: params.sendAsEmail });
|
|
339
|
+
return JSON.stringify(data || { success: true });
|
|
340
|
+
},
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
server.addTool({
|
|
344
|
+
name: 'get_send_as',
|
|
345
|
+
description: 'Gets the specified send-as alias',
|
|
346
|
+
parameters: z.object({
|
|
347
|
+
sendAsEmail: z.string().describe("The send-as alias to retrieve"),
|
|
348
|
+
}),
|
|
349
|
+
execute: async (params) => {
|
|
350
|
+
const gmail = await getGmailClient();
|
|
351
|
+
const { data } = await gmail.users.settings.sendAs.get({ userId: 'me', sendAsEmail: params.sendAsEmail });
|
|
352
|
+
return JSON.stringify(data);
|
|
353
|
+
},
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
server.addTool({
|
|
357
|
+
name: 'list_send_as',
|
|
358
|
+
description: 'Lists the send-as aliases for the specified account',
|
|
359
|
+
parameters: z.object({}),
|
|
360
|
+
execute: async () => {
|
|
361
|
+
const gmail = await getGmailClient();
|
|
362
|
+
const { data } = await gmail.users.settings.sendAs.list({ userId: 'me' });
|
|
363
|
+
return JSON.stringify(data);
|
|
364
|
+
},
|
|
365
|
+
});
|
|
366
|
+
|
|
367
|
+
server.addTool({
|
|
368
|
+
name: 'patch_send_as',
|
|
369
|
+
description: 'Patches the specified send-as alias',
|
|
370
|
+
parameters: z.object({
|
|
371
|
+
sendAsEmail: z.string().describe("The send-as alias to update"),
|
|
372
|
+
displayName: z.string().optional().describe("Name for the 'From:' header"),
|
|
373
|
+
replyToAddress: z.string().optional().describe("Email for 'Reply-To:' header"),
|
|
374
|
+
signature: z.string().optional().describe("Optional HTML signature"),
|
|
375
|
+
isPrimary: z.boolean().optional().describe("Whether this is the primary address"),
|
|
376
|
+
treatAsAlias: z.boolean().optional().describe("Whether Gmail treats this as an alias"),
|
|
377
|
+
}),
|
|
378
|
+
execute: async (params) => {
|
|
379
|
+
const { sendAsEmail, ...patchData } = params;
|
|
380
|
+
const gmail = await getGmailClient();
|
|
381
|
+
const { data } = await gmail.users.settings.sendAs.patch({ userId: 'me', sendAsEmail, requestBody: patchData });
|
|
382
|
+
return JSON.stringify(data);
|
|
383
|
+
},
|
|
384
|
+
});
|
|
385
|
+
|
|
386
|
+
server.addTool({
|
|
387
|
+
name: 'update_send_as',
|
|
388
|
+
description: 'Updates a send-as alias',
|
|
389
|
+
parameters: z.object({
|
|
390
|
+
sendAsEmail: z.string().describe("The send-as alias to update"),
|
|
391
|
+
displayName: z.string().optional().describe("Name for the 'From:' header"),
|
|
392
|
+
replyToAddress: z.string().optional().describe("Email for 'Reply-To:' header"),
|
|
393
|
+
signature: z.string().optional().describe("Optional HTML signature"),
|
|
394
|
+
isPrimary: z.boolean().optional().describe("Whether this is the primary address"),
|
|
395
|
+
treatAsAlias: z.boolean().optional().describe("Whether Gmail treats this as an alias"),
|
|
396
|
+
}),
|
|
397
|
+
execute: async (params) => {
|
|
398
|
+
const { sendAsEmail, ...updateData } = params;
|
|
399
|
+
const gmail = await getGmailClient();
|
|
400
|
+
const { data } = await gmail.users.settings.sendAs.update({ userId: 'me', sendAsEmail, requestBody: updateData });
|
|
401
|
+
return JSON.stringify(data);
|
|
402
|
+
},
|
|
403
|
+
});
|
|
404
|
+
|
|
405
|
+
server.addTool({
|
|
406
|
+
name: 'verify_send_as',
|
|
407
|
+
description: 'Sends a verification email to the specified send-as alias',
|
|
408
|
+
parameters: z.object({
|
|
409
|
+
sendAsEmail: z.string().describe("The send-as alias to verify"),
|
|
410
|
+
}),
|
|
411
|
+
execute: async (params) => {
|
|
412
|
+
const gmail = await getGmailClient();
|
|
413
|
+
const { data } = await gmail.users.settings.sendAs.verify({ userId: 'me', sendAsEmail: params.sendAsEmail });
|
|
414
|
+
return JSON.stringify(data || { success: true });
|
|
415
|
+
},
|
|
416
|
+
});
|
|
417
|
+
|
|
418
|
+
// --- S/MIME ---
|
|
419
|
+
|
|
420
|
+
server.addTool({
|
|
421
|
+
name: 'delete_smime_info',
|
|
422
|
+
description: 'Deletes the specified S/MIME config for a send-as alias',
|
|
423
|
+
parameters: z.object({
|
|
424
|
+
sendAsEmail: z.string().describe("The email address in the 'From:' header"),
|
|
425
|
+
id: z.string().describe("The S/MIME config ID"),
|
|
426
|
+
}),
|
|
427
|
+
execute: async (params) => {
|
|
428
|
+
const gmail = await getGmailClient();
|
|
429
|
+
const { data } = await gmail.users.settings.sendAs.smimeInfo.delete({ userId: 'me', sendAsEmail: params.sendAsEmail, id: params.id });
|
|
430
|
+
return JSON.stringify(data || { success: true });
|
|
431
|
+
},
|
|
432
|
+
});
|
|
433
|
+
|
|
434
|
+
server.addTool({
|
|
435
|
+
name: 'get_smime_info',
|
|
436
|
+
description: 'Gets the specified S/MIME config for a send-as alias',
|
|
437
|
+
parameters: z.object({
|
|
438
|
+
sendAsEmail: z.string().describe("The email address in the 'From:' header"),
|
|
439
|
+
id: z.string().describe("The S/MIME config ID"),
|
|
440
|
+
}),
|
|
441
|
+
execute: async (params) => {
|
|
442
|
+
const gmail = await getGmailClient();
|
|
443
|
+
const { data } = await gmail.users.settings.sendAs.smimeInfo.get({ userId: 'me', sendAsEmail: params.sendAsEmail, id: params.id });
|
|
444
|
+
return JSON.stringify(data);
|
|
445
|
+
},
|
|
446
|
+
});
|
|
447
|
+
|
|
448
|
+
server.addTool({
|
|
449
|
+
name: 'insert_smime_info',
|
|
450
|
+
description: 'Insert (upload) S/MIME config for a send-as alias',
|
|
451
|
+
parameters: z.object({
|
|
452
|
+
sendAsEmail: z.string().describe("The email address in the 'From:' header"),
|
|
453
|
+
encryptedKeyPassword: z.string().describe("Encrypted key password"),
|
|
454
|
+
pkcs12: z.string().describe("PKCS#12 format key pair and certificate chain"),
|
|
455
|
+
}),
|
|
456
|
+
execute: async (params) => {
|
|
457
|
+
const gmail = await getGmailClient();
|
|
458
|
+
const { data } = await gmail.users.settings.sendAs.smimeInfo.insert({ userId: 'me', sendAsEmail: params.sendAsEmail, requestBody: params });
|
|
459
|
+
return JSON.stringify(data);
|
|
460
|
+
},
|
|
461
|
+
});
|
|
462
|
+
|
|
463
|
+
server.addTool({
|
|
464
|
+
name: 'list_smime_info',
|
|
465
|
+
description: 'Lists S/MIME configs for a send-as alias',
|
|
466
|
+
parameters: z.object({
|
|
467
|
+
sendAsEmail: z.string().describe("The email address in the 'From:' header"),
|
|
468
|
+
}),
|
|
469
|
+
execute: async (params) => {
|
|
470
|
+
const gmail = await getGmailClient();
|
|
471
|
+
const { data } = await gmail.users.settings.sendAs.smimeInfo.list({ userId: 'me', sendAsEmail: params.sendAsEmail });
|
|
472
|
+
return JSON.stringify(data);
|
|
473
|
+
},
|
|
474
|
+
});
|
|
475
|
+
|
|
476
|
+
server.addTool({
|
|
477
|
+
name: 'set_default_smime_info',
|
|
478
|
+
description: 'Sets the default S/MIME config for a send-as alias',
|
|
479
|
+
parameters: z.object({
|
|
480
|
+
sendAsEmail: z.string().describe("The email address in the 'From:' header"),
|
|
481
|
+
id: z.string().describe("The S/MIME config ID"),
|
|
482
|
+
}),
|
|
483
|
+
execute: async (params) => {
|
|
484
|
+
const gmail = await getGmailClient();
|
|
485
|
+
const { data } = await gmail.users.settings.sendAs.smimeInfo.setDefault({ userId: 'me', sendAsEmail: params.sendAsEmail, id: params.id });
|
|
486
|
+
return JSON.stringify(data || { success: true });
|
|
487
|
+
},
|
|
488
|
+
});
|
|
489
|
+
|
|
490
|
+
// --- Profile & Watch ---
|
|
491
|
+
|
|
492
|
+
server.addTool({
|
|
493
|
+
name: 'get_profile',
|
|
494
|
+
description: 'Get the current user\'s Gmail profile',
|
|
495
|
+
parameters: z.object({}),
|
|
496
|
+
execute: async () => {
|
|
497
|
+
const gmail = await getGmailClient();
|
|
498
|
+
const { data } = await gmail.users.getProfile({ userId: 'me' });
|
|
499
|
+
return JSON.stringify(data);
|
|
500
|
+
},
|
|
501
|
+
});
|
|
502
|
+
|
|
503
|
+
server.addTool({
|
|
504
|
+
name: 'watch_mailbox',
|
|
505
|
+
description: 'Watch for changes to the user\'s mailbox via Cloud Pub/Sub',
|
|
506
|
+
parameters: z.object({
|
|
507
|
+
topicName: z.string().describe("Cloud Pub/Sub topic to publish notifications to"),
|
|
508
|
+
labelIds: z.array(z.string()).optional().describe("Label IDs to restrict notifications to"),
|
|
509
|
+
labelFilterAction: z.enum(['include', 'exclude']).optional().describe("Whether to include or exclude specified labels"),
|
|
510
|
+
}),
|
|
511
|
+
execute: async (params) => {
|
|
512
|
+
const gmail = await getGmailClient();
|
|
513
|
+
const { data } = await gmail.users.watch({ userId: 'me', requestBody: params });
|
|
514
|
+
return JSON.stringify(data);
|
|
515
|
+
},
|
|
516
|
+
});
|
|
517
|
+
|
|
518
|
+
server.addTool({
|
|
519
|
+
name: 'stop_mail_watch',
|
|
520
|
+
description: 'Stop receiving push notifications for the user\'s mailbox',
|
|
521
|
+
parameters: z.object({}),
|
|
522
|
+
execute: async () => {
|
|
523
|
+
const gmail = await getGmailClient();
|
|
524
|
+
const { data } = await gmail.users.stop({ userId: 'me' });
|
|
525
|
+
return JSON.stringify(data || { success: true });
|
|
526
|
+
},
|
|
527
|
+
});
|
|
528
|
+
}
|