@node2flow/gmail-mcp 1.0.2 → 1.0.3

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/dist/index.d.ts CHANGED
@@ -16,38 +16,5 @@ export default function createSmitheryServer(opts?: {
16
16
  GOOGLE_CLIENT_SECRET?: string;
17
17
  GOOGLE_REFRESH_TOKEN?: string;
18
18
  };
19
- }): import("@modelcontextprotocol/sdk/server").Server<{
20
- method: string;
21
- params?: {
22
- [x: string]: unknown;
23
- _meta?: {
24
- [x: string]: unknown;
25
- progressToken?: string | number | undefined;
26
- "io.modelcontextprotocol/related-task"?: {
27
- taskId: string;
28
- } | undefined;
29
- } | undefined;
30
- } | undefined;
31
- }, {
32
- method: string;
33
- params?: {
34
- [x: string]: unknown;
35
- _meta?: {
36
- [x: string]: unknown;
37
- progressToken?: string | number | undefined;
38
- "io.modelcontextprotocol/related-task"?: {
39
- taskId: string;
40
- } | undefined;
41
- } | undefined;
42
- } | undefined;
43
- }, {
44
- [x: string]: unknown;
45
- _meta?: {
46
- [x: string]: unknown;
47
- progressToken?: string | number | undefined;
48
- "io.modelcontextprotocol/related-task"?: {
49
- taskId: string;
50
- } | undefined;
51
- } | undefined;
52
- }>;
19
+ }): import("@modelcontextprotocol/sdk/server/mcp.js").McpServer;
53
20
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;;;;;GAUG;AA2JH,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,IAAI,CAAC,EAAE;IAClD,MAAM,CAAC,EAAE;QACP,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,oBAAoB,CAAC,EAAE,MAAM,CAAC;QAC9B,oBAAoB,CAAC,EAAE,MAAM,CAAC;KAC/B,CAAC;CACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAMA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;;;;;GAUG;AA2JH,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,IAAI,CAAC,EAAE;IAClD,MAAM,CAAC,EAAE;QACP,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,oBAAoB,CAAC,EAAE,MAAM,CAAC;QAC9B,oBAAoB,CAAC,EAAE,MAAM,CAAC;KAC/B,CAAC;CACH,+DAMA"}
package/dist/server.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Shared MCP Server — used by both Node.js (index.ts) and CF Worker (worker.ts)
3
3
  */
4
- import { Server } from '@modelcontextprotocol/sdk/server/index.js';
4
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
5
5
  import { GmailClient } from './gmail-client.js';
