list_campaigns
Retrieve email campaigns from Mailchimp, filtered by status or audience list ID, to review campaign details and performance data.
Instructions
List email campaigns. Filter by status (save, paused, schedule, sending, sent) or audience list_id.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| status | No | ||
| list_id | No | ||
| count | No | ||
| offset | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- mcp_mailchimp/server.py:75-102 (handler)The list_campaigns tool handler — an async function decorated with @mcp.tool() that calls the Mailchimp API GET /campaigns, formats campaign results, and returns them as indented JSON. Accepts optional filters: status, list_id, count, offset.
@mcp.tool() async def list_campaigns( status: str = "", list_id: str = "", count: int = 20, offset: int = 0, ) -> str: """List email campaigns. Filter by status (save, paused, schedule, sending, sent) or audience list_id.""" mc = get_client() params: dict[str, Any] = {"count": min(count, 100), "offset": offset} if status: params["status"] = status if list_id: params["list_id"] = list_id data = await mc.get("/campaigns", params=params) campaigns = [] for c in data.get("campaigns", []): s = c.get("settings", {}) campaigns.append({ "id": c["id"], "title": s.get("title", ""), "subject_line": s.get("subject_line", ""), "status": c.get("status", ""), "type": c.get("type", ""), "send_time": c.get("send_time"), "emails_sent": c.get("emails_sent", 0), }) return _fmt({"total_items": data.get("total_items", 0), "campaigns": campaigns}) - mcp_mailchimp/server.py:75-75 (registration)Registration using the @mcp.tool() decorator on the list_campaigns function, which registers it with the FastMCP server instance.
@mcp.tool()