list_segments
Retrieve saved audience segments from Mailchimp to organize and target specific subscriber groups for marketing campaigns.
Instructions
List saved segments for an audience.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| list_id | Yes | ||
| count | No | ||
| offset | No |
Implementation Reference
- mcp_mailchimp/server.py:659-677 (handler)The list_segments tool handler, which fetches segments for a given Mailchimp audience list ID.
@mcp.tool() async def list_segments(list_id: str, count: int = 20, offset: int = 0) -> str: """List saved segments for an audience.""" mc = get_client() data = await mc.get( f"/lists/{list_id}/segments", params={"count": min(count, 100), "offset": offset}, ) segments = [] for s in data.get("segments", []): segments.append({ "id": s.get("id", ""), "name": s.get("name", ""), "member_count": s.get("member_count", 0), "type": s.get("type", ""), "created_at": s.get("created_at", ""), "updated_at": s.get("updated_at", ""), }) return _fmt({"total_items": data.get("total_items", 0), "segments": segments})