get_metric
Retrieve specific metric data by ID using this tool on the Klaviyo MCP Server, enabling precise tracking and analysis of marketing performance metrics.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | ID of the metric to retrieve |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"id": {
"description": "ID of the metric to retrieve",
"type": "string"
}
},
"required": [
"id"
],
"type": "object"
}
Implementation Reference
- src/tools/metrics.js:35-46 (handler)The handler function for the 'get_metric' tool. It fetches the metric by ID using the Klaviyo client and returns the JSON response or an error message.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 schema for input validation, requiring an 'id' string parameter.{ id: z.string().describe("ID of the metric to retrieve") },
- src/tools/metrics.js:31-49 (registration)Registration of the 'get_metric' tool on the server, including schema, handler, 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" } );