Skip to main content
Glama

folders

Read-onlyIdempotent

List mailbox folders for email accounts to organize and access email storage structure. Returns folder names, paths, and flags for one or multiple accounts.

Instructions

List mailbox folders for one or all email accounts. Returns folder names, paths, and flags.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionYesAction to perform
accountNoAccount email filter (optional, defaults to all)

Implementation Reference

  • Main handler function 'folders' that orchestrates folder listing operations. It uses a switch statement to route to the appropriate action handler (currently only 'list' is supported).
    export async function folders(accounts: AccountConfig[], input: FoldersInput): Promise<any> {
      return withErrorHandling(async () => {
        switch (input.action) {
          case 'list':
            return await handleList(accounts, input)
    
          default:
            throw createUnknownActionError(input.action, 'list')
        }
      })()
    }
  • TypeScript interface 'FoldersInput' defining the input schema for the folders tool. Requires an 'action' field (currently only 'list') and optional 'account' filter.
    export interface FoldersInput {
      action: 'list'
    
      // Target account (optional - defaults to all)
      account?: string
    }
  • Tool registration defining the 'folders' tool metadata including name, description, annotations (readOnlyHint: true, idempotentHint: true), and JSON input schema with action and account properties.
      name: 'folders',
      description: 'List mailbox folders for one or all email accounts. Returns folder names, paths, and flags.',
      annotations: {
        title: 'Folders',
        readOnlyHint: true,
        destructiveHint: false,
        idempotentHint: true,
        openWorldHint: false
      },
      inputSchema: {
        type: 'object',
        properties: {
          action: {
            type: 'string',
            enum: ['list'],
            description: 'Action to perform'
          },
          account: { type: 'string', description: 'Account email filter (optional, defaults to all)' }
        },
        required: ['action']
      }
    },
  • Handler dispatch logic in the CallToolRequestSchema handler that invokes the folders function when the tool name is 'folders'.
    case 'folders':
      result = await folders(accounts, args as unknown as FoldersInput)
      break
  • Core helper function 'listFolders' that performs the actual IMAP folder listing operation. Connects to the email account and retrieves mailbox list with name, path, flags, and delimiter.
    export async function listFolders(account: AccountConfig): Promise<FolderInfo[]> {
      return withConnection(account, async (client) => {
        const mailboxes = await client.list()
        return mailboxes.map((mb: any) => ({
          name: mb.name,
          path: mb.path,
          flags: Array.from(mb.flags || []),
          delimiter: mb.delimiter || '/'
        }))
      })
    }
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already indicate read-only, non-destructive, and idempotent behavior, which the description doesn't contradict. The description adds value by specifying the return data ('folder names, paths, and flags'), which isn't covered by annotations, providing useful context about what information is retrieved. No rate limits or auth needs are mentioned, but annotations cover safety aspects adequately.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, well-structured sentence that efficiently states the action, scope, and output without unnecessary words. It is front-loaded with the core purpose and avoids redundancy, making it easy for an agent to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's low complexity (list operation), rich annotations (read-only, idempotent), and full schema coverage, the description is mostly complete. It specifies output details, which compensates for the lack of an output schema. However, it could improve by mentioning any limitations (e.g., pagination) or error cases, though annotations provide good safety context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents both parameters (action and account). The description mentions 'one or all email accounts,' which aligns with the optional account parameter but doesn't add syntax or format details beyond what the schema provides. With high schema coverage, baseline 3 is appropriate as the description adds minimal extra semantic value.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('List') and resource ('mailbox folders'), specifies scope ('for one or all email accounts'), and distinguishes from siblings like 'messages' or 'attachments' by focusing on folder metadata rather than message content. It provides specific output details ('folder names, paths, and flags') that further clarify its purpose.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context by specifying it works for 'one or all email accounts,' which helps differentiate from tools that might target specific accounts only. However, it lacks explicit guidance on when to use this versus alternatives like 'messages' (which might list messages within folders) or any prerequisites for accessing accounts.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/n24q02m/better-email-mcp'

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