Skip to main content
Glama

create_tag

Create a new tag in Klaviyo to organize and categorize customer profiles for targeted marketing and segmentation.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesName of the tag
tag_typeYesType of tag

Implementation Reference

  • 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
        };
      }
    },
  • 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")
    },
  • 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);

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