get_segment
Retrieve specific customer segments by ID from the Klaviyo API using the MCP server to manage marketing automation and customer profiling effectively.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | ID of the segment to retrieve |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"id": {
"description": "ID of the segment to retrieve",
"type": "string"
}
},
"required": [
"id"
],
"type": "object"
}
Implementation Reference
- src/tools/segments.js:35-46 (handler)Handler function for the 'get_segment' tool. Fetches a specific segment from Klaviyo API using the provided ID and returns JSON stringified response or error.async (params) => { try { const segment = await klaviyoClient.get(`/segments/${params.id}/`); return { content: [{ type: "text", text: JSON.stringify(segment, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: `Error retrieving segment: ${error.message}` }], isError: true }; }
- src/tools/segments.js:32-34 (schema)Zod input schema for 'get_segment' tool, requiring a string 'id' parameter.{ id: z.string().describe("ID of the segment to retrieve") },
- src/tools/segments.js:31-48 (registration)Registration of the 'get_segment' tool on the MCP server, including name, schema, handler, and description."get_segment", { id: z.string().describe("ID of the segment to retrieve") }, async (params) => { try { const segment = await klaviyoClient.get(`/segments/${params.id}/`); return { content: [{ type: "text", text: JSON.stringify(segment, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: `Error retrieving segment: ${error.message}` }], isError: true }; } }, { description: "Get a specific segment from Klaviyo" }