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 marketing campaigns.

Instructions

List all segments in a specific list

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
list_idYesThe list ID

Implementation Reference

  • Handler for the 'list_segments' tool call. It invokes service.listSegments with the provided list_id argument, maps the segments to a simplified structure, stringifies as JSON, and returns as MCP-formatted text content.
    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 ), }, ], };
  • Tool registration/definition in getToolDefinitions array, including name, description, and input schema requiring 'list_id'.
    { 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"], }, },
  • Input schema for the 'list_segments' tool, defining the required 'list_id' parameter.
    inputSchema: { type: "object", properties: { list_id: { type: "string", description: "The list ID", }, }, required: ["list_id"], },
  • Core helper method in MailchimpService that performs a paginated API request to retrieve segments for the given list ID from Mailchimp's /lists/{list_id}/segments endpoint.
    async listSegments( listId: string ): Promise<{ segments: MailchimpSegment[] }> { return await this.makePaginatedRequest( `/lists/${listId}/segments`, "created_at", "DESC" ); }

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