Skip to main content
Glama
owen-nash

Fastmail MCP Server

by owen-nash

get_mailbox_stats

Retrieve mailbox statistics including unread count and total emails 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

  • src/index.ts:826-838 (registration)
    Tool registration for 'get_mailbox_stats' in the ListToolsRequestSchema handler, defining the name, description, and input schema (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)',
          },
        },
      },
    },
  • Handler for the 'get_mailbox_stats' tool in the CallToolRequestSchema switch. Extracts mailboxId from args, calls client.getMailboxStats(mailboxId), and returns the result 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),
          },
        ],
      };
    }
  • The actual business logic implementation in JmapClient.getMailboxStats(). If mailboxId is provided, calls Mailbox/get with specific properties (totalEmails, unreadEmails, totalThreads, unreadThreads). Otherwise, gets all mailboxes via getMailboxes() and maps to the stats structure.
    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
        }));
      }
    }
Behavior2/5

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

The description discloses the purpose but lacks any behavioral details beyond that. Since annotations are absent, the description should mention that this is a read operation, potential permissions required, or what happens if the mailbox ID is invalid. No such information is provided.

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 a single concise sentence with no redundant words. It efficiently communicates the tool's core function.

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?

Given the tool's simplicity (1 optional param, no output schema), the description is minimally adequate but could be more complete by detailing the return format or providing an example. Without an output schema, more context about the returned object structure would improve completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema covers 100% of parameter descriptions (defaults to all mailboxes). The tool description adds meaning by specifying what kind of statistics are returned ('unread count, total emails, etc.'), which is not in the schema.

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', the resource 'mailbox statistics', and examples of statistics ('unread count, total emails, etc.'). It distinguishes from sibling tools like list_mailboxes which list mailbox metadata.

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

Usage Guidelines3/5

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

The description implies the tool is used to retrieve mailbox statistics, but provides no explicit when-to-use guidance or alternatives. The context of when to choose get_mailbox_stats over other tools like list_mailboxes or get_account_summary is left implicit.

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

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