Skip to main content
Glama
MadLlama25

Fastmail MCP Server

by MadLlama25

get_mailbox_stats

Retrieve mailbox statistics including unread count and total emails for monitoring email activity and managing inbox organization.

Instructions

Get statistics for a mailbox (unread count, total emails, etc.)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
mailboxIdNoID of the mailbox (optional, defaults to all mailboxes)

Implementation Reference

  • src/index.ts:548-560 (registration)
    Tool registration in ListTools response, including name, description, and input schema definition.
    {
      name: 'get_mailbox_stats',
      description: 'Get statistics for a mailbox (unread count, total emails, etc.)',
      inputSchema: {
        type: 'object',
        properties: {
          mailboxId: {
            type: 'string',
            description: 'ID of the mailbox (optional, defaults to all mailboxes)',
          },
        },
      },
    },
  • MCP server dispatch handler for get_mailbox_stats tool that parses arguments and delegates to JmapClient.getMailboxStats.
    case 'get_mailbox_stats': {
      const { mailboxId } = args as any;
      const client = initializeClient();
      const stats = await client.getMailboxStats(mailboxId);
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(stats, null, 2),
          },
        ],
      };
    }
  • Core implementation in JmapClient that fetches mailbox statistics via JMAP Mailbox/get API call, handling both specific mailbox and all mailboxes cases.
    async getMailboxStats(mailboxId?: string): Promise<any> {
      const session = await this.getSession();
      
      if (mailboxId) {
        // Get stats for specific mailbox
        const request: JmapRequest = {
          using: ['urn:ietf:params:jmap:core', 'urn:ietf:params:jmap:mail'],
          methodCalls: [
            ['Mailbox/get', {
              accountId: session.accountId,
              ids: [mailboxId],
              properties: ['id', 'name', 'role', 'totalEmails', 'unreadEmails', 'totalThreads', 'unreadThreads']
            }, 'mailbox']
          ]
        };
    
        const response = await this.makeRequest(request);
        return response.methodResponses[0][1].list[0];
      } else {
        // Get stats for all mailboxes
        const mailboxes = await this.getMailboxes();
        return mailboxes.map(mb => ({
          id: mb.id,
          name: mb.name,
          role: mb.role,
          totalEmails: mb.totalEmails || 0,
          unreadEmails: mb.unreadEmails || 0,
          totalThreads: mb.totalThreads || 0,
          unreadThreads: mb.unreadThreads || 0
        }));
      }
    }

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