bulk_delete
Delete multiple emails at once by providing an array of email IDs to move them to trash.
Instructions
Delete multiple emails (move to trash)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| emailIds | Yes | Array of email IDs to delete |
Implementation Reference
- src/index.ts:903-917 (registration)Tool 'bulk_delete' registered in the ListToolsRequestSchema handler with name, description, and inputSchema defining required 'emailIds' array parameter.
{ name: 'bulk_delete', description: 'Delete multiple emails (move to trash)', inputSchema: { type: 'object', properties: { emailIds: { type: 'array', items: { type: 'string' }, description: 'Array of email IDs to delete', }, }, required: ['emailIds'], }, }, - src/index.ts:1690-1705 (handler)MCP CallToolRequestHandler case for 'bulk_delete' that validates emailIds array and delegates to client.bulkDelete().
case 'bulk_delete': { const { emailIds } = args as any; if (!emailIds || !Array.isArray(emailIds) || emailIds.length === 0) { throw new McpError(ErrorCode.InvalidParams, 'emailIds array is required and must not be empty'); } const client = initializeClient(); await client.bulkDelete(emailIds); return { content: [ { type: 'text', text: `${emailIds.length} emails deleted successfully (moved to trash)`, }, ], }; } - src/jmap-client.ts:1491-1526 (handler)The actual bulkDelete method in JmapClient: moves multiple emails to the Trash mailbox in a single JMAP Email/set update call.
async bulkDelete(emailIds: string[]): Promise<void> { const session = await this.getSession(); // Find the trash mailbox const mailboxes = await this.getMailboxes(); const trashMailbox = this.findMailboxByRoleOrName(mailboxes, 'trash', 'trash'); if (!trashMailbox) { throw new Error('Could not find Trash mailbox'); } const trashMailboxIds: Record<string, boolean> = {}; trashMailboxIds[trashMailbox.id] = true; const updates: Record<string, any> = {}; emailIds.forEach(id => { updates[id] = { mailboxIds: trashMailboxIds }; }); const request: JmapRequest = { using: ['urn:ietf:params:jmap:core', 'urn:ietf:params:jmap:mail'], methodCalls: [ ['Email/set', { accountId: session.accountId, update: updates }, 'bulkDelete'] ] }; const response = await this.makeRequest(request); const result = this.getMethodResult(response, 0); if (result.notUpdated && Object.keys(result.notUpdated).length > 0) { throw new Error('Failed to delete some emails.'); } }