Skip to main content
Glama
AgentX-ai

Mailchimp MCP Server

by AgentX-ai

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
NameRequiredDescriptionDefault
list_idYesThe list ID

Implementation Reference

  • 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 ), }, ], };
  • 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"], }, },
  • 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" ); }
  • 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), }; });

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