Skip to main content
Glama
owen-nash

Fastmail MCP Server

by owen-nash

search_emails

Search emails by subject or content. Specify a query, limit results, and sort oldest first if needed.

Instructions

Search emails by subject or content

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch query string
limitNoMaximum number of results (default: 20)
ascendingNoSort oldest first instead of newest first (default: false)

Implementation Reference

  • src/index.ts:416-438 (registration)
    Tool registration for 'search_emails' — defines the name, description, and input schema (query, limit, ascending) in the ListTools handler.
    {
      name: 'search_emails',
      description: 'Search emails by subject or content',
      inputSchema: {
        type: 'object',
        properties: {
          query: {
            type: 'string',
            description: 'Search query string',
          },
          limit: {
            type: ['number', 'string'],
            description: 'Maximum number of results (default: 20)',
            default: 20,
          },
          ascending: {
            type: 'boolean',
            description: 'Sort oldest first instead of newest first (default: false)',
          },
        },
        required: ['query'],
      },
    },
  • Handler for the 'search_emails' tool call — extracts query, limit, ascending args, validates query is present, and delegates to client.searchEmails().
    case 'search_emails': {
      const { query, limit, ascending } = args as any;
      if (!query) {
        throw new McpError(ErrorCode.InvalidParams, 'query is required');
      }
      const validLimit = Math.min(Math.max(Number(limit) || 20, 1), 100);
      const emails = await client.searchEmails(query, validLimit, !!ascending);
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(emails, null, 2),
          },
        ],
      };
    }
  • Actual implementation of searchEmails() on JmapClient — builds a JMAP Email/query with a text filter, then fetches matching emails via Email/get.
    async searchEmails(query: string, limit: number = 20, ascending: boolean = false): Promise<any[]> {
      const session = await this.getSession();
    
      const request: JmapRequest = {
        using: ['urn:ietf:params:jmap:core', 'urn:ietf:params:jmap:mail'],
        methodCalls: [
          ['Email/query', {
            accountId: session.accountId,
            filter: { text: query },
            sort: [{ property: 'receivedAt', isAscending: ascending }],
            limit
          }, 'query'],
          ['Email/get', {
            accountId: session.accountId,
            '#ids': { resultOf: 'query', name: 'Email/query', path: '/ids' },
            properties: ['id', 'subject', 'from', 'to', 'replyTo', 'receivedAt', 'preview', 'hasAttachment']
          }, 'emails']
        ]
      };
    
      const response = await this.makeRequest(request);
      return this.getListResult(response, 1);
    }
  • Input schema for search_emails — requires 'query' (string), optional 'limit' (number/string, default 20), optional 'ascending' (boolean).
    inputSchema: {
      type: 'object',
      properties: {
        query: {
          type: 'string',
          description: 'Search query string',
        },
        limit: {
          type: ['number', 'string'],
          description: 'Maximum number of results (default: 20)',
          default: 20,
        },
        ascending: {
          type: 'boolean',
          description: 'Sort oldest first instead of newest first (default: false)',
        },
      },
      required: ['query'],
    },
Behavior2/5

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

With no annotations, the description must disclose behavioral traits. It only implies a read operation through 'search', but does not specify permissions, rate limits, or whether it searches body content or just subject. Minimal transparency beyond the obvious.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single short sentence, which is concise but may be too brief to convey important nuances. It is front-loaded but lacks structure; every word earns its place, but more detail would improve clarity.

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

Completeness2/5

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

Given no output schema and no annotations, the description lacks completeness. It does not describe return format, pagination behavior, or how sorting interacts with the 'ascending' parameter. Also, it fails to distinguish this tool from the similar 'advanced_search' sibling.

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 each parameter already has a description. The tool description adds no extra meaning beyond what the schema provides, but it does not contradict it either. Baseline score of 3 is appropriate.

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?

The description clearly states the tool searches emails by subject or content, which is a specific and understandable purpose. However, it does not differentiate from the 'advanced_search' sibling tool, which likely offers more complex querying capabilities.

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 is provided on when to use this tool versus alternatives like 'advanced_search' or 'list_emails'. There is no mention of when-not-to-use or context-appropriate conditions.

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