create_tag
Create a new tag in Klaviyo to organize and categorize customer profiles for targeted marketing and segmentation.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Name of the tag | |
| tag_type | Yes | Type of tag |
Implementation Reference
- src/tools/tags.js:36-58 (handler)The handler function for 'create_tag' tool. Constructs the tag payload and sends a POST request to Klaviyo's /tags/ endpoint using klaviyoClient, returns the result or error.async (params) => { try { const payload = { data: { type: "tag", attributes: { name: params.name, tag_type: params.tag_type } } }; const result = await klaviyoClient.post('/tags/', payload); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: `Error creating tag: ${error.message}` }], isError: true }; } },
- src/tools/tags.js:32-35 (schema)Zod input schema for 'create_tag' tool: requires 'name' (string) and 'tag_type' (enum: 'system' or 'custom').{ name: z.string().describe("Name of the tag"), tag_type: z.enum(["system", "custom"]).describe("Type of tag") },
- src/tools/tags.js:30-60 (registration)Direct registration of the 'create_tag' tool using server.tool, including name, schema, handler, and description.server.tool( "create_tag", { name: z.string().describe("Name of the tag"), tag_type: z.enum(["system", "custom"]).describe("Type of tag") }, async (params) => { try { const payload = { data: { type: "tag", attributes: { name: params.name, tag_type: params.tag_type } } }; const result = await klaviyoClient.post('/tags/', payload); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: `Error creating tag: ${error.message}` }], isError: true }; } }, { description: "Create a new tag in Klaviyo" } );
- src/server.js:42-42 (registration)Invocation of registerTagTools(server) which registers the 'create_tag' tool (and other tag tools) on the MCP server.registerTagTools(server);