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
| Name | Required | Description | Default |
|---|---|---|---|
| list_id | Yes | The list ID |
Implementation Reference
- src/tools/index.ts:792-811 (handler)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 ), }, ], };
- src/tools/index.ts:231-244 (registration)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"], }, },
- src/tools/index.ts:234-243 (schema)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"], },
- src/services/mailchimp.ts:214-222 (helper)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" ); }