batch_delete_emails
Delete multiple Gmail messages simultaneously to clear inbox clutter. Specify message IDs to remove unwanted emails in bulk.
Instructions
Delete multiple emails at once
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| messageIds | Yes | Array of email message IDs to delete |
Implementation Reference
- src/tools.ts:86-91 (handler)Tool handler for batch_delete_emails: validates input using Zod schema and calls GmailService.batchDeleteEmailscase "batch_delete_emails": { const v = validated as z.infer<typeof schemas.batch_delete_emails>; const result = await gmailService.batchDeleteEmails(v.messageIds); return { content: [{ type: "text", text: `Batch delete completed:\nSuccessfully deleted: ${result.successes} emails\nFailed: ${result.failures} emails` }] }; }
- src/tools.ts:12-12 (schema)Zod input schema definition for the batch_delete_emails toolbatch_delete_emails: z.object({ messageIds: z.array(z.string()).describe("Array of email message IDs to delete") }),
- src/tools.ts:50-55 (registration)Registration of tool definitions (schemas and descriptions) for MCP, including batch_delete_emailsexport const getToolDefinitions = () => Object.entries(schemas).map(([name, schema]) => ({ name, description: toolDescriptions[name], inputSchema: zodToJsonSchema(schema) }));
- src/gmail-service.ts:76-78 (helper)Core implementation of batch email deletion using batchOperation helperasync batchDeleteEmails(ids: string[]): Promise<{ successes: number; failures: number }> { return this.batchOperation(ids, (id) => this.deleteEmail(id)); }
- src/gmail-service.ts:113-123 (helper)Supporting batchOperation utility used by batchDeleteEmails for processing IDs in batches with error handlingprivate async batchOperation<T>(items: T[], operation: (item: T) => Promise<any>): Promise<{ successes: number; failures: number }> { let successes = 0, failures = 0; const batchSize = 50; for (let i = 0; i < items.length; i += batchSize) { const results = await Promise.allSettled(items.slice(i, i + batchSize).map(operation)); results.forEach(r => r.status === 'fulfilled' ? successes++ : failures++); } return { successes, failures }; }