Skip to main content
Glama
ggiraudon
by ggiraudon

getFolderList

Retrieve a structured list of email folders from an IMAP account to organize and manage mailbox contents effectively.

Instructions

Returns a list of folders in the imap account.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The execute handler function of the getFolderList tool, which connects to the IMAP controller and retrieves and formats the folder list.
    export const GetFolderListTool: Tool<any, typeof GetFolderListInput> = { name: "getFolderList", description: "Returns a list of folders in the imap account.", parameters: GetFolderListInput, async execute(params) { const controller = ImapControllerFactory.getInstance(); await controller.connect(); const folders: MailFolder[] = await controller.getFolderList(); // Return as a JSON string to match the expected return type return JSON.stringify({ folders: folders.map(f => ({ name: f.name, path: f.path, flags: f.flags, delimiter: f.delimiter })) }); } };
  • Zod input schema for the getFolderList tool (no parameters required).
    const GetFolderListInput = z.object({ // No input parameters needed for this tool });
  • src/index.ts:50-50 (registration)
    Registration of the GetFolderListTool with the FastMCP server.
    server.addTool(GetFolderListTool);
  • ImapController.getFolderList() helper method that traverses the IMAP box structure to build the folder list.
    getFolderList(): Promise<MailFolder[]> { return new Promise((resolve, reject) => { this.imap.getBoxes((err: Error | null, boxes: any) => { if (err) return reject(err); const folders: MailFolder[] = []; const traverse = (boxObj: any, path = '') => { for (const name in boxObj) { const box = boxObj[name]; const fullPath = path ? path + box.delimiter + name : name; // Validate with schema and push folders.push(MailFolderSchema.parse({ name, path: fullPath, flags: box.flags, delimiter: box.delimiter })); if (box.children) traverse(box.children, fullPath); } }; traverse(boxes); resolve(folders); }); }); }

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