gmail-reader-mcp 0.0.0-stage → 1.0.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.
Files changed (107) hide show
  1. package/LICENSE +674 -0
  2. package/README.md +84 -2
  3. package/dist/auth.d.ts +36 -0
  4. package/dist/auth.js +328 -0
  5. package/dist/files.d.ts +8 -0
  6. package/dist/files.js +32 -0
  7. package/dist/format.d.ts +10 -0
  8. package/dist/format.js +53 -0
  9. package/dist/mail.d.ts +80 -0
  10. package/dist/mail.js +265 -0
  11. package/dist/mcp-server.d.ts +2 -0
  12. package/dist/mcp-server.js +37 -0
  13. package/dist/text.d.ts +8 -0
  14. package/dist/text.js +70 -0
  15. package/dist/tools/authenticate/definition.d.ts +8 -0
  16. package/dist/tools/authenticate/definition.js +19 -0
  17. package/dist/tools/authenticate/index.d.ts +2 -0
  18. package/dist/tools/authenticate/index.js +10 -0
  19. package/dist/tools/authenticate/key.d.ts +1 -0
  20. package/dist/tools/authenticate/key.js +4 -0
  21. package/dist/tools/authenticate/schema.d.ts +3 -0
  22. package/dist/tools/authenticate/schema.js +5 -0
  23. package/dist/tools/download-attachment/definition.d.ts +8 -0
  24. package/dist/tools/download-attachment/definition.js +20 -0
  25. package/dist/tools/download-attachment/index.d.ts +2 -0
  26. package/dist/tools/download-attachment/index.js +10 -0
  27. package/dist/tools/download-attachment/key.d.ts +1 -0
  28. package/dist/tools/download-attachment/key.js +4 -0
  29. package/dist/tools/download-attachment/schema.d.ts +7 -0
  30. package/dist/tools/download-attachment/schema.js +14 -0
  31. package/dist/tools/download-attachments/definition.d.ts +8 -0
  32. package/dist/tools/download-attachments/definition.js +50 -0
  33. package/dist/tools/download-attachments/index.d.ts +2 -0
  34. package/dist/tools/download-attachments/index.js +10 -0
  35. package/dist/tools/download-attachments/key.d.ts +1 -0
  36. package/dist/tools/download-attachments/key.js +4 -0
  37. package/dist/tools/download-attachments/schema.d.ts +8 -0
  38. package/dist/tools/download-attachments/schema.js +20 -0
  39. package/dist/tools/get-email/definition.d.ts +8 -0
  40. package/dist/tools/get-email/definition.js +10 -0
  41. package/dist/tools/get-email/index.d.ts +2 -0
  42. package/dist/tools/get-email/index.js +10 -0
  43. package/dist/tools/get-email/key.d.ts +1 -0
  44. package/dist/tools/get-email/key.js +4 -0
  45. package/dist/tools/get-email/schema.d.ts +5 -0
  46. package/dist/tools/get-email/schema.js +9 -0
  47. package/dist/tools/get-emails/definition.d.ts +8 -0
  48. package/dist/tools/get-emails/definition.js +16 -0
  49. package/dist/tools/get-emails/index.d.ts +2 -0
  50. package/dist/tools/get-emails/index.js +10 -0
  51. package/dist/tools/get-emails/key.d.ts +1 -0
  52. package/dist/tools/get-emails/key.js +4 -0
  53. package/dist/tools/get-emails/schema.d.ts +5 -0
  54. package/dist/tools/get-emails/schema.js +11 -0
  55. package/dist/tools/get-thread/definition.d.ts +8 -0
  56. package/dist/tools/get-thread/definition.js +15 -0
  57. package/dist/tools/get-thread/index.d.ts +2 -0
  58. package/dist/tools/get-thread/index.js +10 -0
  59. package/dist/tools/get-thread/key.d.ts +1 -0
  60. package/dist/tools/get-thread/key.js +4 -0
  61. package/dist/tools/get-thread/schema.d.ts +5 -0
  62. package/dist/tools/get-thread/schema.js +9 -0
  63. package/dist/tools/index.d.ts +2 -0
  64. package/dist/tools/index.js +27 -0
  65. package/dist/tools/list-attachments/definition.d.ts +8 -0
  66. package/dist/tools/list-attachments/definition.js +13 -0
  67. package/dist/tools/list-attachments/index.d.ts +2 -0
  68. package/dist/tools/list-attachments/index.js +10 -0
  69. package/dist/tools/list-attachments/key.d.ts +1 -0
  70. package/dist/tools/list-attachments/key.js +4 -0
  71. package/dist/tools/list-attachments/schema.d.ts +5 -0
  72. package/dist/tools/list-attachments/schema.js +9 -0
  73. package/dist/tools/list-emails/definition.d.ts +10 -0
  74. package/dist/tools/list-emails/definition.js +25 -0
  75. package/dist/tools/list-emails/index.d.ts +2 -0
  76. package/dist/tools/list-emails/index.js +10 -0
  77. package/dist/tools/list-emails/key.d.ts +1 -0
  78. package/dist/tools/list-emails/key.js +4 -0
  79. package/dist/tools/list-emails/schema.d.ts +8 -0
  80. package/dist/tools/list-emails/schema.js +27 -0
  81. package/dist/tools/list-labels/definition.d.ts +8 -0
  82. package/dist/tools/list-labels/definition.js +14 -0
  83. package/dist/tools/list-labels/index.d.ts +2 -0
  84. package/dist/tools/list-labels/index.js +10 -0
  85. package/dist/tools/list-labels/key.d.ts +1 -0
  86. package/dist/tools/list-labels/key.js +4 -0
  87. package/dist/tools/list-labels/schema.d.ts +3 -0
  88. package/dist/tools/list-labels/schema.js +5 -0
  89. package/dist/tools/search-emails/definition.d.ts +8 -0
  90. package/dist/tools/search-emails/definition.js +17 -0
  91. package/dist/tools/search-emails/index.d.ts +2 -0
  92. package/dist/tools/search-emails/index.js +10 -0
  93. package/dist/tools/search-emails/key.d.ts +1 -0
  94. package/dist/tools/search-emails/key.js +4 -0
  95. package/dist/tools/search-emails/schema.d.ts +8 -0
  96. package/dist/tools/search-emails/schema.js +27 -0
  97. package/dist/tools/sign-out/definition.d.ts +8 -0
  98. package/dist/tools/sign-out/definition.js +17 -0
  99. package/dist/tools/sign-out/index.d.ts +2 -0
  100. package/dist/tools/sign-out/index.js +10 -0
  101. package/dist/tools/sign-out/key.d.ts +1 -0
  102. package/dist/tools/sign-out/key.js +4 -0
  103. package/dist/tools/sign-out/schema.d.ts +3 -0
  104. package/dist/tools/sign-out/schema.js +5 -0
  105. package/dist/tools/wrap.d.ts +13 -0
  106. package/dist/tools/wrap.js +44 -0
  107. package/package.json +56 -4
