Skip to main content
Glama

delete_email

Remove unwanted emails from your Fastmail account by moving them to trash using their unique ID. Manage your inbox by deleting specific messages through the MCP server's email operations.

Instructions

Delete an email (move to trash)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
emailIdYesID of the email to delete

Implementation Reference

  • src/index.ts:420-433 (registration)
    Registration of the 'delete_email' tool including its input schema in the MCP server's listTools response.
    { name: 'delete_email', description: 'Delete an email (move to trash)', inputSchema: { type: 'object', properties: { emailId: { type: 'string', description: 'ID of the email to delete', }, }, required: ['emailId'], }, },
  • MCP server handler for the 'delete_email' tool: extracts emailId, initializes JmapClient, calls deleteEmail, and returns success message.
    case 'delete_email': { const { emailId } = args as any; if (!emailId) { throw new McpError(ErrorCode.InvalidParams, 'emailId is required'); } const client = initializeClient(); await client.deleteEmail(emailId); return { content: [ { type: 'text', text: 'Email deleted successfully (moved to trash)', }, ], }; }
  • Core implementation in JmapClient: finds trash mailbox, constructs JMAP Email/set request to move the email by updating its mailboxIds, executes via makeRequest.
    async deleteEmail(emailId: 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 request: JmapRequest = { using: ['urn:ietf:params:jmap:core', 'urn:ietf:params:jmap:mail'], methodCalls: [ ['Email/set', { accountId: session.accountId, update: { [emailId]: { mailboxIds: trashMailboxIds } } }, 'moveToTrash'] ] }; const response = await this.makeRequest(request); const result = response.methodResponses[0][1]; if (result.notUpdated && result.notUpdated[emailId]) { throw new Error('Failed to delete email.'); } }

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