create_campaign
Create a new email campaign for your Mailchimp audience. Specify campaign type (regular, plaintext, A/B split, or RSS), subject line, sender details, and audience list to generate a campaign ID for further management.
Instructions
Create a new email campaign. Returns the campaign ID. Type: regular, plaintext, absplit, rss.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| list_id | Yes | ||
| subject_line | Yes | ||
| from_name | Yes | ||
| reply_to | Yes | ||
| title | No | ||
| preview_text | No | ||
| campaign_type | No | regular |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- mcp_mailchimp/server.py:133-163 (handler)The `create_campaign` tool handler function. It is an async function decorated with @mcp.tool() that takes list_id, subject_line, from_name, reply_to (required), plus optional title, preview_text, and campaign_type. It builds the request body and posts to the Mailchimp /campaigns endpoint, returning the new campaign ID, status, and title.
@mcp.tool() async def create_campaign( list_id: str, subject_line: str, from_name: str, reply_to: str, title: str = "", preview_text: str = "", campaign_type: str = "regular", ) -> str: """Create a new email campaign. Returns the campaign ID. Type: regular, plaintext, absplit, rss.""" mc = get_client() body: dict[str, Any] = { "type": campaign_type, "recipients": {"list_id": list_id}, "settings": { "subject_line": subject_line, "from_name": from_name, "reply_to": reply_to, "title": title or subject_line, }, } if preview_text: body["settings"]["preview_text"] = preview_text c = await mc.post("/campaigns", json=body) return _fmt({ "id": c["id"], "status": c.get("status", ""), "title": c.get("settings", {}).get("title", ""), "message": "Campaign created successfully.", }) - mcp_mailchimp/server.py:11-20 (registration)The FastMCP server instance (`mcp`) used to register tools via the @mcp.tool() decorator. The `create_campaign` function is registered this way on line 133.
mcp = FastMCP( "mcp-mailchimp", instructions=( "Production-grade MCP server for the Mailchimp Marketing API. " "71 tools for campaigns, audiences, members, tags, segments, " "templates, reports, automations, webhooks, merge fields, " "interest groups, landing pages, batch operations, e-commerce, " "A/B testing, member notes, file manager, and audience analytics." ), ) - mcp_mailchimp/server.py:134-142 (schema)The function signature and docstring act as the input schema — the parameter names, types, defaults, and descriptions define what inputs the tool accepts (list_id, subject_line, from_name, reply_to, title, preview_text, campaign_type).
async def create_campaign( list_id: str, subject_line: str, from_name: str, reply_to: str, title: str = "", preview_text: str = "", campaign_type: str = "regular", ) -> str: