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
| Name | Required | Description | Default |
|---|---|---|---|
| campaign_id | Yes | ID of the campaign to retrieve messages for |
Implementation Reference
- src/tools/campaigns.js:79-98 (registration)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);
- src/tools/campaigns.js:84-96 (handler)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 }; } },
- src/tools/campaigns.js:81-83 (schema)Zod schema defining the input parameter 'campaign_id' for the tool.{ campaign_id: z.string().describe("ID of the campaign to retrieve messages for") },