Skip to main content
Glama

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

Implementation Reference

  • MCP server tool handler for 'bulk_delete' that validates input and delegates to JmapClient.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)`, }, ], }; }
  • Core JMAP implementation of bulkDelete that moves multiple emails to the trash mailbox using Email/set update with mailboxIds
    async 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.'); } }
  • 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'

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/MadLlama25/fastmail-mcp'

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