Skip to main content
Glama

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
NameRequiredDescriptionDefault
messageIdsYesArray of email message IDs to delete

Implementation Reference

  • Tool handler for batch_delete_emails: validates input using Zod schema and calls GmailService.batchDeleteEmails
    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` }] }; }
  • 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)
    Registration of tool definitions (schemas and descriptions) for MCP, including batch_delete_emails
    export const getToolDefinitions = () => Object.entries(schemas).map(([name, schema]) => ({ name, description: toolDescriptions[name], inputSchema: zodToJsonSchema(schema) }));
  • Core implementation of batch email deletion using batchOperation helper
    async batchDeleteEmails(ids: string[]): Promise<{ successes: number; failures: number }> { return this.batchOperation(ids, (id) => this.deleteEmail(id)); }
  • Supporting batchOperation utility used by batchDeleteEmails for processing IDs in batches with error handling
    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