Skip to main content
Glama
ggiraudon
by ggiraudon

setFlags

Set message flags like read/unread or starred to organize and manage emails in IMAP folders.

Instructions

Sets flags on a message.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
folderYes
uidYes
flagsYes

Implementation Reference

  • The execute function of the SetMessageFlagsTool, which handles the tool invocation: validates arguments, connects to IMAP controller, calls setFlags on the message, and returns success.
    async execute(args, context) { if (!args || typeof args !== 'object' || !('folder' in args) || !('uid' in args) || !('flags' in args)) { throw new Error("Missing required arguments"); } const controller = ImapControllerFactory.getInstance(); await controller.connect(); await controller.setFlags(args.folder, args.uid, args.flags); return JSON.stringify({ success: true }); }
  • Zod schema defining the input parameters for the setFlags tool: folder, uid, and flags.
    export const SetFlagsInput = z.object({ folder: z.string().min(2).max(100), uid: z.number(), flags: z.union([z.string(), z.array(z.string())]) });
  • src/index.ts:55-55 (registration)
    Registers the SetMessageFlagsTool with the FastMCP server instance.
    server.addTool(SetMessageFlagsTool);
  • ImapController method that opens the mailbox and uses node-imap's addFlags to set flags on the specified message UID.
    setFlags(folder: string, uid: number, flags: string | string[]): 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, flags, (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