list_merge_fields
Retrieve all merge fields for a specific Mailchimp list to access custom contact data and personalize email campaigns.
Instructions
List all merge fields in a specific list
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| list_id | Yes | The list ID |
Implementation Reference
- src/tools/index.ts:938-958 (handler)MCP tool handler that executes list_merge_fields by calling the Mailchimp service's listMergeFields method and formatting the merge fields as a JSON text response.case "list_merge_fields": const mergeFields = await service.listMergeFields(args.list_id); return { content: [ { type: "text", text: JSON.stringify( mergeFields.merge_fields.map((mf) => ({ id: mf.id, name: mf.name, type: mf.type, required: mf.required, public: mf.public, display_order: mf.display_order, })), null, 2 ), }, ], };
- src/tools/index.ts:346-359 (schema)Tool definition including name, description, and input schema requiring 'list_id' parameter.{ name: "list_merge_fields", description: "List all merge fields in a specific list", inputSchema: { type: "object", properties: { list_id: { type: "string", description: "The list ID", }, }, required: ["list_id"], }, },
- src/services/mailchimp.ts:361-369 (helper)MailchimpService helper method that performs a paginated API request to retrieve merge fields for the specified list.async listMergeFields( listId: string ): Promise<{ merge_fields: MailchimpMergeField[] }> { return await this.makePaginatedRequest( `/lists/${listId}/merge-fields`, "display_order", "ASC" ); }
- src/types/index.ts:931-966 (schema)TypeScript interface defining the structure of a Mailchimp merge field, used for type safety in the tool's output.export interface MailchimpMergeField { id: number; name: string; type: | "text" | "number" | "address" | "phone" | "date" | "url" | "imageurl" | "radio" | "dropdown" | "birthday" | "zip"; required: boolean; default_value?: string; public: boolean; display_order: number; options?: { default_country?: number; phone_format?: string; date_format?: string; choices?: string[]; size?: number; }; help_text?: string; list_id: string; _links?: Array<{ rel: string; href: string; method: string; targetSchema?: string; schema?: string; }>; }
- src/index.ts:42-46 (registration)MCP server registration of the listTools request handler, which provides the tool definitions including list_merge_fields via getToolDefinitions.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: getToolDefinitions(mailchimpService), }; });