Skip to main content
Glama
AgentX-ai

Mailchimp MCP Server

by AgentX-ai

list_templates

Retrieve all email templates from your Mailchimp account to review, select, or manage your email marketing designs.

Instructions

List all templates in your Mailchimp account

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main tool handler in handleToolCall that processes the list_templates tool call, invokes the service method, maps and formats the templates for response.
    case "list_templates": const templates = await service.listTemplates(); return { content: [ { type: "text", text: JSON.stringify( templates.templates.map((t) => ({ id: t.id, name: t.name, type: t.type, drag_and_drop: t.drag_and_drop, responsive: t.responsive, active: t.active, date_created: t.date_created, })), null, 2 ), }, ], };
  • Tool registration in getToolDefinitions array, including name, description, and empty input schema.
    name: "list_templates", description: "List all templates in your Mailchimp account", inputSchema: { type: "object", properties: {}, required: [], }, },
  • The service method listTemplates that implements the core logic by calling Mailchimp API endpoint /templates with pagination.
    async listTemplates(): Promise<{ templates: MailchimpTemplate[] }> { return await this.makePaginatedRequest( "/templates", "date_created", "DESC" ); }
  • Helper method makePaginatedRequest used by listTemplates to fetch paginated data from Mailchimp API with sorting.
    private async makePaginatedRequest<T = any>( endpoint: string, sortField: string = "create_time", sortDirection: "ASC" | "DESC" = "DESC" ): Promise<T> { // Mailchimp API allows up to 1000 items per page const params = new URLSearchParams({ count: "1000", sort_field: sortField, sort_dir: sortDirection, }); const url = `${this.baseUrl}${endpoint}?${params.toString()}`; const auth = Buffer.from(`anystring:${this.apiKey}`).toString("base64"); const response = await fetch(url, { headers: { Authorization: `Basic ${auth}`, "Content-Type": "application/json", }, }); if (!response.ok) { const errorText = await response.text(); throw new Error( `Mailchimp API Error: ${response.status} ${response.statusText} - ${errorText}` ); } return response.json() as Promise<T>; }

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