Skip to main content
Glama
MadLlama25

Fastmail MCP Server

by MadLlama25

list_emails

Retrieve emails from a Fastmail mailbox to view, organize, or process messages using JMAP API integration.

Instructions

List emails from a mailbox

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
mailboxIdNoID of the mailbox to list emails from (optional, defaults to all)
limitNoMaximum number of emails to return (default: 20)

Implementation Reference

  • Tool schema definition including name, description, and input schema for list_emails
    {
      name: 'list_emails',
      description: 'List emails from a mailbox',
      inputSchema: {
        type: 'object',
        properties: {
          mailboxId: {
            type: 'string',
            description: 'ID of the mailbox to list emails from (optional, defaults to all)',
          },
          limit: {
            type: 'number',
            description: 'Maximum number of emails to return (default: 20)',
            default: 20,
          },
        },
      },
    },
  • MCP tool handler for 'list_emails' that extracts parameters and calls JmapClient.getEmails
    case 'list_emails': {
      const { mailboxId, limit = 20 } = args as any;
      const emails = await client.getEmails(mailboxId, limit);
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(emails, null, 2),
          },
        ],
      };
    }
  • Core implementation of email listing using JMAP protocol: queries emails optionally filtered by mailbox, sorted by receivedAt descending, fetches specified properties.
    async getEmails(mailboxId?: string, limit: number = 20): Promise<any[]> {
      const session = await this.getSession();
      
      const filter = mailboxId ? { inMailbox: mailboxId } : {};
      
      const request: JmapRequest = {
        using: ['urn:ietf:params:jmap:core', 'urn:ietf:params:jmap:mail'],
        methodCalls: [
          ['Email/query', {
            accountId: session.accountId,
            filter,
            sort: [{ property: 'receivedAt', isAscending: false }],
            limit
          }, 'query'],
          ['Email/get', {
            accountId: session.accountId,
            '#ids': { resultOf: 'query', name: 'Email/query', path: '/ids' },
            properties: ['id', 'subject', 'from', 'to', 'receivedAt', 'preview', 'hasAttachment']
          }, 'emails']
        ]
      };
    
      const response = await this.makeRequest(request);
      return response.methodResponses[1][1].list;
    }

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/MadLlama25/fastmail-mcp'

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