get_campaign_messages
Retrieve messages associated with a specific campaign using the campaign ID. This tool integrates with the Klaviyo MCP Server to access and manage marketing automation features efficiently.
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:84-96 (handler)The handler function that fetches campaign messages for a given campaign_id using klaviyoClient.get and returns the JSON response or an error message.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)Input schema validating the campaign_id parameter as a string.{ campaign_id: z.string().describe("ID of the campaign to retrieve messages for") },
- src/tools/campaigns.js:79-98 (registration)Registers the get_campaign_messages tool with the MCP server, specifying name, input schema, handler function, and 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" } );