@mindstone/mcp-server-google-workspace 0.1.5 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -9
- package/dist/modules/accounts/manager.js +20 -2
- package/dist/modules/accounts/token.d.ts +13 -0
- package/dist/modules/accounts/token.js +73 -58
- package/dist/modules/accounts/types.d.ts +1 -0
- package/dist/modules/calendar/service.js +9 -0
- package/dist/modules/chat/index.d.ts +12 -0
- package/dist/modules/chat/index.js +18 -0
- package/dist/modules/chat/scopes.d.ts +14 -0
- package/dist/modules/chat/scopes.js +32 -0
- package/dist/modules/chat/types.d.ts +88 -0
- package/dist/modules/chat/types.js +14 -0
- package/dist/modules/comments/service.js +26 -5
- package/dist/modules/contacts/scopes.d.ts +1 -0
- package/dist/modules/contacts/scopes.js +2 -2
- package/dist/modules/contacts/types.d.ts +34 -0
- package/dist/modules/docs/index.js +2 -1
- package/dist/modules/docs/service.js +36 -7
- package/dist/modules/drive/activity-service.d.ts +45 -0
- package/dist/modules/drive/activity-service.js +114 -0
- package/dist/modules/drive/index.d.ts +4 -0
- package/dist/modules/drive/index.js +12 -0
- package/dist/modules/drive/scopes.d.ts +1 -0
- package/dist/modules/drive/scopes.js +3 -0
- package/dist/modules/drive/service.d.ts +2 -1
- package/dist/modules/drive/service.js +29 -0
- package/dist/modules/drive/types.d.ts +8 -0
- package/dist/modules/forms/service.js +16 -3
- package/dist/modules/gmail/services/attachment.js +2 -1
- package/dist/modules/gmail/services/base.d.ts +5 -1
- package/dist/modules/gmail/services/base.js +10 -1
- package/dist/modules/gmail/services/draft.js +13 -7
- package/dist/modules/gmail/services/email.js +4 -3
- package/dist/modules/gmail/services/label.js +10 -9
- package/dist/modules/gmail/services/settings.d.ts +14 -1
- package/dist/modules/gmail/services/settings.js +96 -1
- package/dist/modules/gmail/types.d.ts +36 -0
- package/dist/modules/meet/index.d.ts +12 -0
- package/dist/modules/meet/index.js +18 -0
- package/dist/modules/meet/scopes.d.ts +9 -0
- package/dist/modules/meet/scopes.js +25 -0
- package/dist/modules/meet/types.d.ts +97 -0
- package/dist/modules/meet/types.js +14 -0
- package/dist/modules/sheets/service.js +49 -0
- package/dist/modules/slides/service.js +31 -6
- package/dist/modules/tasks/service.js +31 -6
- package/dist/resources/compose-email-template.d.ts +1 -1
- package/dist/resources/compose-email-template.js +388 -19
- package/dist/services/base/BaseGoogleService.d.ts +9 -1
- package/dist/services/base/BaseGoogleService.js +33 -1
- package/dist/services/chat/index.d.ts +34 -0
- package/dist/services/chat/index.js +120 -0
- package/dist/services/contacts/index.d.ts +19 -1
- package/dist/services/contacts/index.js +124 -0
- package/dist/services/meet/index.d.ts +35 -0
- package/dist/services/meet/index.js +116 -0
- package/dist/tools/calendar-handlers.js +28 -23
- package/dist/tools/chat-handlers.d.ts +14 -0
- package/dist/tools/chat-handlers.js +126 -0
- package/dist/tools/contacts-handlers.d.ts +31 -0
- package/dist/tools/contacts-handlers.js +96 -23
- package/dist/tools/definitions/account.js +8 -1
- package/dist/tools/definitions/chat.d.ts +3 -0
- package/dist/tools/definitions/chat.js +137 -0
- package/dist/tools/definitions/contacts.js +82 -0
- package/dist/tools/definitions/destructive-overrides.json +12 -0
- package/dist/tools/definitions/drive.js +132 -6
- package/dist/tools/definitions/gmail.js +94 -0
- package/dist/tools/definitions/index.d.ts +2 -0
- package/dist/tools/definitions/index.js +6 -0
- package/dist/tools/definitions/meet.d.ts +3 -0
- package/dist/tools/definitions/meet.js +149 -0
- package/dist/tools/definitions/open-world-overrides.json +12 -0
- package/dist/tools/drive-handlers.d.ts +27 -0
- package/dist/tools/drive-handlers.js +93 -2
- package/dist/tools/forms-handlers.js +5 -12
- package/dist/tools/gmail-handlers.d.ts +31 -1
- package/dist/tools/gmail-handlers.js +167 -35
- package/dist/tools/meet-handlers.d.ts +42 -0
- package/dist/tools/meet-handlers.js +144 -0
- package/dist/tools/server.js +67 -5
- package/dist/tools/tasks-handlers.js +7 -18
- package/dist/tools/type-guards.d.ts +3 -1
- package/dist/tools/type-guards.js +22 -2
- package/dist/tools/types.d.ts +13 -0
- package/dist/utils/apiError.d.ts +49 -0
- package/dist/utils/apiError.js +96 -0
- package/dist/utils/scope-hierarchy.js +10 -0
- package/dist/utils/service-initializer.js +9 -0
- package/dist/utils/untrusted-content.d.ts +37 -1
- package/dist/utils/untrusted-content.js +61 -6
- package/package.json +5 -1
- package/dist/services/calendar/index.d.ts +0 -27
- package/dist/services/calendar/index.js +0 -146
- package/dist/services/gmail/index.d.ts +0 -39
- package/dist/services/gmail/index.js +0 -337
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { ChatService } from "../services/chat/index.js";
|
|
2
|
+
import { McpError, ErrorCode } from "@modelcontextprotocol/sdk/types.js";
|
|
3
|
+
import { toMcpError } from "../utils/apiError.js";
|
|
4
|
+
import { getAccountManager, resolveEmail } from "../modules/accounts/index.js";
|
|
5
|
+
import { readAliasedNumber, readAliasedString } from './arg-aliases.js';
|
|
6
|
+
import { wrapUntrustedJsonStrings } from "../utils/untrusted-content.js";
|
|
7
|
+
// Cap page sizes well below the Chat API maximum (1000) to keep responses manageable
|
|
8
|
+
const MAX_CHAT_PAGE_SIZE = 100;
|
|
9
|
+
// Google Chat documents a maximum TOTAL message size of 32,000 bytes
|
|
10
|
+
// (spaces.messages.create). Enforce it against the UTF-8 byte length of the
|
|
11
|
+
// text body — the only sizable field this tool sends.
|
|
12
|
+
const MAX_CHAT_MESSAGE_TEXT_BYTES = 32_000;
|
|
13
|
+
// Space resource names look like "spaces/AAAA..." — exactly one segment after the prefix.
|
|
14
|
+
const SPACE_NAME_PATTERN = /^spaces\/[^/\s]+$/;
|
|
15
|
+
// Singleton instances - Initialize or inject as per project pattern
|
|
16
|
+
let chatService;
|
|
17
|
+
let accountManager;
|
|
18
|
+
/**
|
|
19
|
+
* Initialize required services.
|
|
20
|
+
* This should likely be integrated into a central initialization process.
|
|
21
|
+
*/
|
|
22
|
+
async function initializeServices() {
|
|
23
|
+
if (!chatService) {
|
|
24
|
+
chatService = new ChatService();
|
|
25
|
+
}
|
|
26
|
+
if (!accountManager) {
|
|
27
|
+
accountManager = getAccountManager();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function capPageSize(pageSize) {
|
|
31
|
+
return pageSize !== undefined ? Math.min(pageSize, MAX_CHAT_PAGE_SIZE) : undefined;
|
|
32
|
+
}
|
|
33
|
+
function requireSpaceName(space) {
|
|
34
|
+
if (!space || !SPACE_NAME_PATTERN.test(space)) {
|
|
35
|
+
throw new McpError(ErrorCode.InvalidParams, 'space must be a space resource name of the form "spaces/<id>" (e.g. "spaces/AAAA...")');
|
|
36
|
+
}
|
|
37
|
+
return space;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Handler function for listing Google Chat spaces.
|
|
41
|
+
*/
|
|
42
|
+
export async function handleListChatSpaces(params) {
|
|
43
|
+
await initializeServices(); // Ensure services are ready
|
|
44
|
+
const pageSize = readAliasedNumber(params, 'page_size', 'pageSize');
|
|
45
|
+
const pageToken = readAliasedString(params, 'page_token', 'pageToken');
|
|
46
|
+
const filter = typeof params.filter === 'string' ? params.filter : undefined;
|
|
47
|
+
// Resolve email - uses instance account if not provided, validates if provided
|
|
48
|
+
const email = await resolveEmail(params);
|
|
49
|
+
// Use accountManager for token renewal like in Contacts handlers
|
|
50
|
+
return accountManager.withTokenRenewal(email, async () => {
|
|
51
|
+
try {
|
|
52
|
+
const result = await chatService.listSpaces({
|
|
53
|
+
email,
|
|
54
|
+
pageSize: capPageSize(pageSize),
|
|
55
|
+
pageToken,
|
|
56
|
+
filter
|
|
57
|
+
});
|
|
58
|
+
return wrapUntrustedJsonStrings(result, 'google-workspace:chat:spaces');
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
// toMcpError passes an McpError (and auth-handoff errors) through unchanged, and folds
|
|
62
|
+
// a ChatError's details into the message so the real cause reaches the user.
|
|
63
|
+
throw toMcpError(error, 'Failed to list chat spaces');
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Handler function for listing messages in a Google Chat space.
|
|
69
|
+
*/
|
|
70
|
+
export async function handleListChatMessages(params) {
|
|
71
|
+
await initializeServices();
|
|
72
|
+
const pageSize = readAliasedNumber(params, 'page_size', 'pageSize');
|
|
73
|
+
const pageToken = readAliasedString(params, 'page_token', 'pageToken');
|
|
74
|
+
const filter = typeof params.filter === 'string' ? params.filter : undefined;
|
|
75
|
+
const orderBy = readAliasedString(params, 'order_by', 'orderBy');
|
|
76
|
+
const space = requireSpaceName(readAliasedString(params, 'space', 'space'));
|
|
77
|
+
// Resolve email - uses instance account if not provided, validates if provided
|
|
78
|
+
const email = await resolveEmail(params);
|
|
79
|
+
return accountManager.withTokenRenewal(email, async () => {
|
|
80
|
+
try {
|
|
81
|
+
const result = await chatService.listMessages({
|
|
82
|
+
email,
|
|
83
|
+
parent: space,
|
|
84
|
+
pageSize: capPageSize(pageSize),
|
|
85
|
+
pageToken,
|
|
86
|
+
filter,
|
|
87
|
+
orderBy
|
|
88
|
+
});
|
|
89
|
+
return wrapUntrustedJsonStrings(result, 'google-workspace:chat:messages');
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
throw toMcpError(error, 'Failed to list chat messages');
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Handler function for posting a text message to a Google Chat space.
|
|
98
|
+
*/
|
|
99
|
+
export async function handleSendChatMessage(params) {
|
|
100
|
+
await initializeServices();
|
|
101
|
+
const space = requireSpaceName(readAliasedString(params, 'space', 'space'));
|
|
102
|
+
const text = readAliasedString(params, 'text', 'text');
|
|
103
|
+
if (!text) {
|
|
104
|
+
throw new McpError(ErrorCode.InvalidParams, 'text parameter is required (the plain-text message body to send)');
|
|
105
|
+
}
|
|
106
|
+
const textBytes = Buffer.byteLength(text, 'utf8');
|
|
107
|
+
if (textBytes > MAX_CHAT_MESSAGE_TEXT_BYTES) {
|
|
108
|
+
throw new McpError(ErrorCode.InvalidParams, `text exceeds the Chat message size limit of ${MAX_CHAT_MESSAGE_TEXT_BYTES} bytes (got ${textBytes})`);
|
|
109
|
+
}
|
|
110
|
+
// Resolve email - uses instance account if not provided, validates if provided
|
|
111
|
+
const email = await resolveEmail(params);
|
|
112
|
+
return accountManager.withTokenRenewal(email, async () => {
|
|
113
|
+
try {
|
|
114
|
+
const result = await chatService.sendMessage({
|
|
115
|
+
email,
|
|
116
|
+
parent: space,
|
|
117
|
+
text
|
|
118
|
+
});
|
|
119
|
+
return wrapUntrustedJsonStrings(result, 'google-workspace:chat:message');
|
|
120
|
+
}
|
|
121
|
+
catch (error) {
|
|
122
|
+
throw toMcpError(error, 'Failed to send chat message');
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=chat-handlers.js.map
|
|
@@ -32,5 +32,36 @@ export declare function handleSearchContacts(params: SearchContactsParams): Prom
|
|
|
32
32
|
}>;
|
|
33
33
|
totalResults: number;
|
|
34
34
|
}>;
|
|
35
|
+
export interface ContactWriteToolParams {
|
|
36
|
+
email?: string;
|
|
37
|
+
given_name?: string;
|
|
38
|
+
givenName?: string;
|
|
39
|
+
family_name?: string;
|
|
40
|
+
familyName?: string;
|
|
41
|
+
email_address?: string;
|
|
42
|
+
emailAddress?: string;
|
|
43
|
+
email_type?: string;
|
|
44
|
+
emailType?: string;
|
|
45
|
+
phone_number?: string;
|
|
46
|
+
phoneNumber?: string;
|
|
47
|
+
phone_type?: string;
|
|
48
|
+
phoneType?: string;
|
|
49
|
+
organization?: string;
|
|
50
|
+
job_title?: string;
|
|
51
|
+
jobTitle?: string;
|
|
52
|
+
notes?: string;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Handler for creating a new Google Contact.
|
|
56
|
+
*/
|
|
57
|
+
export declare function handleCreateContact(params: ContactWriteToolParams): Promise<unknown>;
|
|
58
|
+
/**
|
|
59
|
+
* Handler for updating an existing Google Contact. Only the provided fields
|
|
60
|
+
* are replaced; everything else on the contact is left untouched.
|
|
61
|
+
*/
|
|
62
|
+
export declare function handleUpdateContact(params: ContactWriteToolParams & {
|
|
63
|
+
resource_name?: string;
|
|
64
|
+
resourceName?: string;
|
|
65
|
+
}): Promise<unknown>;
|
|
35
66
|
export {};
|
|
36
67
|
//# sourceMappingURL=contacts-handlers.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ContactsError } from "../modules/contacts/types.js";
|
|
2
1
|
import { ContactsService } from "../services/contacts/index.js";
|
|
3
2
|
import { McpError, ErrorCode } from "@modelcontextprotocol/sdk/types.js";
|
|
3
|
+
import { toMcpError } from "../utils/apiError.js";
|
|
4
4
|
import { getAccountManager, resolveEmail } from "../modules/accounts/index.js";
|
|
5
5
|
import { readAliasedBoolean, readAliasedNumber, readAliasedString } from './arg-aliases.js';
|
|
6
6
|
import { wrapUntrustedContent, wrapUntrustedJsonStrings } from "../utils/untrusted-content.js";
|
|
@@ -48,19 +48,10 @@ export async function handleGetContacts(params) {
|
|
|
48
48
|
return wrapUntrustedJsonStrings(result, 'google-workspace:contacts:list');
|
|
49
49
|
}
|
|
50
50
|
catch (error) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
else if (error instanceof McpError) {
|
|
57
|
-
// Re-throw existing McpErrors (like auth errors from token renewal)
|
|
58
|
-
throw error;
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
// Catch unexpected errors
|
|
62
|
-
throw new McpError(ErrorCode.InternalError, `Failed to get contacts: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
63
|
-
}
|
|
51
|
+
// toMcpError passes an McpError through, and folds a ContactsError's details into
|
|
52
|
+
// the message (InternalError) so the real cause reaches the user — the host drops
|
|
53
|
+
// an McpError's `data` arg, so details-as-data (the old shape) were invisible.
|
|
54
|
+
throw toMcpError(error, 'Failed to get contacts');
|
|
64
55
|
}
|
|
65
56
|
});
|
|
66
57
|
}
|
|
@@ -113,15 +104,97 @@ export async function handleSearchContacts(params) {
|
|
|
113
104
|
return formatContactsAsText(result.results, result.totalResults);
|
|
114
105
|
}
|
|
115
106
|
catch (error) {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
107
|
+
// See handleGetContacts: toMcpError surfaces the real cause (details folded into
|
|
108
|
+
// the message) and passes an McpError through unchanged.
|
|
109
|
+
throw toMcpError(error, 'Failed to search contacts');
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
// Contact resource names follow the documented "people/<id>" form.
|
|
114
|
+
const CONTACT_RESOURCE_NAME_PATTERN = /^people\/[^/\s]+$/;
|
|
115
|
+
// Deliberately permissive email shape check — the People API is the authority;
|
|
116
|
+
// this only catches clearly-malformed values before a network round-trip.
|
|
117
|
+
const EMAIL_PATTERN = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
118
|
+
// Phone values are free-form upstream, but must contain at least one digit.
|
|
119
|
+
const MAX_PHONE_LENGTH = 64;
|
|
120
|
+
function readContactWriteFields(params) {
|
|
121
|
+
const raw = params;
|
|
122
|
+
return {
|
|
123
|
+
givenName: readAliasedString(raw, 'given_name', 'givenName'),
|
|
124
|
+
familyName: readAliasedString(raw, 'family_name', 'familyName'),
|
|
125
|
+
emailAddress: readAliasedString(raw, 'email_address', 'emailAddress'),
|
|
126
|
+
emailType: readAliasedString(raw, 'email_type', 'emailType'),
|
|
127
|
+
phoneNumber: readAliasedString(raw, 'phone_number', 'phoneNumber'),
|
|
128
|
+
phoneType: readAliasedString(raw, 'phone_type', 'phoneType'),
|
|
129
|
+
organization: readAliasedString(raw, 'organization', 'organization'),
|
|
130
|
+
jobTitle: readAliasedString(raw, 'job_title', 'jobTitle'),
|
|
131
|
+
notes: readAliasedString(raw, 'notes', 'notes')
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
function validateContactWriteFields(fields) {
|
|
135
|
+
if (fields.emailAddress !== undefined && !EMAIL_PATTERN.test(fields.emailAddress)) {
|
|
136
|
+
throw new McpError(ErrorCode.InvalidParams, 'email_address must be a valid email address (e.g. "jane@example.com")');
|
|
137
|
+
}
|
|
138
|
+
if (fields.phoneNumber !== undefined
|
|
139
|
+
&& (fields.phoneNumber.length > MAX_PHONE_LENGTH || !/\d/.test(fields.phoneNumber))) {
|
|
140
|
+
throw new McpError(ErrorCode.InvalidParams, 'phone_number must contain at least one digit and be at most 64 characters');
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
function hasAnyWriteField(fields) {
|
|
144
|
+
return Object.values(fields).some(value => value !== undefined);
|
|
145
|
+
}
|
|
146
|
+
function formatWriteResult(action, result) {
|
|
147
|
+
// Every string field is enveloped, matching the read handlers' whole-result wrapping.
|
|
148
|
+
return wrapUntrustedJsonStrings({ status: 'success', action, contact: result }, 'google-workspace:contacts:write');
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Handler for creating a new Google Contact.
|
|
152
|
+
*/
|
|
153
|
+
export async function handleCreateContact(params) {
|
|
154
|
+
await initializeServices();
|
|
155
|
+
const email = await resolveEmail(params);
|
|
156
|
+
const fields = readContactWriteFields(params);
|
|
157
|
+
validateContactWriteFields(fields);
|
|
158
|
+
if (!hasAnyWriteField(fields)) {
|
|
159
|
+
throw new McpError(ErrorCode.InvalidParams, 'Provide at least one contact field (e.g. given_name, email_address, phone_number)');
|
|
160
|
+
}
|
|
161
|
+
if (!fields.givenName && !fields.familyName && !fields.emailAddress) {
|
|
162
|
+
throw new McpError(ErrorCode.InvalidParams, 'A new contact needs at least a name (given_name / family_name) or an email_address');
|
|
163
|
+
}
|
|
164
|
+
return accountManager.withTokenRenewal(email, async () => {
|
|
165
|
+
try {
|
|
166
|
+
const result = await contactsService.createContact({ email, ...fields });
|
|
167
|
+
return formatWriteResult('created', result);
|
|
168
|
+
}
|
|
169
|
+
catch (error) {
|
|
170
|
+
throw toMcpError(error, 'Failed to create contact');
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Handler for updating an existing Google Contact. Only the provided fields
|
|
176
|
+
* are replaced; everything else on the contact is left untouched.
|
|
177
|
+
*/
|
|
178
|
+
export async function handleUpdateContact(params) {
|
|
179
|
+
await initializeServices();
|
|
180
|
+
const email = await resolveEmail(params);
|
|
181
|
+
const raw = params;
|
|
182
|
+
const resourceName = readAliasedString(raw, 'resource_name', 'resourceName');
|
|
183
|
+
const fields = readContactWriteFields(params);
|
|
184
|
+
validateContactWriteFields(fields);
|
|
185
|
+
if (!resourceName || !CONTACT_RESOURCE_NAME_PATTERN.test(resourceName)) {
|
|
186
|
+
throw new McpError(ErrorCode.InvalidParams, 'resource_name is required in the form "people/c1234567890" — get it from search_workspace_contacts');
|
|
187
|
+
}
|
|
188
|
+
if (!hasAnyWriteField(fields)) {
|
|
189
|
+
throw new McpError(ErrorCode.InvalidParams, 'Provide at least one field to update (e.g. phone_number, organization, notes)');
|
|
190
|
+
}
|
|
191
|
+
return accountManager.withTokenRenewal(email, async () => {
|
|
192
|
+
try {
|
|
193
|
+
const result = await contactsService.updateContact({ email, resourceName, ...fields });
|
|
194
|
+
return formatWriteResult('updated', result);
|
|
195
|
+
}
|
|
196
|
+
catch (error) {
|
|
197
|
+
throw toMcpError(error, 'Failed to update contact');
|
|
125
198
|
}
|
|
126
199
|
});
|
|
127
200
|
}
|
|
@@ -24,10 +24,17 @@ export const accountTools = [
|
|
|
24
24
|
default_package_id // mirrors the package_id of the is_default account; empty string if no accounts
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
auth_status.valid means "reconnect is NOT required". A transient refresh blip (status
|
|
28
|
+
"REFRESH_FAILED" with a temporary-error reason) keeps it true; anything else that isn't a live
|
|
29
|
+
grant sets it false — a revoked/invalid grant ("AUTH_REQUIRED"), a missing token ("NO_TOKEN"),
|
|
30
|
+
an unusable token ("INVALID"), or a hard error ("ERROR"). Read status/reason for detail.
|
|
31
|
+
|
|
27
32
|
Common Response Patterns:
|
|
28
|
-
- Valid account exists → Proceed with requested operation (use its package_id)
|
|
33
|
+
- Valid account exists (auth_status.valid true) → Proceed with requested operation (use its package_id)
|
|
29
34
|
- Multiple accounts exist → Ask user which to use; fall back to default_package_id if user has no preference
|
|
30
35
|
- Token expired → Proceed normally (auto-refresh occurs)
|
|
36
|
+
- Transient refresh failure (auth_status.valid true, status "REFRESH_FAILED", reason mentions a temporary error) → Proceed / retry the operation; do NOT tell the user to reconnect — the grant is still valid, the refresh just hit a temporary network blip
|
|
37
|
+
- Reconnect required (auth_status.valid false, e.g. status "AUTH_REQUIRED", "NO_TOKEN", "INVALID", or "ERROR") → Start authentication flow
|
|
31
38
|
- No accounts exist → Start authentication flow
|
|
32
39
|
|
|
33
40
|
Example Usage:
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
// Define Chat Tools
|
|
2
|
+
export const chatTools = [
|
|
3
|
+
{
|
|
4
|
+
name: "list_chat_spaces",
|
|
5
|
+
category: "Chat",
|
|
6
|
+
description: `List Google Chat spaces (direct messages, group chats, and named spaces) for the authenticated user.
|
|
7
|
+
|
|
8
|
+
IMPORTANT: Before using this tool:
|
|
9
|
+
1. Verify account access with list_workspace_accounts
|
|
10
|
+
2. Confirm account if multiple exist
|
|
11
|
+
3. Check required scopes include Chat read access
|
|
12
|
+
|
|
13
|
+
Parameters:
|
|
14
|
+
- email: The Google account email to list spaces for
|
|
15
|
+
- page_size: Optional maximum number of spaces to return (max 100)
|
|
16
|
+
- page_token: Optional token for pagination (to get the next page)
|
|
17
|
+
- filter: Optional filter by space type (e.g. 'space_type = "SPACE"')
|
|
18
|
+
|
|
19
|
+
Example Usage:
|
|
20
|
+
1. Call list_workspace_accounts to check for valid accounts
|
|
21
|
+
2. Call list_chat_spaces to retrieve spaces
|
|
22
|
+
3. Use the space "name" field (e.g. "spaces/AAAA...") with list_chat_messages or send_chat_message`,
|
|
23
|
+
aliases: ["list_spaces", "get_chat_spaces"],
|
|
24
|
+
annotations: { readOnlyHint: true },
|
|
25
|
+
inputSchema: {
|
|
26
|
+
type: "object",
|
|
27
|
+
properties: {
|
|
28
|
+
email: {
|
|
29
|
+
type: "string",
|
|
30
|
+
description: "Email address of the Google account"
|
|
31
|
+
},
|
|
32
|
+
page_size: {
|
|
33
|
+
type: "number",
|
|
34
|
+
description: "Maximum number of spaces to return (default: API default, max: 100)"
|
|
35
|
+
},
|
|
36
|
+
page_token: {
|
|
37
|
+
type: "string",
|
|
38
|
+
description: "Page token from a previous response (for pagination)"
|
|
39
|
+
},
|
|
40
|
+
filter: {
|
|
41
|
+
type: "string",
|
|
42
|
+
description: 'Optional filter by space type (e.g. \'space_type = "SPACE"\' or \'space_type = "GROUP_CHAT"\')'
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
required: []
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: "list_chat_messages",
|
|
50
|
+
category: "Chat",
|
|
51
|
+
description: `List messages in a Google Chat space.
|
|
52
|
+
|
|
53
|
+
Use list_chat_spaces first to find the space resource name (e.g. "spaces/AAAA...").
|
|
54
|
+
|
|
55
|
+
Parameters:
|
|
56
|
+
- email: The Google account email to read messages for
|
|
57
|
+
- space: Required space resource name (e.g. "spaces/AAAA...")
|
|
58
|
+
- page_size: Optional maximum number of messages to return (max 100)
|
|
59
|
+
- page_token: Optional token for pagination (to get the next page)
|
|
60
|
+
- filter: Optional filter (e.g. 'create_time > "2026-01-01T00:00:00+00:00"')
|
|
61
|
+
- order_by: Optional ordering (e.g. "create_time desc"; default is create_time ascending)
|
|
62
|
+
|
|
63
|
+
Example usage:
|
|
64
|
+
- Recent messages: { "space": "spaces/AAAA...", "page_size": 20, "order_by": "create_time desc" }`,
|
|
65
|
+
aliases: ["list_messages", "get_chat_messages"],
|
|
66
|
+
annotations: { readOnlyHint: true },
|
|
67
|
+
inputSchema: {
|
|
68
|
+
type: "object",
|
|
69
|
+
properties: {
|
|
70
|
+
email: {
|
|
71
|
+
type: "string",
|
|
72
|
+
description: "Email address of the Google account"
|
|
73
|
+
},
|
|
74
|
+
space: {
|
|
75
|
+
type: "string",
|
|
76
|
+
description: 'Space resource name, e.g. "spaces/AAAA..." (from list_chat_spaces)'
|
|
77
|
+
},
|
|
78
|
+
page_size: {
|
|
79
|
+
type: "number",
|
|
80
|
+
description: "Maximum number of messages to return (default: 25, max: 100)"
|
|
81
|
+
},
|
|
82
|
+
page_token: {
|
|
83
|
+
type: "string",
|
|
84
|
+
description: "Page token from a previous response (for pagination)"
|
|
85
|
+
},
|
|
86
|
+
filter: {
|
|
87
|
+
type: "string",
|
|
88
|
+
description: 'Optional filter by create_time and/or thread.name (e.g. \'create_time > "2026-01-01T00:00:00+00:00"\')'
|
|
89
|
+
},
|
|
90
|
+
order_by: {
|
|
91
|
+
type: "string",
|
|
92
|
+
description: 'Optional ordering, e.g. "create_time desc" (default: create_time ascending)'
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
required: ["space"]
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
name: "send_chat_message",
|
|
100
|
+
category: "Chat",
|
|
101
|
+
description: `Post a plain-text message to a Google Chat space as the authenticated user.
|
|
102
|
+
|
|
103
|
+
This sends a real message visible to everyone in the space. Confirm the space
|
|
104
|
+
and the message content with the user before sending.
|
|
105
|
+
|
|
106
|
+
Use list_chat_spaces first to find the space resource name (e.g. "spaces/AAAA...").
|
|
107
|
+
|
|
108
|
+
Parameters:
|
|
109
|
+
- email: The Google account email to send from
|
|
110
|
+
- space: Required space resource name (e.g. "spaces/AAAA...")
|
|
111
|
+
- text: Required plain-text message body
|
|
112
|
+
|
|
113
|
+
Example usage:
|
|
114
|
+
- { "space": "spaces/AAAA...", "text": "Meeting moved to 3pm" }`,
|
|
115
|
+
aliases: ["send_message", "post_chat_message"],
|
|
116
|
+
annotations: { readOnlyHint: false },
|
|
117
|
+
inputSchema: {
|
|
118
|
+
type: "object",
|
|
119
|
+
properties: {
|
|
120
|
+
email: {
|
|
121
|
+
type: "string",
|
|
122
|
+
description: "Email address of the Google account"
|
|
123
|
+
},
|
|
124
|
+
space: {
|
|
125
|
+
type: "string",
|
|
126
|
+
description: 'Space resource name, e.g. "spaces/AAAA..." (from list_chat_spaces)'
|
|
127
|
+
},
|
|
128
|
+
text: {
|
|
129
|
+
type: "string",
|
|
130
|
+
description: "Plain-text message body to post to the space"
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
required: ["space", "text"]
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
];
|
|
137
|
+
//# sourceMappingURL=chat.js.map
|
|
@@ -88,6 +88,88 @@ export const contactsTools = [
|
|
|
88
88
|
},
|
|
89
89
|
required: ["query"]
|
|
90
90
|
}
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
name: "create_workspace_contact",
|
|
94
|
+
category: "Contacts",
|
|
95
|
+
description: `Create a new Google Contact.
|
|
96
|
+
|
|
97
|
+
Requires the full Contacts permission (read + write). If the connected account
|
|
98
|
+
only granted read access, the tool explains how to reconnect with the write
|
|
99
|
+
permission.
|
|
100
|
+
|
|
101
|
+
Parameters:
|
|
102
|
+
- email: The Google account email to create the contact in
|
|
103
|
+
- given_name / family_name: Contact name (at least a name or email_address is required)
|
|
104
|
+
- email_address (+ optional email_type, e.g. "work")
|
|
105
|
+
- phone_number (+ optional phone_type, e.g. "mobile")
|
|
106
|
+
- organization / job_title
|
|
107
|
+
- notes: Free-text note stored on the contact
|
|
108
|
+
|
|
109
|
+
Example: { "given_name": "Jane", "family_name": "Doe", "email_address": "jane@example.com", "organization": "Acme Corp" }`,
|
|
110
|
+
aliases: ["create_contact", "add_contact", "new_contact"],
|
|
111
|
+
annotations: { readOnlyHint: false },
|
|
112
|
+
inputSchema: {
|
|
113
|
+
type: "object",
|
|
114
|
+
properties: {
|
|
115
|
+
email: {
|
|
116
|
+
type: "string",
|
|
117
|
+
description: "Email address of the Google account"
|
|
118
|
+
},
|
|
119
|
+
given_name: { type: "string", description: "First name" },
|
|
120
|
+
family_name: { type: "string", description: "Last name" },
|
|
121
|
+
email_address: { type: "string", description: "Contact email address" },
|
|
122
|
+
email_type: { type: "string", description: 'Email type label (e.g. "home", "work")' },
|
|
123
|
+
phone_number: { type: "string", description: "Contact phone number" },
|
|
124
|
+
phone_type: { type: "string", description: 'Phone type label (e.g. "mobile", "work")' },
|
|
125
|
+
organization: { type: "string", description: "Company or organization name" },
|
|
126
|
+
job_title: { type: "string", description: "Job title at the organization" },
|
|
127
|
+
notes: { type: "string", description: "Free-text note stored on the contact" }
|
|
128
|
+
},
|
|
129
|
+
required: []
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
name: "update_workspace_contact",
|
|
134
|
+
category: "Contacts",
|
|
135
|
+
description: `Update fields on an existing Google Contact. Only the fields you
|
|
136
|
+
provide are replaced; everything else on the contact is left untouched.
|
|
137
|
+
|
|
138
|
+
Get the resource_name from search_workspace_contacts or get_workspace_contacts
|
|
139
|
+
(it looks like "people/c1234567890").
|
|
140
|
+
|
|
141
|
+
Parameters:
|
|
142
|
+
- email: The Google account email that owns the contact
|
|
143
|
+
- resource_name: Required. The contact's resource name (e.g. "people/c1234567890")
|
|
144
|
+
- Any of the create_workspace_contact fields to replace: given_name, family_name,
|
|
145
|
+
email_address, email_type, phone_number, phone_type, organization, job_title, notes
|
|
146
|
+
|
|
147
|
+
Example: { "resource_name": "people/c1234567890", "phone_number": "+1 555 0100", "organization": "Acme Corp" }`,
|
|
148
|
+
aliases: ["update_contact", "edit_contact", "modify_contact"],
|
|
149
|
+
annotations: { readOnlyHint: false },
|
|
150
|
+
inputSchema: {
|
|
151
|
+
type: "object",
|
|
152
|
+
properties: {
|
|
153
|
+
email: {
|
|
154
|
+
type: "string",
|
|
155
|
+
description: "Email address of the Google account"
|
|
156
|
+
},
|
|
157
|
+
resource_name: {
|
|
158
|
+
type: "string",
|
|
159
|
+
description: 'The contact resource name (e.g. "people/c1234567890")'
|
|
160
|
+
},
|
|
161
|
+
given_name: { type: "string", description: "First name" },
|
|
162
|
+
family_name: { type: "string", description: "Last name" },
|
|
163
|
+
email_address: { type: "string", description: "Contact email address" },
|
|
164
|
+
email_type: { type: "string", description: 'Email type label (e.g. "home", "work")' },
|
|
165
|
+
phone_number: { type: "string", description: "Contact phone number" },
|
|
166
|
+
phone_type: { type: "string", description: 'Phone type label (e.g. "mobile", "work")' },
|
|
167
|
+
organization: { type: "string", description: "Company or organization name" },
|
|
168
|
+
job_title: { type: "string", description: "Job title at the organization" },
|
|
169
|
+
notes: { type: "string", description: "Free-text note stored on the contact" }
|
|
170
|
+
},
|
|
171
|
+
required: ["resource_name"]
|
|
172
|
+
}
|
|
91
173
|
}
|
|
92
174
|
];
|
|
93
175
|
//# sourceMappingURL=contacts.js.map
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"create_task": true,
|
|
17
17
|
"create_workspace_calendar_event": true,
|
|
18
18
|
"create_workspace_comment": true,
|
|
19
|
+
"create_workspace_contact": true,
|
|
19
20
|
"create_workspace_document": true,
|
|
20
21
|
"create_workspace_draft": true,
|
|
21
22
|
"create_workspace_label": true,
|
|
@@ -44,6 +45,7 @@
|
|
|
44
45
|
"get_current_time": false,
|
|
45
46
|
"get_form": false,
|
|
46
47
|
"get_form_response": false,
|
|
48
|
+
"get_meet_transcript_entries": false,
|
|
47
49
|
"get_workspace_calendar_event": false,
|
|
48
50
|
"get_workspace_contacts": false,
|
|
49
51
|
"get_workspace_draft": false,
|
|
@@ -52,10 +54,15 @@
|
|
|
52
54
|
"get_workspace_label": false,
|
|
53
55
|
"get_workspace_slide": false,
|
|
54
56
|
"get_workspace_slide_thumbnail": false,
|
|
57
|
+
"list_chat_messages": false,
|
|
58
|
+
"list_chat_spaces": false,
|
|
55
59
|
"list_drive_files": false,
|
|
56
60
|
"list_file_revisions": false,
|
|
57
61
|
"list_form_responses": false,
|
|
58
62
|
"list_forms": false,
|
|
63
|
+
"list_meet_conference_records": false,
|
|
64
|
+
"list_meet_transcripts": false,
|
|
65
|
+
"list_shared_drives": false,
|
|
59
66
|
"list_task_lists": false,
|
|
60
67
|
"list_tasks": false,
|
|
61
68
|
"list_workspace_accounts": false,
|
|
@@ -67,6 +74,7 @@
|
|
|
67
74
|
"list_workspace_label_filters": false,
|
|
68
75
|
"list_workspace_labels": false,
|
|
69
76
|
"list_workspace_presentation_slides": false,
|
|
77
|
+
"list_workspace_send_as": false,
|
|
70
78
|
"list_workspace_spreadsheet_sheets": false,
|
|
71
79
|
"manage_workspace_attachment": true,
|
|
72
80
|
"manage_workspace_calendar_event": true,
|
|
@@ -77,6 +85,7 @@
|
|
|
77
85
|
"mark_workspace_email_read": false,
|
|
78
86
|
"mark_workspace_email_unread": false,
|
|
79
87
|
"move_drive_file": true,
|
|
88
|
+
"query_drive_activity": false,
|
|
80
89
|
"read_workspace_document": false,
|
|
81
90
|
"read_workspace_presentation": false,
|
|
82
91
|
"read_workspace_spreadsheet": false,
|
|
@@ -89,6 +98,7 @@
|
|
|
89
98
|
"search_drive_files": false,
|
|
90
99
|
"search_workspace_contacts": false,
|
|
91
100
|
"search_workspace_emails": false,
|
|
101
|
+
"send_chat_message": true,
|
|
92
102
|
"send_workspace_draft": true,
|
|
93
103
|
"send_workspace_email": true,
|
|
94
104
|
"trash_drive_file": true,
|
|
@@ -97,10 +107,12 @@
|
|
|
97
107
|
"untrash_workspace_email": true,
|
|
98
108
|
"update_drive_permissions": true,
|
|
99
109
|
"update_task": true,
|
|
110
|
+
"update_workspace_contact": true,
|
|
100
111
|
"update_workspace_draft": true,
|
|
101
112
|
"update_workspace_label": true,
|
|
102
113
|
"update_workspace_label_filter": true,
|
|
103
114
|
"update_workspace_spreadsheet_values": true,
|
|
115
|
+
"update_workspace_vacation_responder": true,
|
|
104
116
|
"upload_drive_file": true,
|
|
105
117
|
"upload_workspace_attachment": true
|
|
106
118
|
}
|