bulk_delete
Delete multiple emails by moving them to trash. Provide an array of email IDs to remove them from your inbox.
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:906-920 (registration)Tool 'bulk_delete' is registered with input schema requiring 'emailIds' array. It is listed in the ListToolsRequestSchema handler along with all other tools.
{ 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:1693-1708 (handler)Handler for the 'bulk_delete' tool: validates emailIds array, delegates to client.bulkDelete(), returns success message.
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 (helper)JmapClient.bulkDelete() implementation: fetches trash mailbox, builds Email/set update for all email IDs to move them to trash, makes JMAP API 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.'); } }