@@ -0,0 +1,8 @@
1
+ import type { Input } from './schema.js';
2
+ export declare const description = "Get the full content of a specific email by its ID: headers, plain-text body (HTML-only emails are converted to text), and its attachment list. To fetch several emails at once use get_emails; for a whole conversation use get_thread.";
3
+ export declare function handler({ id }: Input): Promise<{
4
+ content: {
5
+ type: "text";
6
+ text: string;
7
+ }[];
8
+ }>;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.description = void 0;
4
+ exports.handler = handler;
5
+ const format_js_1 = require("../../format.js");
6
+ const mail_js_1 = require("../../mail.js");
7
+ exports.description = 'Get the full content of a specific email by its ID: headers, plain-text body (HTML-only emails are converted to text), and its attachment list. To fetch several emails at once use get_emails; for a whole conversation use get_thread.';
8
+ async function handler({ id }) {
9
+ return (0, format_js_1.text)((0, format_js_1.formatDetail)(await (0, mail_js_1.getEmail)(id)));
10
+ }
@@ -0,0 +1,2 @@
1
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ export declare function register(server: McpServer): void;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.register = register;
4
+ const wrap_js_1 = require("../wrap.js");
5
+ const definition_js_1 = require("./definition.js");
6
+ const key_js_1 = require("./key.js");
7
+ const schema_js_1 = require("./schema.js");
8
+ function register(server) {
9
+ server.registerTool(key_js_1.KEY, { description: definition_js_1.description, inputSchema: schema_js_1.schema }, (0, wrap_js_1.wrapHandler)(definition_js_1.handler));
10
+ }
@@ -0,0 +1 @@
1
+ export declare const KEY = "get_email";
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.KEY = void 0;
4
+ exports.KEY = 'get_email';
@@ -0,0 +1,5 @@
1
+ import { z } from 'zod';
2
+ export declare const schema: z.ZodObject<{
3
+ id: z.ZodString;
4
+ }, z.core.$strip>;
5
+ export type Input = z.infer<typeof schema>;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.schema = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.schema = zod_1.z.object({
6
+ id: zod_1.z
7
+ .string()
8
+ .describe('The email message ID (obtained from list_emails or search_emails)'),
9
+ });
@@ -0,0 +1,8 @@
1
+ import type { Input } from './schema.js';
2
+ export declare const description = "Get the full content of multiple emails by their IDs in one call (fetched concurrently). Much faster than calling get_email repeatedly. Returns headers, plain-text body, and attachment list for each.";
3
+ export declare function handler({ ids }: Input): Promise<{
4
+ content: {
5
+ type: "text";
6
+ text: string;
7
+ }[];
8
+ }>;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.description = void 0;
4
+ exports.handler = handler;
5
+ const format_js_1 = require("../../format.js");
6
+ const mail_js_1 = require("../../mail.js");
7
+ exports.description = 'Get the full content of multiple emails by their IDs in one call (fetched concurrently). Much faster than calling get_email repeatedly. Returns headers, plain-text body, and attachment list for each.';
8
+ async function handler({ ids }) {
9
+ const results = await (0, mail_js_1.getEmails)(ids);
10
+ return (0, format_js_1.text)(results
11
+ .map((r, i) => `===== [${i + 1}/${results.length}] =====\n` +
12
+ (r.ok
13
+ ? (0, format_js_1.formatDetail)(r.email)
14
+ : `Failed to fetch ${r.id}: ${r.error}`))
15
+ .join('\n\n'));
16
+ }
@@ -0,0 +1,2 @@
1
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ export declare function register(server: McpServer): void;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.register = register;
4
+ const wrap_js_1 = require("../wrap.js");
5
+ const definition_js_1 = require("./definition.js");
6
+ const key_js_1 = require("./key.js");
7
+ const schema_js_1 = require("./schema.js");
8
+ function register(server) {
9
+ server.registerTool(key_js_1.KEY, { description: definition_js_1.description, inputSchema: schema_js_1.schema }, (0, wrap_js_1.wrapHandler)(definition_js_1.handler));
10
+ }
@@ -0,0 +1 @@
1
+ export declare const KEY = "get_emails";
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.KEY = void 0;
4
+ exports.KEY = 'get_emails';
@@ -0,0 +1,5 @@
1
+ import { z } from 'zod';
2
+ export declare const schema: z.ZodObject<{
3
+ ids: z.ZodArray<z.ZodString>;
4
+ }, z.core.$strip>;
5
+ export type Input = z.infer<typeof schema>;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.schema = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.schema = zod_1.z.object({
6
+ ids: zod_1.z
7
+ .array(zod_1.z.string())
8
+ .min(1)
9
+ .max(50)
10
+ .describe('Email message IDs to fetch (from list_emails or search_emails). Max 50.'),
11
+ });
@@ -0,0 +1,8 @@
1
+ import type { Input } from './schema.js';
2
+ export declare const description = "Get every message of a Gmail conversation (thread) in chronological order, with full plain-text bodies and attachment lists.";
3
+ export declare function handler({ threadId }: Input): Promise<{
4
+ content: {
5
+ type: "text";
6
+ text: string;
7
+ }[];
8
+ }>;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.description = void 0;
4
+ exports.handler = handler;
5
+ const format_js_1 = require("../../format.js");
6
+ const mail_js_1 = require("../../mail.js");
7
+ exports.description = 'Get every message of a Gmail conversation (thread) in chronological order, with full plain-text bodies and attachment lists.';
8
+ async function handler({ threadId }) {
9
+ const messages = await (0, mail_js_1.getThread)(threadId);
10
+ if (messages.length === 0)
11
+ return (0, format_js_1.text)('Thread has no messages.');
12
+ return (0, format_js_1.text)(messages
13
+ .map((m, i) => `===== Message ${i + 1}/${messages.length} =====\n${(0, format_js_1.formatDetail)(m)}`)
14
+ .join('\n\n'));
15
+ }
@@ -0,0 +1,2 @@
1
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ export declare function register(server: McpServer): void;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.register = register;
4
+ const wrap_js_1 = require("../wrap.js");
5
+ const definition_js_1 = require("./definition.js");
6
+ const key_js_1 = require("./key.js");
7
+ const schema_js_1 = require("./schema.js");
8
+ function register(server) {
9
+ server.registerTool(key_js_1.KEY, { description: definition_js_1.description, inputSchema: schema_js_1.schema }, (0, wrap_js_1.wrapHandler)(definition_js_1.handler));
10
+ }
@@ -0,0 +1 @@
1
+ export declare const KEY = "get_thread";
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.KEY = void 0;
4
+ exports.KEY = 'get_thread';
@@ -0,0 +1,5 @@
1
+ import { z } from 'zod';
2
+ export declare const schema: z.ZodObject<{
3
+ threadId: z.ZodString;
4
+ }, z.core.$strip>;
5
+ export type Input = z.infer<typeof schema>;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.schema = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.schema = zod_1.z.object({
6
+ threadId: zod_1.z
7
+ .string()
8
+ .describe('The thread ID (the "Thread" field from list_emails, search_emails, or get_email)'),
9
+ });
@@ -0,0 +1,2 @@
1
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ export declare function registerAllTools(server: McpServer): void;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.registerAllTools = registerAllTools;
4
+ const index_js_1 = require("./authenticate/index.js");
5
+ const index_js_2 = require("./download-attachment/index.js");
6
+ const index_js_3 = require("./download-attachments/index.js");
7
+ const index_js_4 = require("./get-email/index.js");
8
+ const index_js_5 = require("./get-emails/index.js");
9
+ const index_js_6 = require("./get-thread/index.js");
10
+ const index_js_7 = require("./list-attachments/index.js");
11
+ const index_js_8 = require("./list-emails/index.js");
12
+ const index_js_9 = require("./list-labels/index.js");
13
+ const index_js_10 = require("./search-emails/index.js");
14
+ const index_js_11 = require("./sign-out/index.js");
15
+ function registerAllTools(server) {
16
+ (0, index_js_1.register)(server);
17
+ (0, index_js_11.register)(server);
18
+ (0, index_js_8.register)(server);
19
+ (0, index_js_10.register)(server);
20
+ (0, index_js_4.register)(server);
21
+ (0, index_js_5.register)(server);
22
+ (0, index_js_6.register)(server);
23
+ (0, index_js_9.register)(server);
24
+ (0, index_js_7.register)(server);
25
+ (0, index_js_2.register)(server);
26
+ (0, index_js_3.register)(server);
27
+ }
@@ -0,0 +1,8 @@
1
+ import type { Input } from './schema.js';
2
+ export declare const description = "List all attachments of a specific email. Returns each attachment's part ID, name, size, MIME type, and whether it is inline (embedded image/signature). Use download_attachment for one file, or download_attachments to save several (or all) in a single call.";
3
+ export declare function handler({ messageId }: Input): Promise<{
4
+ content: {
5
+ type: "text";
6
+ text: string;
7
+ }[];
8
+ }>;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.description = void 0;
4
+ exports.handler = handler;
5
+ const format_js_1 = require("../../format.js");
6
+ const mail_js_1 = require("../../mail.js");
7
+ exports.description = "List all attachments of a specific email. Returns each attachment's part ID, name, size, MIME type, and whether it is inline (embedded image/signature). Use download_attachment for one file, or download_attachments to save several (or all) in a single call.";
8
+ async function handler({ messageId }) {
9
+ const attachments = await (0, mail_js_1.listAttachments)(messageId);
10
+ if (attachments.length === 0)
11
+ return (0, format_js_1.text)('No attachments found.');
12
+ return (0, format_js_1.text)(attachments.map((a, i) => (0, format_js_1.formatAttachment)(a, i + 1)).join('\n\n'));
13
+ }
@@ -0,0 +1,2 @@
1
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ export declare function register(server: McpServer): void;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.register = register;
4
+ const wrap_js_1 = require("../wrap.js");
5
+ const definition_js_1 = require("./definition.js");
6
+ const key_js_1 = require("./key.js");
7
+ const schema_js_1 = require("./schema.js");
8
+ function register(server) {
9
+ server.registerTool(key_js_1.KEY, { description: definition_js_1.description, inputSchema: schema_js_1.schema }, (0, wrap_js_1.wrapHandler)(definition_js_1.handler));
10
+ }
@@ -0,0 +1 @@
1
+ export declare const KEY = "list_attachments";
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.KEY = void 0;
4
+ exports.KEY = 'list_attachments';
@@ -0,0 +1,5 @@
1
+ import { z } from 'zod';
2
+ export declare const schema: z.ZodObject<{
3
+ messageId: z.ZodString;
4
+ }, z.core.$strip>;
5
+ export type Input = z.infer<typeof schema>;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.schema = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.schema = zod_1.z.object({
6
+ messageId: zod_1.z
7
+ .string()
8
+ .describe('The email message ID (from list_emails or search_emails)'),
9
+ });
@@ -0,0 +1,10 @@
1
+ import { ListEmailsResult } from '../../mail.js';
2
+ import type { Input } from './schema.js';
3
+ export declare const description = "List emails in a Gmail label (default INBOX), newest first, optionally narrowed with a Gmail search query. Returns IDs, thread IDs, subject, sender, date, unread/attachment flags, and a snippet. Use pageToken to page through results.";
4
+ export declare function formatList({ emails, nextPageToken }: ListEmailsResult, emptyMessage: string): string;
5
+ export declare function handler({ label, query, maxResults, pageToken }: Input): Promise<{
6
+ content: {
7
+ type: "text";
8
+ text: string;
9
+ }[];
10
+ }>;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.description = void 0;
4
+ exports.formatList = formatList;
5
+ exports.handler = handler;
6
+ const format_js_1 = require("../../format.js");
7
+ const mail_js_1 = require("../../mail.js");
8
+ exports.description = 'List emails in a Gmail label (default INBOX), newest first, optionally narrowed with a Gmail search query. Returns IDs, thread IDs, subject, sender, date, unread/attachment flags, and a snippet. Use pageToken to page through results.';
9
+ function formatList({ emails, nextPageToken }, emptyMessage) {
10
+ if (emails.length === 0)
11
+ return emptyMessage;
12
+ const body = emails.map((m, i) => (0, format_js_1.formatSummary)(m, i + 1)).join('\n\n');
13
+ return nextPageToken
14
+ ? `${body}\n\n(More results exist. Use pageToken="${nextPageToken}" for the next page.)`
15
+ : body;
16
+ }
17
+ async function handler({ label, query, maxResults, pageToken }) {
18
+ const result = await (0, mail_js_1.listEmails)({
19
+ labelIds: label ? [label] : undefined,
20
+ query,
21
+ maxResults,
22
+ pageToken,
23
+ });
24
+ return (0, format_js_1.text)(formatList(result, 'No emails found.'));
25
+ }
@@ -0,0 +1,2 @@
1
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ export declare function register(server: McpServer): void;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.register = register;
4
+ const wrap_js_1 = require("../wrap.js");
5
+ const definition_js_1 = require("./definition.js");
6
+ const key_js_1 = require("./key.js");
7
+ const schema_js_1 = require("./schema.js");
8
+ function register(server) {
9
+ server.registerTool(key_js_1.KEY, { description: definition_js_1.description, inputSchema: schema_js_1.schema }, (0, wrap_js_1.wrapHandler)(definition_js_1.handler));
10
+ }
@@ -0,0 +1 @@
1
+ export declare const KEY = "list_emails";
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.KEY = void 0;
4
+ exports.KEY = 'list_emails';
@@ -0,0 +1,8 @@
1
+ import { z } from 'zod';
2
+ export declare const schema: z.ZodObject<{
3
+ label: z.ZodDefault<z.ZodOptional<z.ZodString>>;
4
+ query: z.ZodOptional<z.ZodString>;
5
+ maxResults: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
6
+ pageToken: z.ZodOptional<z.ZodString>;
7
+ }, z.core.$strip>;
8
+ export type Input = z.infer<typeof schema>;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.schema = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.schema = zod_1.z.object({
6
+ label: zod_1.z
7
+ .string()
8
+ .optional()
9
+ .default('INBOX')
10
+ .describe('Label ID to list. System labels: INBOX, SENT, DRAFT, SPAM, TRASH, STARRED, IMPORTANT, UNREAD, CATEGORY_PERSONAL, CATEGORY_SOCIAL, CATEGORY_PROMOTIONS, CATEGORY_UPDATES, CATEGORY_FORUMS. For user labels use the ID from list_labels. Pass an empty string for all mail.'),
11
+ query: zod_1.z
12
+ .string()
13
+ .optional()
14
+ .describe('Optional Gmail search query to narrow results, e.g. "is:unread", "from:someone@example.com", "after:2024/01/01 before:2024/02/01", "has:attachment".'),
15
+ maxResults: zod_1.z
16
+ .number()
17
+ .int()
18
+ .min(1)
19
+ .max(50)
20
+ .optional()
21
+ .default(10)
22
+ .describe('Number of emails to return (max 50)'),
23
+ pageToken: zod_1.z
24
+ .string()
25
+ .optional()
26
+ .describe('Token from a previous response ("nextPageToken") to fetch the next page'),
27
+ });
@@ -0,0 +1,8 @@
1
+ import type { Input } from './schema.js';
2
+ export declare const description = "List all Gmail labels (system labels like INBOX/SENT and user-created labels) with their IDs and message/unread counts. Use a label ID with list_emails.";
3
+ export declare function handler(_input: Input): Promise<{
4
+ content: {
5
+ type: "text";
6
+ text: string;
7
+ }[];
8
+ }>;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.description = void 0;
4
+ exports.handler = handler;
5
+ const format_js_1 = require("../../format.js");
6
+ const mail_js_1 = require("../../mail.js");
7
+ exports.description = 'List all Gmail labels (system labels like INBOX/SENT and user-created labels) with their IDs and message/unread counts. Use a label ID with list_emails.';
8
+ async function handler(_input) {
9
+ const labels = await (0, mail_js_1.listLabels)();
10
+ const body = labels
11
+ .map((l) => `${l.name} (id: ${l.id}, ${l.type}, unread: ${l.messagesUnread}, total: ${l.messagesTotal})`)
12
+ .join('\n');
13
+ return (0, format_js_1.text)(body || 'No labels found.');
14
+ }
@@ -0,0 +1,2 @@
1
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ export declare function register(server: McpServer): void;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.register = register;
4
+ const wrap_js_1 = require("../wrap.js");
5
+ const definition_js_1 = require("./definition.js");
6
+ const key_js_1 = require("./key.js");
7
+ const schema_js_1 = require("./schema.js");
8
+ function register(server) {
9
+ server.registerTool(key_js_1.KEY, { description: definition_js_1.description, inputSchema: schema_js_1.schema }, (0, wrap_js_1.wrapHandler)(definition_js_1.handler));
10
+ }
@@ -0,0 +1 @@
1
+ export declare const KEY = "list_labels";
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.KEY = void 0;
4
+ exports.KEY = 'list_labels';
@@ -0,0 +1,3 @@
1
+ import { z } from 'zod';
2
+ export declare const schema: z.ZodObject<{}, z.core.$strip>;
3
+ export type Input = z.infer<typeof schema>;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.schema = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.schema = zod_1.z.object({});
@@ -0,0 +1,8 @@
1
+ import type { Input } from './schema.js';
2
+ export declare const description = "Search all Gmail mail using Gmail search syntax (keywords plus operators like from:, subject:, has:attachment, after:, newer_than:). Searches subject, body, sender, recipients, and attachment names.";
3
+ export declare function handler({ query, maxResults, pageToken, includeSpamTrash, }: Input): Promise<{
4
+ content: {
5
+ type: "text";
6
+ text: string;
7
+ }[];
8
+ }>;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.description = void 0;
4
+ exports.handler = handler;
5
+ const format_js_1 = require("../../format.js");
6
+ const mail_js_1 = require("../../mail.js");
7
+ const definition_js_1 = require("../list-emails/definition.js");
8
+ exports.description = 'Search all Gmail mail using Gmail search syntax (keywords plus operators like from:, subject:, has:attachment, after:, newer_than:). Searches subject, body, sender, recipients, and attachment names.';
9
+ async function handler({ query, maxResults, pageToken, includeSpamTrash, }) {
10
+ const result = await (0, mail_js_1.listEmails)({
11
+ query,
12
+ maxResults,
13
+ pageToken,
14
+ includeSpamTrash,
15
+ });
16
+ return (0, format_js_1.text)((0, definition_js_1.formatList)(result, 'No results found.'));
17
+ }
@@ -0,0 +1,2 @@
1
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ export declare function register(server: McpServer): void;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.register = register;
4
+ const wrap_js_1 = require("../wrap.js");
5
+ const definition_js_1 = require("./definition.js");
6
+ const key_js_1 = require("./key.js");
7
+ const schema_js_1 = require("./schema.js");
8
+ function register(server) {
9
+ server.registerTool(key_js_1.KEY, { description: definition_js_1.description, inputSchema: schema_js_1.schema }, (0, wrap_js_1.wrapHandler)(definition_js_1.handler));
10
+ }
@@ -0,0 +1 @@
1
+ export declare const KEY = "search_emails";
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.KEY = void 0;
4
+ exports.KEY = 'search_emails';
@@ -0,0 +1,8 @@
1
+ import { z } from 'zod';
2
+ export declare const schema: z.ZodObject<{
3
+ query: z.ZodString;
4
+ maxResults: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
5
+ pageToken: z.ZodOptional<z.ZodString>;
6
+ includeSpamTrash: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
7
+ }, z.core.$strip>;
8
+ export type Input = z.infer<typeof schema>;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.schema = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.schema = zod_1.z.object({
6
+ query: zod_1.z
7
+ .string()
8
+ .min(1)
9
+ .describe('Gmail search query — same syntax as the Gmail search box. Plain keywords ("invoice acme") or operators: from:, to:, subject:, has:attachment, filename:pdf, is:unread, label:, after:2024/01/01, before:, newer_than:7d, larger:5M, "exact phrase", OR, -exclude.'),
10
+ maxResults: zod_1.z
11
+ .number()
12
+ .int()
13
+ .min(1)
14
+ .max(50)
15
+ .optional()
16
+ .default(10)
17
+ .describe('Number of results to return (max 50)'),
18
+ pageToken: zod_1.z
19
+ .string()
20
+ .optional()
21
+ .describe('Token from a previous response ("nextPageToken") to fetch the next page'),
22
+ includeSpamTrash: zod_1.z
23
+ .boolean()
24
+ .optional()
25
+ .default(false)
26
+ .describe('Also search Spam and Trash. Default false.'),
27
+ });
@@ -0,0 +1,8 @@
1
+ import type { Input } from './schema.js';
2
+ export declare const description = "Sign out of the Google account: revokes this app's access token at Google, removes the saved session from this machine, and cancels any pending sign-in. After this, the authenticate tool must be run again before other tools work.";
3
+ export declare function handler(_input: Input): Promise<{
4
+ content: {
5
+ type: "text";
6
+ text: string;
7
+ }[];
8
+ }>;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.description = void 0;
4
+ exports.handler = handler;
5
+ const auth_js_1 = require("../../auth.js");
6
+ const format_js_1 = require("../../format.js");
7
+ exports.description = "Sign out of the Google account: revokes this app's access token at Google, removes the saved session from this machine, and cancels any pending sign-in. After this, the authenticate tool must be run again before other tools work.";
8
+ async function handler(_input) {
9
+ const { email, revoked } = await (0, auth_js_1.clearAuth)();
10
+ if (!email)
11
+ return (0, format_js_1.text)('No saved session found — already signed out.');
12
+ return (0, format_js_1.text)(`Signed out: ${email}. ` +
13
+ (revoked
14
+ ? 'Access was revoked at Google. '
15
+ : 'Could not reach Google to revoke access (removed locally only; revoke at https://myaccount.google.com/permissions if needed). ') +
16
+ 'Run the authenticate tool to sign in again.');
17
+ }
@@ -0,0 +1,2 @@
1
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ export declare function register(server: McpServer): void;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.register = register;
4
+ const wrap_js_1 = require("../wrap.js");
5
+ const definition_js_1 = require("./definition.js");
6
+ const key_js_1 = require("./key.js");
7
+ const schema_js_1 = require("./schema.js");
8
+ function register(server) {
9
+ server.registerTool(key_js_1.KEY, { description: definition_js_1.description, inputSchema: schema_js_1.schema }, (0, wrap_js_1.wrapHandler)(definition_js_1.handler));
10
+ }
@@ -0,0 +1 @@
1
+ export declare const KEY = "sign_out";
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.KEY = void 0;
4
+ exports.KEY = 'sign_out';