get_contact
Retrieve a specific contact from Fastmail by providing its unique ID.
Instructions
Get a specific contact by ID
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| contactId | Yes | ID of the contact to retrieve |
Implementation Reference
- src/index.ts:453-466 (registration)Tool 'get_contact' is registered in the ListToolsRequestSchema handler with its name, description, and inputSchema (requires contactId).
{ name: 'get_contact', description: 'Get a specific contact by ID', inputSchema: { type: 'object', properties: { contactId: { type: 'string', description: 'ID of the contact to retrieve', }, }, required: ['contactId'], }, }, - src/index.ts:1271-1286 (handler)The CallToolRequestSchema handler for case 'get_contact' extracts contactId, initializes the ContactsCalendarClient, and calls getContactById(contactId), returning the contact as JSON.
case 'get_contact': { const { contactId } = args as any; if (!contactId) { throw new McpError(ErrorCode.InvalidParams, 'contactId is required'); } const contactsClient = initializeContactsCalendarClient(); const contact = await contactsClient.getContactById(contactId); return { content: [ { type: 'text', text: JSON.stringify(contact, null, 2), }, ], }; } - src/contacts-calendar.ts:63-88 (handler)The getContactById method on ContactsCalendarClient checks contacts permission, builds a JMAP ContactCard/get request with the given ID, and returns the parsed contact result.
async getContactById(id: string): 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/get', { accountId: session.accountId, ids: [id] }, 'contact'] ] }; try { const response = await this.makeRequest(request); return this.getListResult(response, 0)[0]; } catch (error) { throw new Error(`Contact access not supported: ${error instanceof Error ? error.message : String(error)}. Try checking account permissions or enabling contacts API access in Fastmail settings.`); } }