Skip to main content
Glama
as-j

Fastmail MCP Server

by as-j

get_mailbox_stats

Read-onlyIdempotent

Retrieve unread counts and total email statistics for a specific mailbox or all mailboxes to get a quick summary of mailbox volume without listing individual messages.

Instructions

Get statistics such as unread counts and total emails for a mailbox or across the account. Use when the user wants a summary of mailbox volume or unread counts rather than individual messages. Do not use for listing messages themselves.

Input Schema

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

Implementation Reference

  • Handler for the 'get_mailbox_stats' tool - invokes client.getMailboxStats(mailboxId) and returns the result as JSON text.
    case 'get_mailbox_stats': {
      const { mailboxId } = args as any;
      const stats = await client.getMailboxStats(mailboxId);
      return { content: [{ type: 'text', text: JSON.stringify(stats, null, 2) }] };
    }
  • Core implementation of getMailboxStats - calls JMAP Mailbox/get for a specific mailbox or aggregates stats across all mailboxes.
    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
        }));
      }
    }
  • Schema/definition for the get_mailbox_stats tool - describes input parameters (optional mailboxId) and usage guidance.
      'get_mailbox_stats',
      'Get Mailbox Stats',
      description(
        'Get statistics such as unread counts and total emails for a mailbox or across the account.',
        'Use when the user wants a summary of mailbox volume or unread counts rather than individual messages.',
        'Do not use for listing messages themselves.',
      ),
      {
        type: 'object',
        properties: {
          mailboxId: {
            type: 'string',
            description: 'ID of the mailbox (optional, defaults to all mailboxes)',
          },
        },
      },
    ),
  • Registration of 'get_mailbox_stats' as an available function in the email tool capabilities list.
    'get_mailbox_stats', 'get_account_summary', 'bulk_mark_read', 'bulk_move', 'bulk_delete',
    'add_labels', 'remove_labels', 'bulk_add_labels', 'bulk_remove_labels',
Behavior3/5

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

Annotations already declare readOnlyHint=true, destructiveHint=false, idempotentHint=true, and openWorldHint=true. The description does not add additional behavioral context such as performance or required permissions. It is not contradictory.

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 sentences, front-loading the purpose, with zero wasted words. It is highly concise.

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?

For a simple tool with one optional parameter and no output schema, the description is adequate. It could mention the return format but is otherwise complete.

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 coverage is 100% with a clear description for the single parameter. The tool description does not add additional meaning beyond what the schema already provides. Baseline score of 3 applies.

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 'Get' and resource 'statistics for a mailbox or across the account', and specifies the type of statistics ('unread counts and total emails'). It distinguishes from sibling list/search tools.

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

Usage Guidelines5/5

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

Explicitly states when to use ('when the user wants a summary of mailbox volume or unread counts rather than individual messages') and when not to use ('Do not use for listing messages themselves').

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

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