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
| Name | Required | Description | Default |
|---|---|---|---|
| folder | Yes | ||
| uid | Yes | ||
| flags | Yes |
Implementation Reference
- src/tools/SetMessageFlagsTool.ts:15-23 (handler)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 }); }
- src/tools/SetMessageFlagsTool.ts:5-9 (schema)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(); }); }); }); }