Skip to main content
Glama
plutzilla

Omnisend MCP Server

createContact

Add or update customer profiles in Omnisend marketing platform with email, phone, subscription status, and custom data.

Instructions

Create or update a contact in Omnisend. Contact data can include identifiers (email, phone), personal information, subscription status, and custom properties.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The inline handler function for the createContact MCP tool. It calls the createOrUpdateContact API wrapper, filters the response using filterContactFields, and returns JSON stringified result or error.
    async (args) => { try { const response = await createOrUpdateContact(args.contactData); // 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" }] }; } }
  • Input schema for the createContact tool, defining contactData as an open object.
    { additionalProperties: false, properties: { contactData: { additionalProperties: true, description: "Contact data", properties: {}, type: "object" } }, required: ["contactData"], type: "object" },
  • Registration of the createContact tool using server.tool(), including name, description, input schema, and handler function.
    server.tool( "createContact", "Create or update a contact in Omnisend. Contact data can include identifiers (email, phone), personal information, subscription status, and custom properties.", { additionalProperties: false, properties: { contactData: { additionalProperties: true, description: "Contact data", properties: {}, type: "object" } }, required: ["contactData"], type: "object" }, async (args) => { try { const response = await createOrUpdateContact(args.contactData); // 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 wrapper function that performs the POST request to Omnisend /contacts endpoint to create or update a contact.
    export const createOrUpdateContact = async (contactData: Partial<Contact>): Promise<Contact> => { try { const response = await omnisendApi.post<Contact>('/contacts', contactData); return response.data; } catch (error) { if (error instanceof Error) { throw new Error(`Error creating contact: ${error.message}`); } else { throw new Error('Unknown error occurred when creating contact'); } } };
  • Helper function to filter contact object to specific allowed fields before returning in tool response.
    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 }; };
  • TypeScript interface defining the structure of a Contact object, used in API calls and filtering.
    export interface Contact { contactID: string; email?: string; phone?: string; firstName?: string; lastName?: string; status?: string; tags?: string[]; identifiers?: ContactIdentifier[]; createdAt?: string; updatedAt?: string; country?: string; state?: string; city?: string; gender?: string; birthdate?: string; [key: string]: unknown; }

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/plutzilla/omnisend-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server