Skip to main content
Glama

batch_delete_emails

Delete multiple Gmail messages simultaneously by specifying their IDs, enabling efficient inbox cleanup through bulk removal operations.

Instructions

Delete multiple emails at once

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
messageIdsYesArray of email message IDs to delete

Implementation Reference

  • Zod input schema definition for the batch_delete_emails tool.
    batch_delete_emails: z.object({ messageIds: z.array(z.string()).describe("Array of email message IDs to delete") }),
  • src/tools.ts:50-55 (registration)
    Tool registration function that exports definitions for all tools including batch_delete_emails using its schema and description.
    export const getToolDefinitions = () => Object.entries(schemas).map(([name, schema]) => ({ name, description: toolDescriptions[name], inputSchema: zodToJsonSchema(schema) }));
  • Main handler logic for batch_delete_emails tool: validates input, calls GmailService.batchDeleteEmails, and returns formatted success/failure count.
    case "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` }] }; }
  • Core implementation of batch email deletion: uses batchOperation helper to delete multiple emails via Gmail API.
    async batchDeleteEmails(ids: string[]): Promise<{ successes: number; failures: number }> { return this.batchOperation(ids, (id) => this.deleteEmail(id)); }
  • Generic batch operation helper used by batchDeleteEmails to process deletions in batches of 50 with success/failure counting.
    private 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 }; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/muammar-yacoob/GMail-Manager-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server