Skip to main content
Glama
AgentX-ai

Mailchimp MCP Server

by AgentX-ai

list_segments

Retrieve all audience segments from a Mailchimp email list to analyze subscriber groups and target specific audiences for email campaigns.

Instructions

List all segments in a specific list

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
list_idYesThe list ID

Implementation Reference

  • The core handler function that executes the logic to list segments for a given Mailchimp list ID by making a paginated API request.
    async listSegments(
      listId: string
    ): Promise<{ segments: MailchimpSegment[] }> {
      return await this.makePaginatedRequest(
        `/lists/${listId}/segments`,
        "created_at",
        "DESC"
      );
    }
  • Input schema definition for the list_segments tool, requiring a list_id parameter.
    {
      name: "list_segments",
      description: "List all segments in a specific list",
      inputSchema: {
        type: "object",
        properties: {
          list_id: {
            type: "string",
            description: "The list ID",
          },
        },
        required: ["list_id"],
      },
    },
  • Registration of the list_segments tool in the getToolDefinitions array.
    {
      name: "list_segments",
      description: "List all segments in a specific list",
      inputSchema: {
        type: "object",
        properties: {
          list_id: {
            type: "string",
            description: "The list ID",
          },
        },
        required: ["list_id"],
      },
    },
  • Tool dispatch handler in handleToolCall that invokes the service method and formats the response as JSON text.
    case "list_segments":
      const segments = await service.listSegments(args.list_id);
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(
              segments.segments.map((s) => ({
                id: s.id,
                name: s.name,
                member_count: s.member_count,
                type: s.type,
                created_at: s.created_at,
              })),
              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