Skip to main content
Glama
MadLlama25

Fastmail MCP Server

by MadLlama25

search_contacts

Search your Fastmail contacts by name or email address. Returns matching contacts with default limit of 20; specify limit for more or fewer results.

Instructions

Search contacts by name or email

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch query string
limitNoMaximum number of results (default: 20)

Implementation Reference

  • The searchContacts method on ContactsCalendarClient executes the contact search logic. It checks JMAP contacts permissions, builds a JMAP request using ContactCard/query with a text filter and ContactCard/get to retrieve contact details (id, name, emails, phones, addresses, notes), and returns the results.
    async searchContacts(query: string, limit: number = 20): Promise<any[]> {
      // Check permissions first
      const hasPermission = await this.checkContactsPermission();
      if (!hasPermission) {
        throw new Error('Contacts access not available. This account may not have JMAP contacts permissions enabled. Please check your Fastmail account settings or contact support to enable contacts API access.');
      }
    
      const session = await this.getSession();
      
      const request: JmapRequest = {
        using: ['urn:ietf:params:jmap:core', 'urn:ietf:params:jmap:contacts'],
        methodCalls: [
          ['ContactCard/query', {
            accountId: session.accountId,
            filter: { text: query },
            limit
          }, 'query'],
          ['ContactCard/get', {
            accountId: session.accountId,
            '#ids': { resultOf: 'query', name: 'ContactCard/query', path: '/ids' },
            properties: ['id', 'name', 'emails', 'phones', 'addresses', 'notes']
          }, 'contacts']
        ]
      };
    
      try {
        const response = await this.makeRequest(request);
        return this.getListResult(response, 1);
      } catch (error) {
        throw new Error(`Contact search not supported: ${error instanceof Error ? error.message : String(error)}. Try checking account permissions or enabling contacts API access in Fastmail settings.`);
      }
    }
  • Input schema registration for the 'search_contacts' tool. Defines 'query' (required, string) and 'limit' (optional number, default 20) parameters.
    {
      name: 'search_contacts',
      description: 'Search contacts by name or email',
      inputSchema: {
        type: 'object',
        properties: {
          query: {
            type: 'string',
            description: 'Search query string',
          },
          limit: {
            type: 'number',
            description: 'Maximum number of results (default: 20)',
            default: 20,
          },
        },
        required: ['query'],
      },
  • src/index.ts:1285-1300 (registration)
    The CallToolRequestSchema handler case for 'search_contacts'. It extracts query and limit from args, initializes the ContactsCalendarClient, calls searchContacts(query, limit), and returns the results as JSON.
    case 'search_contacts': {
      const { query, limit = 20 } = args as any;
      if (!query) {
        throw new McpError(ErrorCode.InvalidParams, 'query is required');
      }
      const contactsClient = initializeContactsCalendarClient();
      const contacts = await contactsClient.searchContacts(query, limit);
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(contacts, null, 2),
          },
        ],
      };
    }
  • Helper function initializeContactsCalendarClient() that creates and caches a ContactsCalendarClient instance used by the search_contacts handler.
    function initializeContactsCalendarClient(): ContactsCalendarClient {
      if (contactsCalendarClient) {
        return contactsCalendarClient;
      }
    
      const auth = new FastmailAuth(getAuthConfig());
      contactsCalendarClient = new ContactsCalendarClient(auth);
      return contactsCalendarClient;
    }
Behavior2/5

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

No annotations are provided, and the description lacks details on behavior such as case sensitivity, fuzzy matching, response format, or side effects (though search is likely non-destructive). It only states the basic function.

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?

The description is extremely concise, using a single sentence with no verbose or redundant phrases. It could benefit from more detail but remains efficient.

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?

With no output schema and minimal description, the tool lacks completeness. It does not explain return values, pagination, filtering behavior, or error handling, which are important for a search tool.

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%, and the description adds context that the 'query' parameter is for name or email, improving upon the schema's generic 'Search query string' description. However, no additional parameter details are given.

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 tool searches contacts by name or email, distinguishing it from siblings like 'list_contacts' (lists all contacts) and 'get_contact' (retrieves a specific contact).

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 use when you need to find contacts by querying name or email, but it does not explicitly contrast with alternatives or provide conditions for when not to use it.

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

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