Skip to main content
Glama
MadLlama25

Fastmail MCP Server

by MadLlama25

get_mailbox_stats

Retrieve unread count and total email statistics for a specific mailbox or all mailboxes.

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

  • The `getMailboxStats` method on JmapClient that executes the tool logic. If a mailboxId is provided, it fetches stats for that specific mailbox via JMAP Mailbox/get; otherwise, it calls getMailboxes() and returns stats for all mailboxes (id, name, role, totalEmails, unreadEmails, totalThreads, unreadThreads).
    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 this.getListResult(response, 0)[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
        }));
      }
    }
  • Input schema registration for the 'get_mailbox_stats' tool, defining its description and optional mailboxId parameter.
    {
      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)',
          },
        },
      },
    },
  • The call handler dispatch for 'get_mailbox_stats'. Extracts mailboxId from args, calls client.getMailboxStats(mailboxId), and returns the result as JSON.
    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),
          },
        ],
      };
    }
  • src/index.ts:1758-1759 (registration)
    References 'get_mailbox_stats' in the check_function_availability listing to confirm it is a registered tool name.
    'get_mailbox_stats', 'get_account_summary', 'bulk_mark_read', 'bulk_pin', 'bulk_move', 'bulk_delete',
    'add_labels', 'remove_labels', 'bulk_add_labels', 'bulk_remove_labels'
Behavior2/5

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

No annotations provided. Description only states 'Get statistics', a read operation, but does not disclose behavior like defaults (e.g., when mailboxId omitted, it retrieves all mailboxes) or performance implications. Lacks depth beyond basic action.

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?

Single sentence of 7 words, very concise and front-loaded. However, could include the default behavior (all mailboxes) without much bloat. Efficient but slightly under-specified.

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

Completeness3/5

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

For a simple tool with 1 optional parameter and no output schema, the description is adequate but minimal. It does not mention return format or that it is read-only, which would help completeness. Just enough to understand purpose.

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% (1 parameter fully described). Description adds minimal extra meaning beyond schema: it implies the parameter is optional and relates to a single mailbox, but this is already in the schema. Baseline 3 is appropriate.

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?

Description clearly states verb 'Get', resource 'mailbox statistics', and hints at specific statistics (unread count, total emails). It distinguishes from sibling tools like 'list_mailboxes' which list mailboxes rather than stats.

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?

No guidance on when to use this tool versus alternatives (e.g., 'list_mailboxes' for listing only, or 'get_email' for detailed email retrieval). No exclusions or prerequisites mentioned.

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

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