Skip to main content
Glama

get_metrics

Retrieve targeted marketing metrics using a filter query, customizable page size, and pagination cursor to optimize data management and analysis via Klaviyo MCP Server.

Input Schema

NameRequiredDescriptionDefault
filterNoFilter query for metrics
page_cursorNoCursor for pagination
page_sizeNoNumber of metrics per page (1-100)

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "filter": { "description": "Filter query for metrics", "type": "string" }, "page_cursor": { "description": "Cursor for pagination", "type": "string" }, "page_size": { "description": "Number of metrics per page (1-100)", "maximum": 100, "minimum": 1, "type": "number" } }, "type": "object" }

Implementation Reference

  • Handler function for the 'get_metrics' tool. Fetches metrics data from the Klaviyo API using klaviyoClient.get and returns formatted JSON response or error message.
    async (params) => { try { const metrics = await klaviyoClient.get('/metrics/', params); return { content: [{ type: "text", text: JSON.stringify(metrics, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: `Error retrieving metrics: ${error.message}` }], isError: true }; } },
  • Zod schema defining input parameters for the 'get_metrics' tool: optional filter, page_size (1-100), and page_cursor.
    { filter: z.string().optional().describe("Filter query for metrics"), page_size: z.number().min(1).max(100).optional().describe("Number of metrics per page (1-100)"), page_cursor: z.string().optional().describe("Cursor for pagination") },
  • Registers the 'get_metrics' tool on the MCP server using server.tool, specifying name, input schema, handler function, and description.
    "get_metrics", { filter: z.string().optional().describe("Filter query for metrics"), page_size: z.number().min(1).max(100).optional().describe("Number of metrics per page (1-100)"), page_cursor: z.string().optional().describe("Cursor for pagination") }, async (params) => { try { const metrics = await klaviyoClient.get('/metrics/', params); return { content: [{ type: "text", text: JSON.stringify(metrics, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: `Error retrieving metrics: ${error.message}` }], isError: true }; } }, { description: "Get metrics from Klaviyo" } );
  • src/server.js:36-36 (registration)
    Calls registerMetricTools to register metrics-related tools including 'get_metrics' on the 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