get_template
Retrieve a specific template by its ID using the Klaviyo MCP Server. This tool simplifies accessing and managing email templates for marketing automation workflows.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | ID of the template to retrieve |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"id": {
"description": "ID of the template to retrieve",
"type": "string"
}
},
"required": [
"id"
],
"type": "object"
}
Implementation Reference
- src/tools/templates.js:35-47 (handler)The async handler function that fetches the specific template by ID from the Klaviyo API using klaviyoClient.get, formats it as JSON, and handles errors.async (params) => { try { const template = await klaviyoClient.get(`/templates/${params.id}/`); return { content: [{ type: "text", text: JSON.stringify(template, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: `Error retrieving template: ${error.message}` }], isError: true }; } },
- src/tools/templates.js:32-34 (schema)Zod input schema defining the required 'id' parameter as a string.{ id: z.string().describe("ID of the template to retrieve") },
- src/tools/templates.js:31-49 (registration)The server.tool call that registers the 'get_template' tool, including name, schema, handler, and description."get_template", { id: z.string().describe("ID of the template to retrieve") }, async (params) => { try { const template = await klaviyoClient.get(`/templates/${params.id}/`); return { content: [{ type: "text", text: JSON.stringify(template, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: `Error retrieving template: ${error.message}` }], isError: true }; } }, { description: "Get a specific template from Klaviyo" } );
- src/server.js:40-40 (registration)The call to registerTemplateTools which includes registration of the 'get_template' tool.registerTemplateTools(server);
- src/server.js:11-11 (registration)Import of the registerTemplateTools function from templates.js.import { registerTemplateTools } from './tools/templates.js';