getContact
Retrieve detailed contact information using a unique identifier to enhance personalization and management within the Omnisend marketing platform.
Instructions
Retrieve detailed information about a specific contact by their unique identifier.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| contactId | Yes | Contact ID |
Implementation Reference
- src/tools/contacts/index.ts:93-126 (registration)MCP tool registration for 'getContact', including description, input schema, and inline handler function that calls API and returns filtered JSON.server.tool( "getContact", "Retrieve detailed information about a specific contact by their unique identifier.", { additionalProperties: false, properties: { contactId: { description: "Contact ID", type: "string" } }, required: ["contactId"], type: "object" }, async (args) => { try { const response = await getContact(args.contactId); // Filter contact data to include only defined fields const filteredContact = filterContactFields(response); return { content: [ { type: "text", text: JSON.stringify(filteredContact, null, 2) } ] }; } catch (error) { if (error instanceof Error) { return { content: [{ type: "text", text: `Error: ${error.message}` }] }; } return { content: [{ type: "text", text: "An unknown error occurred" }] }; } } );
- API handler function that performs the HTTP GET request to retrieve specific contact data from Omnisend API.export const getContact = async (contactId: string): Promise<Contact> => { try { const response = await omnisendApi.get<Contact>(`/contacts/${contactId}`); return response.data; } catch (error) { if (error instanceof Error) { throw new Error(`Error getting contact information: ${error.message}`); } else { throw new Error('Unknown error occurred when getting contact'); } }
- src/filters/contacts/index.ts:2-21 (helper)Helper function to filter and select specific fields from the raw contact object for safe exposure.export const filterContactFields = (contact: any) => { return { contactID: contact.contactID, email: contact.email, phone: contact.phone, firstName: contact.firstName, lastName: contact.lastName, status: contact.status, tags: contact.tags, identifiers: contact.identifiers, createdAt: contact.createdAt, updatedAt: contact.updatedAt, // Include added fields country: contact.country, state: contact.state, city: contact.city, gender: contact.gender, birthdate: contact.birthdate }; };