Skip to main content
Glama
ggiraudon

Email MCP Server

by ggiraudon

getMessageList

Retrieve a list of email messages from a specified folder in an email server. Specify folder name and optional range parameters to fetch messages.

Instructions

Returns a list of messages in a given folder.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
folderYes
startNo
endNo*

Implementation Reference

  • Main tool handler: defines name, description, parameters schema, and execute function that validates args, connects via factory, calls controller.getMessageList, returns JSON stringified messages.
    export const GetMessageListTool: Tool<any, typeof GetMessageListInput> = {
      name: "getMessageList",
      description: "Returns a list of messages in a given folder.",
      parameters: GetMessageListInput,
      async execute(args, context) {
        if (!args || typeof args !== 'object' || !('folder' in args)) {
          throw new Error("Missing required arguments");
        }
        const controller = ImapControllerFactory.getInstance();
        await controller.connect();
        const messages: MailItem[] = await controller.getMessageList(args.folder, args.start, args.end);
        return JSON.stringify({ messages });
      }
    };
  • Zod input schema defining required folder (string 2-100 chars), optional start number (default 1), optional end string (default '*').
    const GetMessageListInput = z.object({
      folder: z.string().min(2).max(100),
      start: z.number().min(1).optional().default(1),
      end: z.string().min(1).optional().default('*'),
    });
  • src/index.ts:51-51 (registration)
    Registers the GetMessageListTool instance with the FastMCP server.
    server.addTool(GetMessageListTool);
  • Core helper method in ImapController that opens IMAP box, fetches headers for range start:end, parses subject/from/to/date/uid into MessageListItem objects.
    getMessageList(folder: string, start: number, end: number|string): Promise<MessageListItem[]> {
        return new Promise((resolve, reject) => {
            this.imap.openBox(folder, true, (err: Error | null, box: Imap.Box) => {
                if (err) return reject(err);
                const results: MessageListItem[] = [];
                const fetch = this.imap.seq.fetch(`${start}:${end}`, { bodies: 'HEADER.FIELDS (FROM TO SUBJECT DATE)', struct: true });
                fetch.on('message', (msg: ImapMessage, seqno: number) => {
                    const item: any = { };
                    msg.on('body', (stream: any) => {
                        let buffer = '';
                        stream.on('data', (chunk: Buffer) => buffer += chunk.toString('utf8'));
                        stream.on('end', () => {
                            const headers = Imap.parseHeader(buffer);
                            item.subject = headers.subject?.[0];
                            item.from = parseAddressList(headers.from)[0];
                            item.to = parseAddressList(headers.to);
                            item.date = headers.date?.[0] ? new Date(headers.date[0]) : undefined;
                        });
                    });
                    msg.once('attributes', (attrs: any) => {
                        item.id = attrs.uid;
                    });
                    msg.once('end', () => {
                        //console.log('Parsed MessageListItem:', item);
                        results.push(MessageListItem.parse(item));
                    });
                });
                fetch.once('error', (err:Error|null) => reject(err));
                fetch.once('end', () => resolve(results));
            });
        });
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool returns a list, implying a read-only operation, but does not cover aspects like pagination (hinted by 'start' and 'end' parameters), rate limits, authentication needs, or what happens if the folder is empty. This leaves significant gaps in understanding the tool's behavior beyond basic functionality.

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

Conciseness4/5

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

The description is a single, straightforward sentence that efficiently conveys the core action. It is front-loaded with the main purpose and avoids unnecessary details. However, it could be more structured by including key usage notes, but as-is, it is appropriately sized with zero waste.

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

Completeness2/5

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

Given the complexity of a list operation with 3 parameters, no annotations, and no output schema, the description is incomplete. It does not explain the return format (e.g., structure of the message list), error handling, or how parameters interact (e.g., 'start' and 'end' for pagination). For a tool with such gaps in structured data, the description should provide more contextual detail to be fully helpful.

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

Parameters2/5

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

Schema description coverage is 0%, so the description must compensate for undocumented parameters. It only mentions 'folder' in the context of the list operation, without explaining the semantics of 'start' (e.g., offset or page number) or 'end' (e.g., limit or end marker). This fails to add meaningful context beyond what the schema minimally provides, leaving parameters largely unexplained.

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

Purpose3/5

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

The description states the tool 'Returns a list of messages in a given folder,' which clearly indicates its purpose as a read operation on messages. However, it does not differentiate from siblings like 'getMessage' (which fetches a single message) or 'search' (which might filter messages), making it somewhat vague in comparison. The verb 'Returns' and resource 'messages' are specific, but sibling distinction is lacking.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It does not mention scenarios like retrieving all messages in a folder versus using 'search' for filtered results or 'getMessage' for a single message. Without explicit when/when-not instructions or named alternatives, it offers minimal usage context.

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/ggiraudon/emailMCPServer'

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