Skip to main content
Glama

get_campaign_messages

Retrieve messages associated with a specific Klaviyo campaign by providing the campaign ID to access and manage marketing content.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
campaign_idYesID of the campaign to retrieve messages for

Implementation Reference

  • Registration of the 'get_campaign_messages' MCP tool, including inline Zod input schema, async handler function that fetches campaign messages from Klaviyo API using klaviyoClient, error handling, and tool description.
    server.tool(
      "get_campaign_messages",
      {
        campaign_id: z.string().describe("ID of the campaign to retrieve messages for")
      },
      async (params) => {
        try {
          const messages = await klaviyoClient.get(`/campaigns/${params.campaign_id}/campaign-messages/`);
          return {
            content: [{ type: "text", text: JSON.stringify(messages, null, 2) }]
          };
        } catch (error) {
          return {
            content: [{ type: "text", text: `Error retrieving campaign messages: ${error.message}` }],
            isError: true
          };
        }
      },
      { description: "Get all messages for a specific campaign" }
    );
  • src/server.js:37-37 (registration)
    Invocation of registerCampaignTools to register all campaign-related tools on the MCP server, including 'get_campaign_messages'.
    registerCampaignTools(server);
  • The core handler function for executing the 'get_campaign_messages' tool logic: calls Klaviyo API endpoint for campaign messages and returns JSON response or error.
    async (params) => {
      try {
        const messages = await klaviyoClient.get(`/campaigns/${params.campaign_id}/campaign-messages/`);
        return {
          content: [{ type: "text", text: JSON.stringify(messages, null, 2) }]
        };
      } catch (error) {
        return {
          content: [{ type: "text", text: `Error retrieving campaign messages: ${error.message}` }],
          isError: true
        };
      }
    },
  • Zod schema defining the input parameter 'campaign_id' for the tool.
    {
      campaign_id: z.string().describe("ID of the campaign to retrieve messages for")
    },

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