Skip to main content
Glama

get_metric

Retrieve specific marketing metrics from Klaviyo by providing the metric ID to access campaign performance data and analytics.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesID of the metric to retrieve

Implementation Reference

  • Handler function that implements the core logic of the 'get_metric' tool by calling the Klaviyo API with the provided metric ID and formatting the response.
    async (params) => { try { const metric = await klaviyoClient.get(`/metrics/${params.id}/`); return { content: [{ type: "text", text: JSON.stringify(metric, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: `Error retrieving metric: ${error.message}` }], isError: true }; } },
  • Zod input validation schema for the 'get_metric' tool, defining the required 'id' parameter.
    { id: z.string().describe("ID of the metric to retrieve") },
  • Registers the 'get_metric' MCP tool on the server with name, input schema, handler function, and description.
    "get_metric", { id: z.string().describe("ID of the metric to retrieve") }, async (params) => { try { const metric = await klaviyoClient.get(`/metrics/${params.id}/`); return { content: [{ type: "text", text: JSON.stringify(metric, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: `Error retrieving metric: ${error.message}` }], isError: true }; } }, { description: "Get a specific metric from Klaviyo" } );
  • src/server.js:36-36 (registration)
    Top-level call to registerMetricTools, which sets up the 'get_metric' tool among others on the main MCP server.
    registerMetricTools(server);

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