list_products
Retrieve all products from a Mailchimp-connected store to manage inventory and marketing campaigns.
Instructions
List all products in a store
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| store_id | Yes | The store ID |
Implementation Reference
- src/services/mailchimp.ts:309-317 (handler)Core handler function in MailchimpService that fetches the list of products for a given store ID using a paginated API request to Mailchimp's e-commerce endpoint.async listProducts( storeId: string ): Promise<{ products: MailchimpProduct[] }> { return await this.makePaginatedRequest( `/ecommerce/stores/${storeId}/products`, "created_at", "DESC" ); }
- src/tools/index.ts:1071-1089 (handler)Tool dispatch handler in handleToolCall that invokes the service.listProducts method with the provided store_id argument and formats the products list into a JSON text response for MCP.case "list_products": const products = await service.listProducts(args.store_id); return { content: [ { type: "text", text: JSON.stringify( products.products.map((p) => ({ id: p.id, title: p.title, type: p.type, vendor: p.vendor, })), null, 2 ), }, ], };
- src/tools/index.ts:451-464 (registration)Tool registration entry in getToolDefinitions array, including the tool name, description, and input schema.{ name: "list_products", description: "List all products in a store", inputSchema: { type: "object", properties: { store_id: { type: "string", description: "The store ID", }, }, required: ["store_id"], }, },
- src/types/index.ts:802-830 (schema)TypeScript interface defining the structure of a MailchimpProduct, used for typing the output of the listProducts method.export interface MailchimpProduct { id: string; title: string; handle: string; url: string; description: string; type: string; vendor: string; image_url?: string; variants: Array<{ id: string; title: string; url: string; sku: string; price: number; inventory_quantity: number; image_url?: string; backorders: string; visibility: string; }>; published_at_foreign?: string; _links?: Array<{ rel: string; href: string; method: string; targetSchema?: string; schema?: string; }>; }
- src/services/mailchimp.ts:65-95 (helper)Helper method used by listProducts to make paginated requests to the 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>; }