Skip to main content
Glama
ggiraudon
by ggiraudon

deleteMessage

Remove specific emails from designated folders using unique message identifiers to manage email storage and organization.

Instructions

Deletes a message by UID from a given folder.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
folderYes
uidYes

Implementation Reference

  • The execute function implementing the 'deleteMessage' tool logic. Validates args, gets IMAP controller, connects, deletes message by folder and UID, returns success.
    async execute(args, context) { if (!args || typeof args !== 'object' || !('folder' in args) || !('uid' in args)) { throw new Error("Missing required arguments"); } const controller = ImapControllerFactory.getInstance(); await controller.connect(); await controller.deleteMessage(args.folder, args.uid); return JSON.stringify({ success: true }); }
  • Zod schema defining input parameters for deleteMessage tool: folder (string) and uid (number).
    export const DeleteMessageInput = z.object({ folder: z.string().min(2).max(100), uid: z.number() });
  • src/index.ts:49-49 (registration)
    Registration of the DeleteMessageTool with the MCP server.
    server.addTool(DeleteMessageTool);
  • Helper method in ImapController that opens the folder, adds \Deleted flag to the message by UID, and expunges it.
    deleteMessage(folder: string, uid: number): Promise<void> { return new Promise((resolve, reject) => { this.imap.openBox(folder, false, (err: Error | null, box: Imap.Box | null) => { if (err) return reject(err); this.imap.addFlags(uid, '\\Deleted', (err: Error | null) => { if (err) return reject(err); this.imap.expunge(uid, (err: Error | null) => { if (err) return reject(err); resolve(); }); }); }); }); }

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/ggiraudon/emailMCPServer'

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