createFolder
Create a new folder in your IMAP email account to organize messages and improve email management.
Instructions
Creates a new folder in the IMAP account.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| folderName | Yes |
Implementation Reference
- src/tools/CreateFolderTool.ts:9-22 (handler)The main tool implementation including the execute handler that uses ImapController to create the folder.export const CreateFolderTool: Tool<any, typeof CreateFolderInput> = { name: "createFolder", description: "Creates a new folder in the IMAP account.", parameters: CreateFolderInput, async execute(args, context) { if (!args || typeof args !== 'object' || !('folderName' in args)) { throw new Error("Missing required arguments"); } const controller = ImapControllerFactory.getInstance(); await controller.connect(); await controller.createFolder(args.folderName); return JSON.stringify({ success: true }); } };
- src/tools/CreateFolderTool.ts:5-7 (schema)Zod schema defining the input for the createFolder tool (folderName string).export const CreateFolderInput = z.object({ folderName: z.string().min(2).max(100) });
- src/index.ts:47-47 (registration)Registration of the CreateFolderTool with the FastMCP server.server.addTool(CreateFolderTool);
- Helper method in ImapController that performs the actual IMAP folder creation using imap.addBox.createFolder(folderName: string): Promise<void> { return new Promise((resolve, reject) => { this.imap.addBox(folderName, (err: Error | null) => { if (err) return reject(err); resolve(); }); }); }