Skip to main content
Glama
owen-nash

Fastmail MCP Server

by owen-nash

get_recent_emails

Fetch the most recent emails from a specified mailbox, with configurable count and sorting direction.

Instructions

Get the most recent emails from inbox (like top-ten)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoNumber of recent emails to retrieve (default: 10, max: 50)
mailboxNameNoMailbox to search (default: inbox)inbox
ascendingNoSort oldest first instead of newest first (default: false)

Implementation Reference

  • The getRecentEmails method on JmapClient queries a mailbox (defaults to inbox) and returns the most recent emails. It resolves the mailbox by role or name, then performs an Email/query + Email/get JMAP call.
    async getRecentEmails(limit: number = 10, mailboxName: string = 'inbox', ascending: boolean = false): Promise<any[]> {
      const session = await this.getSession();
      
      // 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}`);
      }
    
      const request: JmapRequest = {
        using: ['urn:ietf:params:jmap:core', 'urn:ietf:params:jmap:mail'],
        methodCalls: [
          ['Email/query', {
            accountId: session.accountId,
            filter: { inMailbox: targetMailbox.id },
            sort: [{ property: 'receivedAt', isAscending: ascending }],
            limit: Math.min(limit, 50)
          }, 'query'],
          ['Email/get', {
            accountId: session.accountId,
            '#ids': { resultOf: 'query', name: 'Email/query', path: '/ids' },
            properties: ['id', 'subject', 'from', 'to', 'replyTo', 'receivedAt', 'preview', 'hasAttachment', 'keywords', 'header:List-Unsubscribe:asURLs']
          }, 'emails']
        ]
      };
    
      const response = await this.makeRequest(request);
      return this.getListResult(response, 1);
    }
  • src/index.ts:588-609 (registration)
    Tool registration schema for 'get_recent_emails' defining the input parameters (limit, mailboxName, ascending) with descriptions and defaults.
      name: 'get_recent_emails',
      description: 'Get the most recent emails from inbox (like top-ten)',
      inputSchema: {
        type: 'object',
        properties: {
          limit: {
            type: ['number', 'string'],
            description: 'Number of recent emails to retrieve (default: 10, max: 50)',
            default: 10,
          },
          mailboxName: {
            type: 'string',
            description: 'Mailbox to search (default: inbox)',
            default: 'inbox',
          },
          ascending: {
            type: 'boolean',
            description: 'Sort oldest first instead of newest first (default: false)',
          },
        },
      },
    },
  • Call handler in index.ts that extracts arguments (limit, mailboxName, ascending) and delegates to client.getRecentEmails(), returning JSON results.
    case 'get_recent_emails': {
      const { limit = 10, mailboxName = 'inbox', ascending } = args as any;
      const client = initializeClient();
      const emails = await client.getRecentEmails(limit, mailboxName, !!ascending);
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(emails, null, 2),
          },
        ],
      };
    }
Behavior2/5

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

With no annotations, description should disclose behavioral traits. It only states it gets recent emails, but does not mention read-only nature, response format, or any side effects.

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, no wasted words. Informal 'like top-ten' adds clarity without excess.

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?

Adequate for basic retrieval, but lacks explanation of return values (no output schema) and could mislead on scope (e.g., only inbox? default mailbox parameter says 'inbox' but not stated in description).

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 descriptions cover all 3 parameters. Description adds no extra meaning beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

Clearly states it retrieves recent emails from inbox, with 'like top-ten' adding specificity. However, it does not explicitly differentiate from sibling tools like list_emails or search_emails.

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, nor any conditions or exclusions.

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