Skip to main content
Glama

create_event

Track and log customer interactions by generating events with specified metrics, profile details, and custom properties for marketing automation via Klaviyo MCP Server.

Input Schema

NameRequiredDescriptionDefault
metricYesMetric information for the event
profileYesProfile information for the event
propertiesNoAdditional properties for the event
timeNoISO timestamp for the event
valueNoNumeric value for the event

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "metric": { "additionalProperties": false, "description": "Metric information for the event", "properties": { "name": { "description": "Name of the metric", "type": "string" } }, "required": [ "name" ], "type": "object" }, "profile": { "additionalProperties": false, "description": "Profile information for the event", "properties": { "email": { "description": "Email of the customer", "format": "email", "type": "string" } }, "required": [ "email" ], "type": "object" }, "properties": { "additionalProperties": {}, "description": "Additional properties for the event", "type": "object" }, "time": { "description": "ISO timestamp for the event", "type": "string" }, "value": { "description": "Numeric value for the event", "type": "number" } }, "required": [ "metric", "profile" ], "type": "object" }

Implementation Reference

  • Handler function that formats the event payload and sends a POST request to Klaviyo's /events/ endpoint using klaviyoClient, returning the result or error.
    async (params) => { try { // Format payload according to the latest API structure const payload = { data: { type: "event", attributes: { metric: params.metric, profile: params.profile, properties: params.properties || {}, time: params.time || new Date().toISOString(), value: params.value !== undefined ? params.value : 0 } } }; const result = await klaviyoClient.post('/events/', payload); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: `Error creating event: ${error.message}` }], isError: true }; }
  • Zod schema defining input parameters: metric (with name), profile (with email), optional properties, time, and value.
    { metric: z.object({ name: z.string().describe("Name of the metric") }).describe("Metric information for the event"), profile: z.object({ email: z.string().email().describe("Email of the customer") }).describe("Profile information for the event"), properties: z.record(z.any()).optional().describe("Additional properties for the event"), time: z.string().optional().describe("ISO timestamp for the event"), value: z.number().optional().describe("Numeric value for the event") },
  • Registration of the create_event tool via server.tool, including name, schema, handler function, and description.
    server.tool( "create_event", { metric: z.object({ name: z.string().describe("Name of the metric") }).describe("Metric information for the event"), profile: z.object({ email: z.string().email().describe("Email of the customer") }).describe("Profile information for the event"), properties: z.record(z.any()).optional().describe("Additional properties for the event"), time: z.string().optional().describe("ISO timestamp for the event"), value: z.number().optional().describe("Numeric value for the event") }, async (params) => { try { // Format payload according to the latest API structure const payload = { data: { type: "event", attributes: { metric: params.metric, profile: params.profile, properties: params.properties || {}, time: params.time || new Date().toISOString(), value: params.value !== undefined ? params.value : 0 } } }; const result = await klaviyoClient.post('/events/', payload); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: `Error creating event: ${error.message}` }], isError: true }; } }, { description: "Create a new event in Klaviyo" } );

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/ivan-rivera-projects/Klaviyo-MCP-Server-Enhanced'

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