Skip to main content
Glama

list_contacts

Retrieve contacts from your Fastmail address book to access and manage contact information, with optional limit settings for controlling the number of results returned.

Instructions

List contacts from the address book

Input Schema

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

Implementation Reference

  • Schema definition for the list_contacts tool, specifying input schema with optional 'limit' parameter (default 50).
    { 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, }, }, }, },
  • MCP tool handler for 'list_contacts': extracts limit from args, initializes ContactsCalendarClient, calls getContacts(limit), and returns JSON-formatted contacts.
    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), }, ], }; }
  • Core implementation of contact listing in ContactsCalendarClient: performs permission check, executes JMAP Contact/query + Contact/get requests to fetch up to 'limit' contacts with specified properties, includes 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: [ ['Contact/query', { accountId: session.accountId, limit }, 'query'], ['Contact/get', { accountId: session.accountId, '#ids': { resultOf: 'query', name: 'Contact/query', path: '/ids' }, properties: ['id', 'name', 'emails', 'phones', 'addresses', 'notes'] }, 'contacts'] ] }; try { const response = await this.makeRequest(request); return response.methodResponses[1][1].list; } 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 fallbackResponse.methodResponses[0][1].list || []; } 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.`); } } }

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