Skip to main content
Glama
sugar-crash-studios

Proton MCP Server

List Emails in Folder

proton_list_emails
Read-onlyIdempotent

Retrieve emails from a Proton Mail folder with pagination. View sender, subject, date, and read status for organized email management.

Instructions

List emails in a specific folder with pagination. Shows sender, subject, date, and read status. Results are newest first.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
folderNoINBOX
limitNo
offsetNo

Implementation Reference

  • Registration of the proton_list_emails tool, which uses the listMessages service to fetch data.
    export function registerListEmailsTool(server: McpServer) {
      server.registerTool(
        'proton_list_emails',
        {
          title: 'List Emails in Folder',
          description: 'List emails in a specific folder with pagination. Shows sender, subject, date, and read status. Results are newest first.',
          inputSchema: ListEmailsSchema,
          annotations: {
            readOnlyHint: true,
            destructiveHint: false,
            idempotentHint: true,
            openWorldHint: false,
          },
        },
        async (params: z.infer<typeof ListEmailsSchema>) => {
          try {
            const messages = await listMessages(params.folder, params.limit, params.offset);
    
            if (messages.length === 0) {
              return {
                content: [
                  {
                    type: 'text',
                    text: 'No messages found in this folder.',
                  },
                ],
              };
            }
    
            // Format as markdown table
            let result = `**Folder:** ${params.folder}\n`;
            result += `**Page:** offset=${params.offset}, limit=${params.limit}\n\n`;
            result += '| UID | From | Subject | Date | Read |\n';
            result += '|-----|------|---------|------|------|\n';
    
            for (const msg of messages) {
              const fromName = msg.from.name || msg.from.email;
              const subject = msg.subject.substring(0, 40);
              const date = msg.date.toISOString().split('T')[0];
              const readStatus = msg.seen ? '✓' : '✗';
    
              result += `| ${msg.uid} | ${fromName} | ${subject} | ${date} | ${readStatus} |\n`;
            }
    
            return {
              content: [
                {
                  type: 'text',
                  text: result,
                },
              ],
            };
          } catch (error) {
            return {
              content: [
                {
                  type: 'text',
                  text: `Error listing emails: ${error instanceof Error ? error.message : String(error)}`,
                },
              ],
            };
          }
        }
      );
    }
  • The handler logic for listing messages, which fetches and paginates emails via IMAP.
    export async function listMessages(
      folder: string,
      limit: number,
      offset: number
    ): Promise<MessageEnvelope[]> {
      const client = await getImapClient();
      try {
        const lock = await client.getMailboxLock(folder);
        try {
          // Get total message count
          const mailbox = await client.mailboxOpen(folder);
          const totalMessages = mailbox.exists || 0;
    
          // Calculate range for pagination
          const start = Math.max(1, totalMessages - offset - limit + 1);
          const end = Math.max(1, totalMessages - offset);
    
          if (start > end) {
            return [];
          }
    
          const messages: MessageEnvelope[] = [];
          const fetchQuery = await client.fetch(`${start}:${end}`, {
            envelope: true,
            uid: true,
            flags: true,
          });
    
          for await (const msg of fetchQuery) {
            if (msg.envelope) {
              const from = msg.envelope.from?.[0];
              const to = msg.envelope.to;
    
              messages.push({
                uid: msg.uid as number,
                from: {
                  name: from?.name || undefined,
                  email: from?.address || '',
                },
                to: to?.map(t => ({
                  name: t.name || undefined,
                  email: t.address || '',
                })),
                subject: msg.envelope.subject || '(no subject)',
                date: msg.envelope.date || new Date(),
                flags: Array.from(msg.flags || []).map(f => String(f)),
                seen: msg.flags.has('\\Seen'),
              });
            }
          }
    
          // Reverse to show newest first
          return messages.reverse();
        } finally {
          lock.release();
        }
      } finally {
        await client.logout();
      }
    }
Behavior3/5

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

Annotations already provide readOnlyHint=true, destructiveHint=false, idempotentHint=true, and openWorldHint=false, covering safety and idempotency. The description adds useful context about pagination, displayed fields (sender, subject, date, read status), and sorting (newest first), but does not disclose additional behavioral traits like rate limits, authentication needs, or error conditions beyond what annotations imply.

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 two concise sentences with zero waste: the first states the core action and key features (pagination, displayed fields), and the second adds ordering information. It is front-loaded and appropriately sized for the tool's complexity.

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 moderate complexity (3 parameters, no output schema), rich annotations (covering safety and idempotency), and the description's coverage of purpose, fields, and ordering, it is mostly complete. However, it lacks details on error handling, authentication requirements, or output format, which could be useful since there is no output schema.

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 0%, so the schema provides no parameter descriptions. The description mentions 'specific folder' and 'pagination', which loosely relate to the folder, limit, and offset parameters, but does not add detailed meaning (e.g., default values, constraints, or semantics like offset for pagination). With 3 parameters and no schema descriptions, the description compensates minimally, meeting the baseline for adequate but incomplete coverage.

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 ('emails in a specific folder'), specifies the scope ('with pagination'), and distinguishes it from siblings like proton_search_emails by focusing on listing rather than searching. It explicitly mentions what information is shown (sender, subject, date, read status) and the ordering (newest first).

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 for listing emails in a folder with pagination, but does not explicitly state when to use this tool versus alternatives like proton_search_emails or proton_list_folders. It provides clear context (specific folder, pagination) but lacks explicit exclusions or named alternatives.

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/sugar-crash-studios/proton-mcp-server'

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