Skip to main content
Glama
owen-nash

Fastmail MCP Server

by owen-nash

list_contacts

Retrieve contacts from the address book with an optional limit on the number of results.

Instructions

List contacts from the address book

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum number of contacts to return (default: 50)

Implementation Reference

  • Handler for the list_contacts tool. Calls initializeContactsCalendarClient() to get a ContactsCalendarClient, then calls contactsClient.getContacts(limit) with the provided limit (default 50). Returns the contacts as JSON.
    case 'list_contacts': {
      const { limit = 50 } = args as any;
      const contactsClient = initializeContactsCalendarClient();
      const contacts = await contactsClient.getContacts(limit);
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(contacts, null, 2),
          },
        ],
      };
    }
  • src/index.ts:439-452 (registration)
    Registration/schema definition for the list_contacts tool. Declares the tool name, description, and input schema (optional limit parameter with default 50). Registered in the ListToolsRequestSchema handler.
    {
      name: 'list_contacts',
      description: 'List contacts from the address book',
      inputSchema: {
        type: 'object',
        properties: {
          limit: {
            type: 'number',
            description: 'Maximum number of contacts to return (default: 50)',
            default: 50,
          },
        },
      },
    },
  • initializeContactsCalendarClient() helper function that creates (or returns cached) ContactsCalendarClient instance used by list_contacts handler.
    function initializeContactsCalendarClient(): ContactsCalendarClient {
      if (contactsCalendarClient) {
        return contactsCalendarClient;
      }
    
      const auth = new FastmailAuth(getAuthConfig());
      contactsCalendarClient = new ContactsCalendarClient(auth);
      return contactsCalendarClient;
    }
  • The actual implementation: ContactsCalendarClient.getContacts() method. Makes JMAP requests using ContactCard/query and ContactCard/get to fetch contacts from Fastmail's address book, with a fallback to AddressBook/get.
    async getContacts(limit: number = 50): 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();
      
      // Try CardDAV namespace first, then Fastmail specific
      const request: JmapRequest = {
        using: ['urn:ietf:params:jmap:core', 'urn:ietf:params:jmap:contacts'],
        methodCalls: [
          ['ContactCard/query', {
            accountId: session.accountId,
            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) {
        // Fallback: try to get contacts using AddressBook methods
        const fallbackRequest: JmapRequest = {
          using: ['urn:ietf:params:jmap:core', 'urn:ietf:params:jmap:contacts'],
          methodCalls: [
            ['AddressBook/get', {
              accountId: session.accountId
            }, 'addressbooks']
          ]
        };
        
        try {
          const fallbackResponse = await this.makeRequest(fallbackRequest);
          return this.getListResult(fallbackResponse, 0);
        } catch (fallbackError) {
          throw new Error(`Contacts not supported or accessible: ${error instanceof Error ? error.message : String(error)}. Try checking account permissions or enabling contacts API access in Fastmail settings.`);
        }
      }
    }
  • ContactsCalendarClient class definition extending JmapClient, including checkContactsPermission() method that validates JMAP contacts capability is available.
    export class ContactsCalendarClient extends JmapClient {
      
      private async checkContactsPermission(): Promise<boolean> {
        const session = await this.getSession();
        return !!session.capabilities['urn:ietf:params:jmap:contacts'];
      }
      
      private async checkCalendarsPermission(): Promise<boolean> {
        const session = await this.getSession();
        return !!session.capabilities['urn:ietf:params:jmap:calendars'];
      }
Behavior2/5

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

With no annotations, the description should disclose behavioral traits like read-only nature, pagination behavior, and ordering, but it only states 'list contacts'. It does not confirm the operation is non-destructive or describe 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.

Conciseness5/5

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

The description is a single clear sentence with no redundant words. Every word contributes to the purpose, making it highly concise and effectively front-loaded.

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?

For a simple list tool with one optional parameter, the description is minimally adequate. However, it is incomplete as it does not specify which address book is used, how contacts are ordered, or what happens when the limit is exceeded. More context would improve utility.

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?

The schema provides 100% coverage of the single 'limit' parameter, including its default value. The description adds no additional meaning beyond the schema, so baseline score of 3 is appropriate.

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 uses a specific verb 'list' and resource 'contacts' from 'the address book', clearly indicating the tool's function. It distinguishes itself from siblings like 'search_contacts' (filtered search) and 'get_contact' (single contact retrieval).

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?

There is no guidance on when to use this tool versus alternatives such as 'search_contacts' for filtered queries or 'get_contact' for a single contact. The description does not mention exclusions or prerequisites.

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