get_contact
Retrieve a contact by its unique ID to access full contact details, enabling efficient lookups of contact information.
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:1268-1283 (handler)Handler for the 'get_contact' tool - extracts contactId from args, initializes the ContactsCalendarClient, and calls getContactById(). Returns the contact as formatted 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/index.ts:450-463 (schema)Input schema registration for the 'get_contact' tool - requires a contactId string parameter.
{ 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:450-463 (registration)Tool registration in the ListToolsRequestSchema handler - defines name 'get_contact', description, and inputSchema.
{ 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/contacts-calendar.ts:63-88 (helper)The actual implementation: getContactById() in ContactsCalendarClient - checks permissions, builds a JMAP ContactCard/get request with the given id, and returns the contact.
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.`); } }