Skip to main content
Glama
dazanza
by dazanza

set_campaign_content

Set HTML or plain-text content for Mailchimp campaigns using custom HTML or template IDs to define email content.

Instructions

Set the HTML/plain-text content for a campaign. Provide either html for custom content or template_id to use a Mailchimp template.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
campaign_idYesCampaign ID
htmlNoFull HTML content for the email
plain_textNoPlain text version of the email
template_idNoMailchimp template ID to use instead of raw HTML

Implementation Reference

  • The set_campaign_content tool is registered and implemented in server.js, handling input validation for campaign content and interaction with the Mailchimp campaigns API.
    server.tool(
      "set_campaign_content",
      "Set the HTML/plain-text content for a campaign. Provide either html for custom content or template_id to use a Mailchimp template.",
      {
        campaign_id: z.string().describe("Campaign ID"),
        html: z.string().optional().describe("Full HTML content for the email"),
        plain_text: z.string().optional().describe("Plain text version of the email"),
        template_id: z.number().optional().describe("Mailchimp template ID to use instead of raw HTML"),
      },
      async ({ campaign_id, html, plain_text, template_id }) => {
        if (!html && !template_id) {
          return {
            content: [{ type: "text", text: JSON.stringify({ error: "Must provide either 'html' or 'template_id'" }, null, 2) }],
            isError: true,
          };
        }
        const body = {};
        if (html && template_id) {
          // html and template_id are mutually exclusive in Mailchimp API.
          // When both are sent, Mailchimp silently ignores html and uses the template.
          // Prefer html (the explicit content) and warn.
          body.html = html;
          if (plain_text) body.plain_text = plain_text;
          const response = await mailchimp.campaigns.setContent(campaign_id, body);
          return {
            content: [
              {
                type: "text",
                text: JSON.stringify({
                  success: true,
                  warning: "Both html and template_id were provided. Used html only — Mailchimp ignores html when template is also set.",
                  has_html: !!response.html,
                  has_plain_text: !!response.plain_text,
                }, null, 2),
              },
            ],
          };
        }
        if (template_id) {
          body.template = { id: template_id };
        }
        if (html) {
          body.html = html;
        }
        if (plain_text) {
          body.plain_text = plain_text;
        }
        const response = await mailchimp.campaigns.setContent(campaign_id, body);
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify({ success: true, has_html: !!response.html, has_plain_text: !!response.plain_text }, null, 2),
            },
          ],
        };
      }
    );

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/dazanza/mailchimp-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server