get_campaign
Retrieve detailed campaign information by providing its unique ID using the Klaviyo MCP Server, enabling efficient campaign management and analysis.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | ID of the campaign to retrieve |
Implementation Reference
- src/tools/campaigns.js:38-50 (handler)The handler function for the 'get_campaign' tool. It fetches the specific campaign by ID using the Klaviyo client and returns the JSON data or an error response.async (params) => { try { const campaign = await klaviyoClient.get(`/campaigns/${params.id}/`); return { content: [{ type: "text", text: JSON.stringify(campaign, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: `Error retrieving campaign: ${error.message}` }], isError: true }; } },
- src/tools/campaigns.js:36-37 (schema)Zod schema for the input parameter 'id' of the campaign.id: z.string().describe("ID of the campaign to retrieve") },
- src/tools/campaigns.js:34-52 (registration)The registration of the 'get_campaign' tool using server.tool, including name, schema, handler, and description."get_campaign", { id: z.string().describe("ID of the campaign to retrieve") }, async (params) => { try { const campaign = await klaviyoClient.get(`/campaigns/${params.id}/`); return { content: [{ type: "text", text: JSON.stringify(campaign, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: `Error retrieving campaign: ${error.message}` }], isError: true }; } }, { description: "Get a specific campaign from Klaviyo" } );