6
6
  export interface GmailMcpConfig {
7
7
  clientId: string;
@@ -9,5 +9,5 @@ export interface GmailMcpConfig {
9
9
  refreshToken: string;
10
10
  }
11
11
  export declare function handleToolCall(toolName: string, args: Record<string, unknown>, client: GmailClient): Promise<import("./types.js").MessageList> | Promise<import("./types.js").Message> | Promise<void> | Promise<import("./types.js").Attachment> | Promise<import("./types.js").DraftList> | Promise<import("./types.js").Draft> | Promise<import("./types.js").LabelList> | Promise<import("./types.js").Label> | Promise<import("./types.js").ThreadList> | Promise<import("./types.js").Thread> | Promise<import("./types.js").Profile> | Promise<import("./types.js").VacationSettings>;
12
- export declare function createServer(config?: GmailMcpConfig): Server;
12
+ export declare function createServer(config?: GmailMcpConfig): McpServer;
13
13
  //# sourceMappingURL=server.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AASnE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,MAAM,EAAE,WAAW,2dAoKpB;AAED,wBAAgB,YAAY,CAAC,MAAM,CAAC,EAAE,cAAc,GAAG,MAAM,CAwL5D"}
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,MAAM,EAAE,WAAW,2dAoKpB;AAED,wBAAgB,YAAY,CAAC,MAAM,CAAC,EAAE,cAAc,aA2KnD"}
package/dist/server.js CHANGED
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * Shared MCP Server — used by both Node.js (index.ts) and CF Worker (worker.ts)
3
3
  */
4
- import { Server } from '@modelcontextprotocol/sdk/server/index.js';
5
- import { CallToolRequestSchema, ListToolsRequestSchema, ListPromptsRequestSchema, GetPromptRequestSchema, ListResourcesRequestSchema, ReadResourceRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
4
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
5
+ import { ListToolsRequestSchema } from '@modelcontextprotocol/sdk/types.js';
6
6
  import { GmailClient } from './gmail-client.js';
7
7
  import { TOOLS } from './tools.js';
8
8
  export function handleToolCall(toolName, args, client) {
@@ -165,30 +165,23 @@ export function handleToolCall(toolName, args, client) {
165
165
  }
166
166
  }
167
167
  export function createServer(config) {
168
- const server = new Server({ name: 'gmail-mcp', version: '1.0.0' }, { capabilities: { tools: {}, prompts: {}, resources: {} } });
168
+ const server = new McpServer({
169
+ name: 'gmail-mcp',
170
+ version: '1.0.0',
171
+ });
169
172
  let client = null;
170
- // List available tools
171
- server.setRequestHandler(ListToolsRequestSchema, async () => ({
172
- tools: TOOLS.map(tool => {
173
- const hasProperties = Object.keys(tool.inputSchema.properties).length > 0;
174
- return {
175
- name: tool.name,
176
- description: tool.description,
177
- ...(hasProperties ? { inputSchema: tool.inputSchema } : {}),
178
- annotations: tool.annotations,
179
- };
180
- }),
181
- }));
182
- // Handle tool calls
183
- server.setRequestHandler(CallToolRequestSchema, async (request) => {
184
- const { name, arguments: args } = request.params;
185
- try {
173
+ for (const tool of TOOLS) {
174
+ server.registerTool(tool.name, {
175
+ description: tool.description,
176
+ inputSchema: tool.inputSchema,
177
+ annotations: tool.annotations,
178
+ }, async (args) => {
186
179
  const clientId = config?.clientId ||
187
- args?.GOOGLE_CLIENT_ID;
180
+ args.GOOGLE_CLIENT_ID;
188
181
  const clientSecret = config?.clientSecret ||
189
- args?.GOOGLE_CLIENT_SECRET;
182
+ args.GOOGLE_CLIENT_SECRET;
190
183
  const refreshToken = config?.refreshToken ||
191
- args?.GOOGLE_REFRESH_TOKEN;
184
+ args.GOOGLE_REFRESH_TOKEN;
192
185
  if (!clientId || !clientSecret || !refreshToken) {
193
186
  return {
194
187
  content: [{ type: 'text', text: 'Error: GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET, and GOOGLE_REFRESH_TOKEN are all required.' }],
@@ -198,133 +191,120 @@ export function createServer(config) {
198
191
  if (!client || config?.clientId !== clientId) {
199
192
  client = new GmailClient({ clientId, clientSecret, refreshToken });
200
193
  }
201
- const result = await handleToolCall(name, args || {}, client);
202
- const text = result === undefined ? '{"success": true}' : JSON.stringify(result, null, 2);
203
- return {
204
- content: [{ type: 'text', text }],
205
- isError: false,
206
- };
207
- }
208
- catch (error) {
209
- return {
210
- content: [{ type: 'text', text: `Error: ${error instanceof Error ? error.message : String(error)}` }],
211
- isError: true,
212
- };
213
- }
214
- });
215
- // List prompts
216
- server.setRequestHandler(ListPromptsRequestSchema, async () => ({
217
- prompts: [
218
- { name: 'compose-and-send', description: 'Guide for composing and sending emails, managing drafts' },
219
- { name: 'search-and-organize', description: 'Guide for searching emails, managing labels, and organizing the mailbox' },
220
- ],
194
+ try {
195
+ const result = await handleToolCall(tool.name, args, client);
196
+ const text = result === undefined ? '{"success": true}' : JSON.stringify(result, null, 2);
197
+ return {
198
+ content: [{ type: 'text', text }],
199
+ isError: false,
200
+ };
201
+ }
202
+ catch (error) {
203
+ return {
204
+ content: [{ type: 'text', text: `Error: ${error instanceof Error ? error.message : String(error)}` }],
205
+ isError: true,
206
+ };
207
+ }
208
+ });
209
+ }
210
+ // Register prompts
211
+ server.prompt('compose-and-send', 'Guide for composing and sending emails, managing drafts', async () => ({
212
+ messages: [{
213
+ role: 'user',
214
+ content: {
215
+ type: 'text',
216
+ text: [
217
+ 'You are a Gmail email assistant.',
218
+ '',
219
+ 'Sending emails:',
220
+ '1. **Send directly** — gmail_send_message with to, subject, body',
221
+ '2. **HTML emails** — Include html parameter for rich formatting',
222
+ '3. **Reply to thread** — Set thread_id, in_reply_to (Message-ID header), and references',
223
+ '4. **CC/BCC** — Comma-separate multiple addresses',
224
+ '',
225
+ 'Working with drafts:',
226
+ '1. **Create draft** — gmail_create_draft (same params as send)',
227
+ '2. **Update draft** — gmail_update_draft replaces the entire draft',
228
+ '3. **Send draft** — gmail_send_draft with the draft ID',
229
+ '4. **List drafts** — gmail_list_drafts to see all drafts',
230
+ '',
231
+ 'Tips:',
232
+ '- For replies, always get the original message first to extract Message-ID and thread_id',
233
+ '- Use gmail_get_thread to see the full conversation before replying',
234
+ '- HTML body is sent alongside plain text as multipart/alternative',
235
+ ].join('\n'),
236
+ },
237
+ }],
221
238
  }));
222
- // Get prompt
223
- server.setRequestHandler(GetPromptRequestSchema, async (request) => {
224
- const { name } = request.params;
225
- if (name === 'compose-and-send') {
226
- return {
227
- messages: [{
228
- role: 'user',
229
- content: {
230
- type: 'text',
231
- text: [
232
- 'You are a Gmail email assistant.',
233
- '',
234
- 'Sending emails:',
235
- '1. **Send directly** gmail_send_message with to, subject, body',
236
- '2. **HTML emails** Include html parameter for rich formatting',
237
- '3. **Reply to thread**Set thread_id, in_reply_to (Message-ID header), and references',
238
- '4. **CC/BCC**Comma-separate multiple addresses',
239
- '',
240
- 'Working with drafts:',
241
- '1. **Create draft** — gmail_create_draft (same params as send)',
242
- '2. **Update draft** — gmail_update_draft replaces the entire draft',
243
- '3. **Send draft** — gmail_send_draft with the draft ID',
244
- '4. **List drafts** — gmail_list_drafts to see all drafts',
245
- '',
246
- 'Tips:',
247
- '- For replies, always get the original message first to extract Message-ID and thread_id',
248
- '- Use gmail_get_thread to see the full conversation before replying',
249
- '- HTML body is sent alongside plain text as multipart/alternative',
250
- ].join('\n'),
251
- },
252
- }],
253
- };
254
- }
255
- if (name === 'search-and-organize') {
256
- return {
257
- messages: [{
258
- role: 'user',
259
- content: {
260
- type: 'text',
261
- text: [
262
- 'You are a Gmail organization assistant.',
263
- '',
264
- 'Search syntax (q parameter):',
265
- '- from:user@example.com — Messages from a sender',
266
- '- to:user@example.com — Messages to a recipient',
267
- '- subject:"meeting notes" — Subject contains text',
268
- '- has:attachment — Messages with attachments',
269
- '- is:unread / is:starred / is:important',
270
- '- label:custom-label — Messages with a specific label',
271
- '- after:2026/01/01 / before:2026/12/31 — Date range',
272
- '- newer_than:2d / older_than:1y — Relative dates',
273
- '- filename:pdf — Attachments by type',
274
- '- Combine: "from:boss@company.com has:attachment is:unread"',
275
- '',
276
- 'Organizing with labels:',
277
- '1. **List labels** — gmail_list_labels to see all labels',
278
- '2. **Create label** — gmail_create_label with nested support ("Projects/Active")',
279
- '3. **Apply labels** — gmail_modify_message to add/remove labels',
280
- '4. **Mark as read** — Remove "UNREAD" label',
281
- '5. **Star message** — Add "STARRED" label',
282
- '6. **Batch operations** — gmail_batch_modify for bulk label changes',
283
- '',
284
- 'System labels: INBOX, SENT, DRAFT, SPAM, TRASH, UNREAD, STARRED, IMPORTANT, CATEGORY_PERSONAL, CATEGORY_SOCIAL, CATEGORY_PROMOTIONS, CATEGORY_UPDATES, CATEGORY_FORUMS',
285
- ].join('\n'),
286
- },
287
- }],
288
- };
289
- }
290
- throw new Error(`Unknown prompt: ${name}`);
291
- });
292
- // List resources
293
- server.setRequestHandler(ListResourcesRequestSchema, async () => ({
294
- resources: [{
239
+ server.prompt('search-and-organize', 'Guide for searching emails, managing labels, and organizing the mailbox', async () => ({
240
+ messages: [{
241
+ role: 'user',
242
+ content: {
243
+ type: 'text',
244
+ text: [
245
+ 'You are a Gmail organization assistant.',
246
+ '',
247
+ 'Search syntax (q parameter):',
248
+ '- from:user@example.com — Messages from a sender',
249
+ '- to:user@example.com Messages to a recipient',
250
+ '- subject:"meeting notes" — Subject contains text',
251
+ '- has:attachment — Messages with attachments',
252
+ '- is:unread / is:starred / is:important',
253
+ '- label:custom-labelMessages with a specific label',
254
+ '- after:2026/01/01 / before:2026/12/31Date range',
255
+ '- newer_than:2d / older_than:1y Relative dates',
256
+ '- filename:pdf — Attachments by type',
257
+ '- Combine: "from:boss@company.com has:attachment is:unread"',
258
+ '',
259
+ 'Organizing with labels:',
260
+ '1. **List labels** — gmail_list_labels to see all labels',
261
+ '2. **Create label** — gmail_create_label with nested support ("Projects/Active")',
262
+ '3. **Apply labels** — gmail_modify_message to add/remove labels',
263
+ '4. **Mark as read** — Remove "UNREAD" label',
264
+ '5. **Star message** Add "STARRED" label',
265
+ '6. **Batch operations** gmail_batch_modify for bulk label changes',
266
+ '',
267
+ 'System labels: INBOX, SENT, DRAFT, SPAM, TRASH, UNREAD, STARRED, IMPORTANT, CATEGORY_PERSONAL, CATEGORY_SOCIAL, CATEGORY_PROMOTIONS, CATEGORY_UPDATES, CATEGORY_FORUMS',
268
+ ].join('\n'),
269
+ },
270
+ }],
271
+ }));
272
+ // Register resource
273
+ server.resource('server-info', 'gmail://server-info', {
274
+ description: 'Connection status and available tools for this Gmail MCP server',
275
+ mimeType: 'application/json',
276
+ }, async () => ({
277
+ contents: [{
295
278
  uri: 'gmail://server-info',
296
- name: 'server-info',
297
- description: 'Connection status and available tools for this Gmail MCP server',
298
279
  mimeType: 'application/json',
280
+ text: JSON.stringify({
281
+ name: 'gmail-mcp',
282
+ version: '1.0.0',
283
+ connected: !!config,
284
+ has_oauth: !!(config?.clientId),
285
+ tools_available: TOOLS.length,
286
+ tool_categories: {
287
+ messages: 10,
288
+ drafts: 6,
289
+ labels: 5,
290
+ threads: 5,
291
+ settings: 2,
292
+ },
293
+ }, null, 2),
299
294
  }],
300
295
  }));
301
- // Read resource
302
- server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
303
- const { uri } = request.params;
304
- if (uri === 'gmail://server-info') {
296
+ // Override tools/list handler to return raw JSON Schema with property descriptions
297
+ server.server.setRequestHandler(ListToolsRequestSchema, () => ({
298
+ tools: TOOLS.map(tool => {
299
+ const hasProperties = Object.keys(tool.inputSchema.properties).length > 0;
305
300
  return {
306
- contents: [{
307
- uri: 'gmail://server-info',
308
- mimeType: 'application/json',
309
- text: JSON.stringify({
310
- name: 'gmail-mcp',
311
- version: '1.0.0',
312
- connected: !!config,
313
- has_oauth: !!(config?.clientId),
314
- tools_available: TOOLS.length,
315
- tool_categories: {
316
- messages: 10,
317
- drafts: 6,
318
- labels: 5,
319
- threads: 5,
320
- settings: 2,
321
- },
322
- }, null, 2),
323
- }],
301
+ name: tool.name,
302
+ description: tool.description,
303
+ ...(hasProperties ? { inputSchema: tool.inputSchema } : {}),
304
+ annotations: tool.annotations,
324
305
  };
325
- }
326
- throw new Error(`Unknown resource: ${uri}`);
327
- });
306
+ }),
307
+ }));
328
308
  return server;
329
309
  }
330
310
  //# sourceMappingURL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AI,EAAE,IAAI,CAAC,IAAI;gBACf,WAAW,EAAE,IAAI,CAAC,WAAW;gBAC7B,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC3D,WAAW,EAAE,IAAI,CAAC,WAAW;aAC9B,CAAC;QACJ,CAAC,CAAC;KACH,CAAC,CAAC,CAAC;IAEJ,OAAO,MAAM,CAAC;AAChB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@node2flow/gmail-mcp",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "MCP server for Gmail — send, search, read, organize emails and manage labels through 28 tools",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
package/src/server.ts CHANGED
@@ -2,15 +2,8 @@
2
2
  * Shared MCP Server — used by both Node.js (index.ts) and CF Worker (worker.ts)
3
3
  */
4
4
 
5
- import { Server } from '@modelcontextprotocol/sdk/server/index.js';
6
- import {
7
- CallToolRequestSchema,
8
- ListToolsRequestSchema,
9
- ListPromptsRequestSchema,
10
- GetPromptRequestSchema,
11
- ListResourcesRequestSchema,
12
- ReadResourceRequestSchema,
13
- } from '@modelcontextprotocol/sdk/types.js';
5
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
6
+ import { ListToolsRequestSchema } from '@modelcontextprotocol/sdk/types.js';
14
7
  import { GmailClient } from './gmail-client.js';
15
8
  import { TOOLS } from './tools.js';
16
9
 
@@ -189,188 +182,175 @@ export function handleToolCall(
189
182
  }
190
183
  }
191
184
 
192
- export function createServer(config?: GmailMcpConfig): Server {
193
- const server = new Server(
194
- { name: 'gmail-mcp', version: '1.0.0' },
195
- { capabilities: { tools: {}, prompts: {}, resources: {} } }
196
- );
185
+ export function createServer(config?: GmailMcpConfig) {
186
+ const server = new McpServer({
187
+ name: 'gmail-mcp',
188
+ version: '1.0.0',
189
+ });
197
190
 
198
191
  let client: GmailClient | null = null;
199
192
 
200
- // List available tools
201
- server.setRequestHandler(ListToolsRequestSchema, async () => ({
202
- tools: TOOLS.map(tool => {
203
- const hasProperties = Object.keys(tool.inputSchema.properties).length > 0;
204
- return {
205
- name: tool.name,
193
+ for (const tool of TOOLS) {
194
+ server.registerTool(
195
+ tool.name,
196
+ {
206
197
  description: tool.description,
207
- ...(hasProperties ? { inputSchema: tool.inputSchema } : {}),
198
+ inputSchema: tool.inputSchema as any,
208
199
  annotations: tool.annotations,
209
- };
210
- }),
211
- }));
200
+ },
201
+ async (args: Record<string, unknown>) => {
202
+ const clientId =
203
+ config?.clientId ||
204
+ (args as Record<string, unknown>).GOOGLE_CLIENT_ID as string;
205
+ const clientSecret =
206
+ config?.clientSecret ||
207
+ (args as Record<string, unknown>).GOOGLE_CLIENT_SECRET as string;
208
+ const refreshToken =
209
+ config?.refreshToken ||
210
+ (args as Record<string, unknown>).GOOGLE_REFRESH_TOKEN as string;
212
211
 
213
- // Handle tool calls
214
- server.setRequestHandler(CallToolRequestSchema, async (request) => {
215
- const { name, arguments: args } = request.params;
212
+ if (!clientId || !clientSecret || !refreshToken) {
213
+ return {
214
+ content: [{ type: 'text' as const, text: 'Error: GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET, and GOOGLE_REFRESH_TOKEN are all required.' }],
215
+ isError: true,
216
+ };
217
+ }
216
218
 
217
- try {
218
- const clientId =
219
- config?.clientId ||
220
- (args as Record<string, unknown>)?.GOOGLE_CLIENT_ID as string;
221
- const clientSecret =
222
- config?.clientSecret ||
223
- (args as Record<string, unknown>)?.GOOGLE_CLIENT_SECRET as string;
224
- const refreshToken =
225
- config?.refreshToken ||
226
- (args as Record<string, unknown>)?.GOOGLE_REFRESH_TOKEN as string;
219
+ if (!client || config?.clientId !== clientId) {
220
+ client = new GmailClient({ clientId, clientSecret, refreshToken });
221
+ }
227
222
 
228
- if (!clientId || !clientSecret || !refreshToken) {
229
- return {
230
- content: [{ type: 'text' as const, text: 'Error: GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET, and GOOGLE_REFRESH_TOKEN are all required.' }],
231
- isError: true,
232
- };
223
+ try {
224
+ const result = await handleToolCall(tool.name, args, client);
225
+ const text = result === undefined ? '{"success": true}' : JSON.stringify(result, null, 2);
226
+ return {
227
+ content: [{ type: 'text' as const, text }],
228
+ isError: false,
229
+ };
230
+ } catch (error) {
231
+ return {
232
+ content: [{ type: 'text' as const, text: `Error: ${error instanceof Error ? error.message : String(error)}` }],
233
+ isError: true,
234
+ };
235
+ }
233
236
  }
237
+ );
238
+ }
234
239
 
235
- if (!client || config?.clientId !== clientId) {
236
- client = new GmailClient({ clientId, clientSecret, refreshToken });
237
- }
238
-
239
- const result = await handleToolCall(name, args || {}, client);
240
- const text = result === undefined ? '{"success": true}' : JSON.stringify(result, null, 2);
241
- return {
242
- content: [{ type: 'text' as const, text }],
243
- isError: false,
244
- };
245
- } catch (error) {
246
- return {
247
- content: [{ type: 'text' as const, text: `Error: ${error instanceof Error ? error.message : String(error)}` }],
248
- isError: true,
249
- };
250
- }
251
- });
252
-
253
- // List prompts
254
- server.setRequestHandler(ListPromptsRequestSchema, async () => ({
255
- prompts: [
256
- { name: 'compose-and-send', description: 'Guide for composing and sending emails, managing drafts' },
257
- { name: 'search-and-organize', description: 'Guide for searching emails, managing labels, and organizing the mailbox' },
258
- ],
259
- }));
260
-
261
- // Get prompt
262
- server.setRequestHandler(GetPromptRequestSchema, async (request) => {
263
- const { name } = request.params;
264
-
265
- if (name === 'compose-and-send') {
266
- return {
267
- messages: [{
268
- role: 'user' as const,
269
- content: {
270
- type: 'text' as const,
271
- text: [
272
- 'You are a Gmail email assistant.',
273
- '',
274
- 'Sending emails:',
275
- '1. **Send directly** — gmail_send_message with to, subject, body',
276
- '2. **HTML emails** — Include html parameter for rich formatting',
277
- '3. **Reply to thread** — Set thread_id, in_reply_to (Message-ID header), and references',
278
- '4. **CC/BCC** — Comma-separate multiple addresses',
279
- '',
280
- 'Working with drafts:',
281
- '1. **Create draft** — gmail_create_draft (same params as send)',
282
- '2. **Update draft** — gmail_update_draft replaces the entire draft',
283
- '3. **Send draft** — gmail_send_draft with the draft ID',
284
- '4. **List drafts** — gmail_list_drafts to see all drafts',
285
- '',
286
- 'Tips:',
287
- '- For replies, always get the original message first to extract Message-ID and thread_id',
288
- '- Use gmail_get_thread to see the full conversation before replying',
289
- '- HTML body is sent alongside plain text as multipart/alternative',
290
- ].join('\n'),
291
- },
292
- }],
293
- };
294
- }
295
-
296
- if (name === 'search-and-organize') {
297
- return {
298
- messages: [{
299
- role: 'user' as const,
300
- content: {
301
- type: 'text' as const,
302
- text: [
303
- 'You are a Gmail organization assistant.',
304
- '',
305
- 'Search syntax (q parameter):',
306
- '- from:user@example.com — Messages from a sender',
307
- '- to:user@example.com — Messages to a recipient',
308
- '- subject:"meeting notes" — Subject contains text',
309
- '- has:attachment — Messages with attachments',
310
- '- is:unread / is:starred / is:important',
311
- '- label:custom-label — Messages with a specific label',
312
- '- after:2026/01/01 / before:2026/12/31 — Date range',
313
- '- newer_than:2d / older_than:1y — Relative dates',
314
- '- filename:pdf — Attachments by type',
315
- '- Combine: "from:boss@company.com has:attachment is:unread"',
316
- '',
317
- 'Organizing with labels:',
318
- '1. **List labels** — gmail_list_labels to see all labels',
319
- '2. **Create label** — gmail_create_label with nested support ("Projects/Active")',
320
- '3. **Apply labels** — gmail_modify_message to add/remove labels',
321
- '4. **Mark as read** — Remove "UNREAD" label',
322
- '5. **Star message** — Add "STARRED" label',
323
- '6. **Batch operations** — gmail_batch_modify for bulk label changes',
324
- '',
325
- 'System labels: INBOX, SENT, DRAFT, SPAM, TRASH, UNREAD, STARRED, IMPORTANT, CATEGORY_PERSONAL, CATEGORY_SOCIAL, CATEGORY_PROMOTIONS, CATEGORY_UPDATES, CATEGORY_FORUMS',
326
- ].join('\n'),
327
- },
328
- }],
329
- };
330
- }
240
+ // Register prompts
241
+ server.prompt(
242
+ 'compose-and-send',
243
+ 'Guide for composing and sending emails, managing drafts',
244
+ async () => ({
245
+ messages: [{
246
+ role: 'user' as const,
247
+ content: {
248
+ type: 'text' as const,
249
+ text: [
250
+ 'You are a Gmail email assistant.',
251
+ '',
252
+ 'Sending emails:',
253
+ '1. **Send directly** — gmail_send_message with to, subject, body',
254
+ '2. **HTML emails** — Include html parameter for rich formatting',
255
+ '3. **Reply to thread** — Set thread_id, in_reply_to (Message-ID header), and references',
256
+ '4. **CC/BCC** — Comma-separate multiple addresses',
257
+ '',
258
+ 'Working with drafts:',
259
+ '1. **Create draft** — gmail_create_draft (same params as send)',
260
+ '2. **Update draft** — gmail_update_draft replaces the entire draft',
261
+ '3. **Send draft** gmail_send_draft with the draft ID',
262
+ '4. **List drafts** gmail_list_drafts to see all drafts',
263
+ '',
264
+ 'Tips:',
265
+ '- For replies, always get the original message first to extract Message-ID and thread_id',
266
+ '- Use gmail_get_thread to see the full conversation before replying',
267
+ '- HTML body is sent alongside plain text as multipart/alternative',
268
+ ].join('\n'),
269
+ },
270
+ }],
271
+ }),
272
+ );
331
273
 
332
- throw new Error(`Unknown prompt: ${name}`);
333
- });
274
+ server.prompt(
275
+ 'search-and-organize',
276
+ 'Guide for searching emails, managing labels, and organizing the mailbox',
277
+ async () => ({
278
+ messages: [{
279
+ role: 'user' as const,
280
+ content: {
281
+ type: 'text' as const,
282
+ text: [
283
+ 'You are a Gmail organization assistant.',
284
+ '',
285
+ 'Search syntax (q parameter):',
286
+ '- from:user@example.com — Messages from a sender',
287
+ '- to:user@example.com — Messages to a recipient',
288
+ '- subject:"meeting notes" — Subject contains text',
289
+ '- has:attachment — Messages with attachments',
290
+ '- is:unread / is:starred / is:important',
291
+ '- label:custom-label — Messages with a specific label',
292
+ '- after:2026/01/01 / before:2026/12/31 — Date range',
293
+ '- newer_than:2d / older_than:1y — Relative dates',
294
+ '- filename:pdf — Attachments by type',
295
+ '- Combine: "from:boss@company.com has:attachment is:unread"',
296
+ '',
297
+ 'Organizing with labels:',
298
+ '1. **List labels** — gmail_list_labels to see all labels',
299
+ '2. **Create label** — gmail_create_label with nested support ("Projects/Active")',
300
+ '3. **Apply labels** — gmail_modify_message to add/remove labels',
301
+ '4. **Mark as read** — Remove "UNREAD" label',
302
+ '5. **Star message** — Add "STARRED" label',
303
+ '6. **Batch operations** — gmail_batch_modify for bulk label changes',
304
+ '',
305
+ 'System labels: INBOX, SENT, DRAFT, SPAM, TRASH, UNREAD, STARRED, IMPORTANT, CATEGORY_PERSONAL, CATEGORY_SOCIAL, CATEGORY_PROMOTIONS, CATEGORY_UPDATES, CATEGORY_FORUMS',
306
+ ].join('\n'),
307
+ },
308
+ }],
309
+ }),
310
+ );
334
311
 
335
- // List resources
336
- server.setRequestHandler(ListResourcesRequestSchema, async () => ({
337
- resources: [{
338
- uri: 'gmail://server-info',
339
- name: 'server-info',
312
+ // Register resource
313
+ server.resource(
314
+ 'server-info',
315
+ 'gmail://server-info',
316
+ {
340
317
  description: 'Connection status and available tools for this Gmail MCP server',
341
318
  mimeType: 'application/json',
342
- }],
343
- }));
344
-
345
- // Read resource
346
- server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
347
- const { uri } = request.params;
319
+ },
320
+ async () => ({
321
+ contents: [{
322
+ uri: 'gmail://server-info',
323
+ mimeType: 'application/json',
324
+ text: JSON.stringify({
325
+ name: 'gmail-mcp',
326
+ version: '1.0.0',
327
+ connected: !!config,
328
+ has_oauth: !!(config?.clientId),
329
+ tools_available: TOOLS.length,
330
+ tool_categories: {
331
+ messages: 10,
332
+ drafts: 6,
333
+ labels: 5,
334
+ threads: 5,
335
+ settings: 2,
336
+ },
337
+ }, null, 2),
338
+ }],
339
+ }),
340
+ );
348
341
 
349
- if (uri === 'gmail://server-info') {
342
+ // Override tools/list handler to return raw JSON Schema with property descriptions
343
+ (server as any).server.setRequestHandler(ListToolsRequestSchema, () => ({
344
+ tools: TOOLS.map(tool => {
345
+ const hasProperties = Object.keys(tool.inputSchema.properties).length > 0;
350
346
  return {
351
- contents: [{
352
- uri: 'gmail://server-info',
353
- mimeType: 'application/json',
354
- text: JSON.stringify({
355
- name: 'gmail-mcp',
356
- version: '1.0.0',
357
- connected: !!config,
358
- has_oauth: !!(config?.clientId),
359
- tools_available: TOOLS.length,
360
- tool_categories: {
361
- messages: 10,
362
- drafts: 6,
363
- labels: 5,
364
- threads: 5,
365
- settings: 2,
366
- },
367
- }, null, 2),
368
- }],
347
+ name: tool.name,
348
+ description: tool.description,
349
+ ...(hasProperties ? { inputSchema: tool.inputSchema } : {}),
350
+ annotations: tool.annotations,
369
351
  };
370
- }
371
-
372
- throw new Error(`Unknown resource: ${uri}`);
373
- });
352
+ }),
353
+ }));
374
354
 
375
355
  return server;
376
356
  }