Skip to main content
Glama
AgentX-ai

Mailchimp MCP Server

by AgentX-ai

list_members

Retrieve all subscribers from a specific Mailchimp email list using the list ID to manage audience data.

Instructions

List all members in a specific list

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
list_idYesThe list ID

Implementation Reference

  • The handler for the 'list_members' tool call. It invokes MailchimpService.listMembers with the provided list_id, maps the members data, and returns formatted text content for the MCP response.
    case "list_members":
      const members = await service.listMembers(args.list_id);
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(
              members.members.map((m) => ({
                id: m.id,
                email_address: m.email_address,
                status: m.status,
                member_rating: m.member_rating,
                last_changed: m.last_changed,
              })),
              null,
              2
            ),
          },
        ],
      };
  • Input schema definition for the 'list_members' tool, specifying the required 'list_id' parameter.
    {
      name: "list_members",
      description: "List all members in a specific list",
      inputSchema: {
        type: "object",
        properties: {
          list_id: {
            type: "string",
            description: "The list ID",
          },
        },
        required: ["list_id"],
      },
  • src/index.ts:42-46 (registration)
    Registers all tools, including 'list_members', by providing the tool definitions from getToolDefinitions in response to ListToolsRequest.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: getToolDefinitions(mailchimpService),
      };
    });
  • Helper method in MailchimpService that makes a paginated API request to retrieve members from a specified Mailchimp list.
    async listMembers(listId: string): Promise<{ members: MailchimpMember[] }> {
      return await this.makePaginatedRequest(
        `/lists/${listId}/members`,
        "timestamp_signup",
        "DESC"
      );
    }
  • TypeScript interface defining the structure of a MailchimpMember, used for typing the output of listMembers.
    export interface MailchimpMember {
      id: string;
      email_address: string;
      unique_email_id: string;
      email_type: string;
      status:
        | "subscribed"
        | "unsubscribed"
        | "cleaned"
        | "pending"
        | "transactional";
      merge_fields: Record<string, any>;
      interests: Record<string, boolean>;
      stats: {
        avg_open_rate: number;
        avg_click_rate: number;
        ecommerce_data?: {
          total_revenue: number;
          number_of_orders: number;
          currency_code: string;
        };
      };
      ip_signup?: string;
      timestamp_signup?: string;
      ip_opt?: string;
      timestamp_opt?: string;
      member_rating: number;
      last_changed: string;
      language?: string;
      vip: boolean;
      email_client?: string;
      location?: {
        latitude: number;
        longitude: number;
        gmtoff: number;
        dstoff: number;
        country_code: string;
        timezone: string;
        region: string;
      };
      source?: string;
      tags_count: number;
      tags: Array<{
        id: number;
        name: string;
      }>;
      list_id: string;
      _links?: Array<{
        rel: string;
        href: string;
        method: string;
        targetSchema?: string;
        schema?: string;
      }>;
    }

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