get_metric
Retrieve specific marketing metrics from Klaviyo by providing the metric ID to access campaign performance data and analytics.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | ID of the metric to retrieve |
Implementation Reference
- src/tools/metrics.js:35-47 (handler)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 }; } },
- src/tools/metrics.js:32-34 (schema)Zod input validation schema for the 'get_metric' tool, defining the required 'id' parameter.{ id: z.string().describe("ID of the metric to retrieve") },
- src/tools/metrics.js:31-49 (registration)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);