list_merge_fields
Retrieve all merge fields for a Mailchimp audience, including standard fields like FNAME and LNAME and any custom fields you have created.
Instructions
List merge fields (custom fields) for an audience — FNAME, LNAME, plus any custom ones.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| list_id | Yes | ||
| count | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- mcp_mailchimp/server.py:971-991 (handler)The handler function that executes the 'list_merge_fields' tool logic. It calls the Mailchimp API's /lists/{list_id}/merge-fields endpoint and returns formatted merge field data.
@mcp.tool() async def list_merge_fields(list_id: str, count: int = 50) -> str: """List merge fields (custom fields) for an audience — FNAME, LNAME, plus any custom ones.""" mc = get_client() data = await mc.get( f"/lists/{list_id}/merge-fields", params={"count": min(count, 100)}, ) fields = [] for f in data.get("merge_fields", []): fields.append({ "merge_id": f.get("merge_id", ""), "tag": f.get("tag", ""), "name": f.get("name", ""), "type": f.get("type", ""), "required": f.get("required", False), "default_value": f.get("default_value", ""), "public": f.get("public", False), }) return _fmt({"total_items": data.get("total_items", 0), "merge_fields": fields}) - mcp_mailchimp/server.py:971-971 (registration)The '@mcp.tool()' decorator registers 'list_merge_fields' as an MCP tool.
@mcp.tool() - mcp_mailchimp/server.py:972-973 (schema)The function signature defines the input schema: list_id (required string), count (optional int, default 50).
async def list_merge_fields(list_id: str, count: int = 50) -> str: """List merge fields (custom fields) for an audience — FNAME, LNAME, plus any custom ones.""" - mcp_mailchimp/server.py:41-43 (helper)The _fmt helper function formats response data as indented JSON, used by list_merge_fields for output formatting.
def _fmt(data: Any) -> str: """Format response data as indented JSON string.""" return json.dumps(data, indent=2, default=str)