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,145 +1,145 @@
|
|
|
1
|
-
// Gmail Thread tools
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
import { getGmailClient } from '../../clients.js';
|
|
4
|
-
import { processMessagePart } from '../../helpers.js';
|
|
5
|
-
|
|
6
|
-
export function register(server) {
|
|
7
|
-
server.addTool({
|
|
8
|
-
name: 'get_thread',
|
|
9
|
-
description: 'Get a specific thread by ID',
|
|
10
|
-
parameters: z.object({
|
|
11
|
-
id: z.string().describe("The ID of the thread to retrieve"),
|
|
12
|
-
includeBodyHtml: z.boolean().optional().describe("Whether to include the parsed HTML in the return for each body"),
|
|
13
|
-
}),
|
|
14
|
-
execute: async (params) => {
|
|
15
|
-
const gmail = await getGmailClient();
|
|
16
|
-
const { data } = await gmail.users.threads.get({ userId: 'me', id: params.id, format: 'full' });
|
|
17
|
-
if (data.messages) {
|
|
18
|
-
data.messages = data.messages.map(message => {
|
|
19
|
-
if (message.payload) {
|
|
20
|
-
message.payload = processMessagePart(message.payload, params.includeBodyHtml);
|
|
21
|
-
}
|
|
22
|
-
return message;
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
return JSON.stringify(data);
|
|
26
|
-
},
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
server.addTool({
|
|
30
|
-
name: 'list_threads',
|
|
31
|
-
description: 'List threads in the user\'s mailbox',
|
|
32
|
-
parameters: z.object({
|
|
33
|
-
maxResults: z.number().optional().describe("Maximum number of threads to return"),
|
|
34
|
-
pageToken: z.string().optional().describe("Page token to retrieve a specific page of results"),
|
|
35
|
-
q: z.string().optional().describe("Only return threads matching the specified query"),
|
|
36
|
-
labelIds: z.array(z.string()).optional().describe("Only return threads with labels that match all specified label IDs"),
|
|
37
|
-
includeSpamTrash: z.boolean().optional().describe("Include threads from SPAM and TRASH"),
|
|
38
|
-
includeBodyHtml: z.boolean().optional().describe("Whether to include the parsed HTML in the return for each body"),
|
|
39
|
-
}),
|
|
40
|
-
execute: async (params) => {
|
|
41
|
-
const gmail = await getGmailClient();
|
|
42
|
-
const { data } = await gmail.users.threads.list({ userId: 'me', ...params });
|
|
43
|
-
if (data.threads) {
|
|
44
|
-
data.threads = data.threads.map(thread => {
|
|
45
|
-
if (thread.messages) {
|
|
46
|
-
thread.messages = thread.messages.map(message => {
|
|
47
|
-
if (message.payload) {
|
|
48
|
-
message.payload = processMessagePart(message.payload, params.includeBodyHtml);
|
|
49
|
-
}
|
|
50
|
-
return message;
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
return thread;
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
return JSON.stringify(data);
|
|
57
|
-
},
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
server.addTool({
|
|
61
|
-
name: 'batch_get_threads',
|
|
62
|
-
description: 'Get multiple threads by ID in parallel. More efficient than calling get_thread multiple times.',
|
|
63
|
-
parameters: z.object({
|
|
64
|
-
ids: z.array(z.string()).describe("The IDs of the threads to retrieve"),
|
|
65
|
-
includeBodyHtml: z.boolean().optional().describe("Whether to include the parsed HTML in the return for each body"),
|
|
66
|
-
}),
|
|
67
|
-
execute: async (params) => {
|
|
68
|
-
const gmail = await getGmailClient();
|
|
69
|
-
const results = await Promise.all(
|
|
70
|
-
params.ids.map(async (id) => {
|
|
71
|
-
try {
|
|
72
|
-
const { data } = await gmail.users.threads.get({ userId: 'me', id, format: 'full' });
|
|
73
|
-
if (data.messages) {
|
|
74
|
-
data.messages = data.messages.map(message => {
|
|
75
|
-
if (message.payload) {
|
|
76
|
-
message.payload = processMessagePart(message.payload, params.includeBodyHtml);
|
|
77
|
-
}
|
|
78
|
-
return message;
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
return data;
|
|
82
|
-
} catch (error) {
|
|
83
|
-
return { id, error: error.message || 'Failed to retrieve thread' };
|
|
84
|
-
}
|
|
85
|
-
})
|
|
86
|
-
);
|
|
87
|
-
return JSON.stringify(results);
|
|
88
|
-
},
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
server.addTool({
|
|
92
|
-
name: 'modify_thread',
|
|
93
|
-
description: 'Modify the labels applied to a thread',
|
|
94
|
-
parameters: z.object({
|
|
95
|
-
id: z.string().describe("The ID of the thread to modify"),
|
|
96
|
-
addLabelIds: z.array(z.string()).optional().describe("Label IDs to add"),
|
|
97
|
-
removeLabelIds: z.array(z.string()).optional().describe("Label IDs to remove"),
|
|
98
|
-
}),
|
|
99
|
-
execute: async (params) => {
|
|
100
|
-
const { id, ...threadData } = params;
|
|
101
|
-
const gmail = await getGmailClient();
|
|
102
|
-
const { data } = await gmail.users.threads.modify({ userId: 'me', id, requestBody: threadData });
|
|
103
|
-
return JSON.stringify(data);
|
|
104
|
-
},
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
server.addTool({
|
|
108
|
-
name: 'delete_thread',
|
|
109
|
-
description: 'Delete a thread',
|
|
110
|
-
parameters: z.object({
|
|
111
|
-
id: z.string().describe("The ID of the thread to delete"),
|
|
112
|
-
}),
|
|
113
|
-
execute: async (params) => {
|
|
114
|
-
const gmail = await getGmailClient();
|
|
115
|
-
const { data } = await gmail.users.threads.delete({ userId: 'me', id: params.id });
|
|
116
|
-
return JSON.stringify(data || { success: true });
|
|
117
|
-
},
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
server.addTool({
|
|
121
|
-
name: 'trash_thread',
|
|
122
|
-
description: 'Move a thread to the trash',
|
|
123
|
-
parameters: z.object({
|
|
124
|
-
id: z.string().describe("The ID of the thread to move to trash"),
|
|
125
|
-
}),
|
|
126
|
-
execute: async (params) => {
|
|
127
|
-
const gmail = await getGmailClient();
|
|
128
|
-
const { data } = await gmail.users.threads.trash({ userId: 'me', id: params.id });
|
|
129
|
-
return JSON.stringify(data);
|
|
130
|
-
},
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
server.addTool({
|
|
134
|
-
name: 'untrash_thread',
|
|
135
|
-
description: 'Remove a thread from the trash',
|
|
136
|
-
parameters: z.object({
|
|
137
|
-
id: z.string().describe("The ID of the thread to remove from trash"),
|
|
138
|
-
}),
|
|
139
|
-
execute: async (params) => {
|
|
140
|
-
const gmail = await getGmailClient();
|
|
141
|
-
const { data } = await gmail.users.threads.untrash({ userId: 'me', id: params.id });
|
|
142
|
-
return JSON.stringify(data);
|
|
143
|
-
},
|
|
144
|
-
});
|
|
145
|
-
}
|
|
1
|
+
// Gmail Thread tools
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { getGmailClient } from '../../clients.js';
|
|
4
|
+
import { processMessagePart } from '../../helpers.js';
|
|
5
|
+
|
|
6
|
+
export function register(server) {
|
|
7
|
+
server.addTool({
|
|
8
|
+
name: 'get_thread',
|
|
9
|
+
description: 'Get a specific thread by ID',
|
|
10
|
+
parameters: z.object({
|
|
11
|
+
id: z.string().describe("The ID of the thread to retrieve"),
|
|
12
|
+
includeBodyHtml: z.boolean().optional().describe("Whether to include the parsed HTML in the return for each body"),
|
|
13
|
+
}),
|
|
14
|
+
execute: async (params) => {
|
|
15
|
+
const gmail = await getGmailClient();
|
|
16
|
+
const { data } = await gmail.users.threads.get({ userId: 'me', id: params.id, format: 'full' });
|
|
17
|
+
if (data.messages) {
|
|
18
|
+
data.messages = data.messages.map(message => {
|
|
19
|
+
if (message.payload) {
|
|
20
|
+
message.payload = processMessagePart(message.payload, params.includeBodyHtml);
|
|
21
|
+
}
|
|
22
|
+
return message;
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
return JSON.stringify(data);
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
server.addTool({
|
|
30
|
+
name: 'list_threads',
|
|
31
|
+
description: 'List threads in the user\'s mailbox',
|
|
32
|
+
parameters: z.object({
|
|
33
|
+
maxResults: z.number().optional().describe("Maximum number of threads to return"),
|
|
34
|
+
pageToken: z.string().optional().describe("Page token to retrieve a specific page of results"),
|
|
35
|
+
q: z.string().optional().describe("Only return threads matching the specified query"),
|
|
36
|
+
labelIds: z.array(z.string()).optional().describe("Only return threads with labels that match all specified label IDs"),
|
|
37
|
+
includeSpamTrash: z.boolean().optional().describe("Include threads from SPAM and TRASH"),
|
|
38
|
+
includeBodyHtml: z.boolean().optional().describe("Whether to include the parsed HTML in the return for each body"),
|
|
39
|
+
}),
|
|
40
|
+
execute: async (params) => {
|
|
41
|
+
const gmail = await getGmailClient();
|
|
42
|
+
const { data } = await gmail.users.threads.list({ userId: 'me', ...params });
|
|
43
|
+
if (data.threads) {
|
|
44
|
+
data.threads = data.threads.map(thread => {
|
|
45
|
+
if (thread.messages) {
|
|
46
|
+
thread.messages = thread.messages.map(message => {
|
|
47
|
+
if (message.payload) {
|
|
48
|
+
message.payload = processMessagePart(message.payload, params.includeBodyHtml);
|
|
49
|
+
}
|
|
50
|
+
return message;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
return thread;
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
return JSON.stringify(data);
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
server.addTool({
|
|
61
|
+
name: 'batch_get_threads',
|
|
62
|
+
description: 'Get multiple threads by ID in parallel. More efficient than calling get_thread multiple times.',
|
|
63
|
+
parameters: z.object({
|
|
64
|
+
ids: z.array(z.string()).describe("The IDs of the threads to retrieve"),
|
|
65
|
+
includeBodyHtml: z.boolean().optional().describe("Whether to include the parsed HTML in the return for each body"),
|
|
66
|
+
}),
|
|
67
|
+
execute: async (params) => {
|
|
68
|
+
const gmail = await getGmailClient();
|
|
69
|
+
const results = await Promise.all(
|
|
70
|
+
params.ids.map(async (id) => {
|
|
71
|
+
try {
|
|
72
|
+
const { data } = await gmail.users.threads.get({ userId: 'me', id, format: 'full' });
|
|
73
|
+
if (data.messages) {
|
|
74
|
+
data.messages = data.messages.map(message => {
|
|
75
|
+
if (message.payload) {
|
|
76
|
+
message.payload = processMessagePart(message.payload, params.includeBodyHtml);
|
|
77
|
+
}
|
|
78
|
+
return message;
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
return data;
|
|
82
|
+
} catch (error) {
|
|
83
|
+
return { id, error: error.message || 'Failed to retrieve thread' };
|
|
84
|
+
}
|
|
85
|
+
})
|
|
86
|
+
);
|
|
87
|
+
return JSON.stringify(results);
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
server.addTool({
|
|
92
|
+
name: 'modify_thread',
|
|
93
|
+
description: 'Modify the labels applied to a thread',
|
|
94
|
+
parameters: z.object({
|
|
95
|
+
id: z.string().describe("The ID of the thread to modify"),
|
|
96
|
+
addLabelIds: z.array(z.string()).optional().describe("Label IDs to add"),
|
|
97
|
+
removeLabelIds: z.array(z.string()).optional().describe("Label IDs to remove"),
|
|
98
|
+
}),
|
|
99
|
+
execute: async (params) => {
|
|
100
|
+
const { id, ...threadData } = params;
|
|
101
|
+
const gmail = await getGmailClient();
|
|
102
|
+
const { data } = await gmail.users.threads.modify({ userId: 'me', id, requestBody: threadData });
|
|
103
|
+
return JSON.stringify(data);
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
server.addTool({
|
|
108
|
+
name: 'delete_thread',
|
|
109
|
+
description: 'Delete a thread',
|
|
110
|
+
parameters: z.object({
|
|
111
|
+
id: z.string().describe("The ID of the thread to delete"),
|
|
112
|
+
}),
|
|
113
|
+
execute: async (params) => {
|
|
114
|
+
const gmail = await getGmailClient();
|
|
115
|
+
const { data } = await gmail.users.threads.delete({ userId: 'me', id: params.id });
|
|
116
|
+
return JSON.stringify(data || { success: true });
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
server.addTool({
|
|
121
|
+
name: 'trash_thread',
|
|
122
|
+
description: 'Move a thread to the trash',
|
|
123
|
+
parameters: z.object({
|
|
124
|
+
id: z.string().describe("The ID of the thread to move to trash"),
|
|
125
|
+
}),
|
|
126
|
+
execute: async (params) => {
|
|
127
|
+
const gmail = await getGmailClient();
|
|
128
|
+
const { data } = await gmail.users.threads.trash({ userId: 'me', id: params.id });
|
|
129
|
+
return JSON.stringify(data);
|
|
130
|
+
},
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
server.addTool({
|
|
134
|
+
name: 'untrash_thread',
|
|
135
|
+
description: 'Remove a thread from the trash',
|
|
136
|
+
parameters: z.object({
|
|
137
|
+
id: z.string().describe("The ID of the thread to remove from trash"),
|
|
138
|
+
}),
|
|
139
|
+
execute: async (params) => {
|
|
140
|
+
const gmail = await getGmailClient();
|
|
141
|
+
const { data } = await gmail.users.threads.untrash({ userId: 'me', id: params.id });
|
|
142
|
+
return JSON.stringify(data);
|
|
143
|
+
},
|
|
144
|
+
});
|
|
145
|
+
}
|
package/dist/tools/index.js
CHANGED
|
@@ -74,6 +74,14 @@ const CATEGORIES = {
|
|
|
74
74
|
register(server);
|
|
75
75
|
},
|
|
76
76
|
},
|
|
77
|
+
calendar: {
|
|
78
|
+
description: 'Google Calendar — list calendars, get/create/update/delete events, check busy times, find free slots, move events, recurring event instances, manage calendars',
|
|
79
|
+
toolCount: 8,
|
|
80
|
+
async loader(server) {
|
|
81
|
+
const { registerCalendarTools } = await import('./calendar/index.js');
|
|
82
|
+
registerCalendarTools(server);
|
|
83
|
+
},
|
|
84
|
+
},
|
|
77
85
|
};
|
|
78
86
|
|
|
79
87
|
// Track which categories have been loaded
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// Gmail Label tools
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { getGmailClient } from '../clients.js';
|
|
4
|
+
|
|
5
|
+
export function register(server) {
|
|
6
|
+
server.addTool({
|
|
7
|
+
name: 'create_label',
|
|
8
|
+
description: 'Create a new label',
|
|
9
|
+
parameters: z.object({
|
|
10
|
+
name: z.string().describe("The display name of the label"),
|
|
11
|
+
messageListVisibility: z.enum(['show', 'hide']).optional().describe("Visibility of messages with this label in the message list"),
|
|
12
|
+
labelListVisibility: z.enum(['labelShow', 'labelShowIfUnread', 'labelHide']).optional().describe("Visibility of the label in the label list"),
|
|
13
|
+
color: z.object({
|
|
14
|
+
textColor: z.string().describe("The text color as hex string"),
|
|
15
|
+
backgroundColor: z.string().describe("The background color as hex string"),
|
|
16
|
+
}).optional().describe("The color settings for the label"),
|
|
17
|
+
}),
|
|
18
|
+
execute: async (params) => {
|
|
19
|
+
const gmail = await getGmailClient();
|
|
20
|
+
const { data } = await gmail.users.labels.create({ userId: 'me', requestBody: params });
|
|
21
|
+
return JSON.stringify(data);
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
server.addTool({
|
|
26
|
+
name: 'delete_label',
|
|
27
|
+
description: 'Delete a label',
|
|
28
|
+
parameters: z.object({
|
|
29
|
+
id: z.string().describe("The ID of the label to delete"),
|
|
30
|
+
}),
|
|
31
|
+
execute: async (params) => {
|
|
32
|
+
const gmail = await getGmailClient();
|
|
33
|
+
const { data } = await gmail.users.labels.delete({ userId: 'me', id: params.id });
|
|
34
|
+
return JSON.stringify(data || { success: true });
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
server.addTool({
|
|
39
|
+
name: 'get_label',
|
|
40
|
+
description: 'Get a specific label by ID',
|
|
41
|
+
parameters: z.object({
|
|
42
|
+
id: z.string().describe("The ID of the label to retrieve"),
|
|
43
|
+
}),
|
|
44
|
+
execute: async (params) => {
|
|
45
|
+
const gmail = await getGmailClient();
|
|
46
|
+
const { data } = await gmail.users.labels.get({ userId: 'me', id: params.id });
|
|
47
|
+
return JSON.stringify(data);
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
server.addTool({
|
|
52
|
+
name: 'list_labels',
|
|
53
|
+
description: 'List all labels in the user\'s mailbox',
|
|
54
|
+
parameters: z.object({}),
|
|
55
|
+
execute: async () => {
|
|
56
|
+
const gmail = await getGmailClient();
|
|
57
|
+
const { data } = await gmail.users.labels.list({ userId: 'me' });
|
|
58
|
+
return JSON.stringify(data);
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
server.addTool({
|
|
63
|
+
name: 'patch_label',
|
|
64
|
+
description: 'Patch an existing label (partial update)',
|
|
65
|
+
parameters: z.object({
|
|
66
|
+
id: z.string().describe("The ID of the label to patch"),
|
|
67
|
+
name: z.string().optional().describe("The display name of the label"),
|
|
68
|
+
messageListVisibility: z.enum(['show', 'hide']).optional().describe("Visibility of messages with this label"),
|
|
69
|
+
labelListVisibility: z.enum(['labelShow', 'labelShowIfUnread', 'labelHide']).optional().describe("Visibility of the label in the label list"),
|
|
70
|
+
color: z.object({
|
|
71
|
+
textColor: z.string().describe("The text color as hex string"),
|
|
72
|
+
backgroundColor: z.string().describe("The background color as hex string"),
|
|
73
|
+
}).optional().describe("The color settings for the label"),
|
|
74
|
+
}),
|
|
75
|
+
execute: async (params) => {
|
|
76
|
+
const { id, ...labelData } = params;
|
|
77
|
+
const gmail = await getGmailClient();
|
|
78
|
+
const { data } = await gmail.users.labels.patch({ userId: 'me', id, requestBody: labelData });
|
|
79
|
+
return JSON.stringify(data);
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
server.addTool({
|
|
84
|
+
name: 'update_label',
|
|
85
|
+
description: 'Update an existing label',
|
|
86
|
+
parameters: z.object({
|
|
87
|
+
id: z.string().describe("The ID of the label to update"),
|
|
88
|
+
name: z.string().optional().describe("The display name of the label"),
|
|
89
|
+
messageListVisibility: z.enum(['show', 'hide']).optional().describe("Visibility of messages with this label"),
|
|
90
|
+
labelListVisibility: z.enum(['labelShow', 'labelShowIfUnread', 'labelHide']).optional().describe("Visibility of the label in the label list"),
|
|
91
|
+
color: z.object({
|
|
92
|
+
textColor: z.string().describe("The text color as hex string"),
|
|
93
|
+
backgroundColor: z.string().describe("The background color as hex string"),
|
|
94
|
+
}).optional().describe("The color settings for the label"),
|
|
95
|
+
}),
|
|
96
|
+
execute: async (params) => {
|
|
97
|
+
const { id, ...labelData } = params;
|
|
98
|
+
const gmail = await getGmailClient();
|
|
99
|
+
const { data } = await gmail.users.labels.update({ userId: 'me', id, requestBody: labelData });
|
|
100
|
+
return JSON.stringify(data);
|
|
101
|
+
},
|
|
102
|
+
});
|
|
103
|
+
}
|