Skip to main content
Glama
as-j

Fastmail MCP Server

by as-j

get_recent_emails

Read-onlyIdempotent

Retrieve paginated summaries of recent emails from your Fastmail Inbox or another mailbox. Ideal for checking email or seeing what just arrived.

Instructions

Get the newest email summaries from a Fastmail mailbox, defaulting to Inbox, in paginated form. Use when the user says "check email", "read my inbox", "show recent emails", or asks what just arrived. Returns items, total, has_more, and next_offset so the caller can keep paging only when needed. Use mailboxName to target another mailbox. Do not use when you need full message content for a known emailId (use get_email) or when you need filtered search results (use search_emails or advanced_search).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoNumber of recent emails to retrieve (default: 10, max: 50)
mailboxNameNoMailbox to search (default: inbox)inbox
offsetNoZero-based offset for pagination. Use next_offset from the previous response to fetch the next page.

Implementation Reference

  • The MCP server handler for the 'get_recent_emails' tool. It extracts limit/mailboxName/offset args, calls client.getRecentEmails(), and returns the result as JSON.
    case 'get_recent_emails': {
      const { limit = 10, mailboxName = 'inbox', offset = 0 } = args as any;
      const emails = await client.getRecentEmails(limit, mailboxName, offset);
      return { content: [{ type: 'text', text: JSON.stringify(emails, null, 2) }] };
    }
  • The JMAP client method 'getRecentEmails' that resolves the mailbox by name, then calls queryEmails with the mailbox filter and desired properties.
    async getRecentEmails(
      limit: number = 10,
      mailboxName: string = 'inbox',
      offset: number = 0,
    ): Promise<PaginatedResult<any>> {
      // Find the specified mailbox (default to inbox)
      const mailboxes = await this.getMailboxes();
      const targetMailbox = mailboxes.find(mb => 
        mb.role === mailboxName.toLowerCase() || 
        mb.name.toLowerCase().includes(mailboxName.toLowerCase())
      );
      
      if (!targetMailbox) {
        throw new Error(`Could not find mailbox: ${mailboxName}`);
      }
    
      return this.queryEmails({
        filter: { inMailbox: targetMailbox.id },
        properties: ['id', 'subject', 'from', 'to', 'receivedAt', 'preview', 'hasAttachment', 'keywords'],
        limit,
        offset,
        defaultLimit: 10,
      });
    }
  • The tool definition (schema) for 'get_recent_emails' including title, description, and input schema with limit, mailboxName, and offset properties.
    readTool(
      'get_recent_emails',
      'Get Recent Emails',
      description(
        'Get the newest email summaries from a Fastmail mailbox, defaulting to Inbox, in paginated form.',
        'Use when the user says "check email", "read my inbox", "show recent emails", or asks what just arrived.',
        'Returns items, total, has_more, and next_offset so the caller can keep paging only when needed.',
        'Use mailboxName to target another mailbox. Do not use when you need full message content for a known emailId (use get_email) or when you need filtered search results (use search_emails or advanced_search).',
      ),
      {
        type: 'object',
        properties: {
          limit: {
            ...numberLikeSchema,
            description: 'Number of recent emails to retrieve (default: 10, max: 50)',
            default: 10,
          },
          mailboxName: {
            type: 'string',
            description: 'Mailbox to search (default: inbox)',
            default: 'inbox',
          },
          offset: {
            ...numberLikeSchema,
            description: 'Zero-based offset for pagination. Use next_offset from the previous response to fetch the next page.',
            default: 0,
          },
        },
      },
  • Tool registration: TOOL_DEFINITIONS are passed to ListToolsRequestSchema handler, and the 'get_recent_emails' case is handled in the CallToolRequestSchema switch.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: TOOL_DEFINITIONS }));
    
    server.setRequestHandler(CallToolRequestSchema, async (request) => {
Behavior5/5

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

Annotations already declare readOnlyHint, idempotentHint, etc. Description adds details about return structure (items, total, has_more, next_offset) for pagination, which is valuable behavioral context beyond annotations.

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?

Concise and well-structured: first sentence states purpose, second gives usage triggers, third explains return format, fourth provides exclusion guidance. No unnecessary words, each sentence earns its place.

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

Completeness5/5

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

Given no output schema, description explains return fields for pagination. Covers when to use and not use, referencing siblings. Complete enough for the agent to select and invoke correctly.

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%, so the schema already documents all parameters' meanings and defaults. Description merely echoes 'defaulting to Inbox' and 'mailboxName to target another mailbox', adding no new semantic value beyond what the schema provides.

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 it retrieves newest email summaries from a mailbox, defaulting to Inbox, in paginated form. Distinguishes from siblings like get_email and search_emails by specifying scope and purpose.

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 lists user utterances that trigger this tool ('check email', 'read my inbox', etc.) and provides clear exclusions with alternative tool names (get_email, search_emails, advanced_search). Excellent guidance.

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