Skip to main content
Glama
AgentX-ai

Mailchimp MCP Server

by AgentX-ai

list_merge_fields

Retrieve all merge fields from a specific Mailchimp list to access custom subscriber data for email personalization and segmentation.

Instructions

List all merge fields in a specific list

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
list_idYesThe list ID

Implementation Reference

  • The core handler function implementing the logic to list merge fields for a given Mailchimp list ID by calling the Mailchimp API with pagination.
    async listMergeFields( listId: string ): Promise<{ merge_fields: MailchimpMergeField[] }> { return await this.makePaginatedRequest( `/lists/${listId}/merge-fields`, "display_order", "ASC" ); }
  • Registers the 'list_merge_fields' tool in the getToolDefinitions array, including its name, description, and input schema.
    { 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"], }, },
  • TypeScript interface defining the MailchimpMergeField structure for output data validation and typing.
    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; }>; }
  • The tool execution handler in handleToolCall that dispatches to the service and formats the merge fields response for the MCP protocol.
    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 ), }, ], };

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/AgentX-ai/mailchimp-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server