bulk_delete
Delete multiple emails at once by moving them to trash. Use this tool to remove unwanted messages from your Fastmail inbox efficiently.
Instructions
Delete multiple emails (move to trash)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| emailIds | Yes | Array of email IDs to delete |
Implementation Reference
- src/index.ts:1114-1129 (handler)MCP server tool handler for 'bulk_delete' that validates input and delegates to JmapClient.bulkDeletecase '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:727-762 (handler)Core JMAP implementation of bulkDelete that moves multiple emails to the trash mailbox using Email/set update with mailboxIdsasync bulkDelete(emailIds: string[]): Promise<void> { const session = await this.getSession(); // Find the trash mailbox const mailboxes = await this.getMailboxes(); const trashMailbox = mailboxes.find(mb => mb.role === 'trash') || mailboxes.find(mb => mb.name.toLowerCase().includes('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 = response.methodResponses[0][1]; if (result.notUpdated && Object.keys(result.notUpdated).length > 0) { throw new Error('Failed to delete some emails.'); } }
- src/index.ts:608-622 (schema)Input schema definition for the bulk_delete tool, specifying required emailIds array{ 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:1142-1142 (registration)Tool listed in check_function_availability response for email capabilities'get_mailbox_stats', 'get_account_summary', 'bulk_mark_read', 'bulk_move', 'bulk_delete'