list_members
Retrieve audience members with optional status filters. Specify list ID and filter by subscribed, unsubscribed, cleaned, pending, or transactional status to get targeted member data.
Instructions
List members of an audience. Filter by status: subscribed, unsubscribed, cleaned, pending, transactional.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| list_id | Yes | ||
| status | No | ||
| count | No | ||
| offset | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- mcp_mailchimp/server.py:462-486 (handler)The 'list_members' tool function. It accepts list_id, status, count, and offset parameters, calls the Mailchimp API at /lists/{list_id}/members, and returns formatted member data including email, status, full_name, tags_count, rating, last_changed, and id.
@mcp.tool() async def list_members( list_id: str, status: str = "", count: int = 20, offset: int = 0, ) -> str: """List members of an audience. Filter by status: subscribed, unsubscribed, cleaned, pending, transactional.""" mc = get_client() params: dict[str, Any] = {"count": min(count, 100), "offset": offset} if status: params["status"] = status data = await mc.get(f"/lists/{list_id}/members", params=params) members = [] for m in data.get("members", []): members.append({ "email": m.get("email_address", ""), "status": m.get("status", ""), "full_name": m.get("full_name", ""), "tags_count": m.get("tags_count", 0), "rating": m.get("member_rating", 0), "last_changed": m.get("last_changed", ""), "id": m.get("id", ""), }) return _fmt({"total_items": data.get("total_items", 0), "members": members}) - mcp_mailchimp/server.py:462-463 (registration)The tool is registered with FastMCP via the @mcp.tool() decorator on line 462.
@mcp.tool() async def list_members( - mcp_mailchimp/server.py:27-38 (helper)The get_client() helper function used by list_members to obtain the MailchimpClient singleton.
def get_client() -> MailchimpClient: global _client if _client is None: api_key = os.environ.get("MAILCHIMP_API_KEY", "") if not api_key or "-" not in api_key: raise ValueError( "MAILCHIMP_API_KEY environment variable required. " "Format: xxxxxxxxxx-usXX " "(get yours at https://mailchimp.com/account/api)" ) _client = MailchimpClient(api_key) return _client - mcp_mailchimp/server.py:41-43 (helper)The _fmt() helper function used by list_members to format output as indented JSON.
def _fmt(data: Any) -> str: """Format response data as indented JSON string.""" return json.dumps(data, indent=2, default=str)