Skip to main content
Glama

get-customers

Retrieve Shopify customer data with pagination support to manage and access customer lists efficiently.

Instructions

Get shopify customers with pagination support

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoLimit of customers to return
nextNoNext page cursor

Implementation Reference

  • src/index.ts:246-269 (registration)
    Registration of the 'get-customers' MCP tool, including input schema (limit, next) and inline handler that delegates to ShopifyClient.loadCustomers and formats response as JSON.
    server.tool( "get-customers", "Get shopify customers with pagination support", { limit: z.number().optional().describe("Limit of customers to return"), next: z.string().optional().describe("Next page cursor"), }, async ({ limit, next }) => { const client = new ShopifyClient(); try { const response = await client.loadCustomers( SHOPIFY_ACCESS_TOKEN, MYSHOPIFY_DOMAIN, limit, next ); return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }], }; } catch (error) { return handleError("Failed to retrieve customers data", error); } } );
  • The MCP tool handler function for 'get-customers', which instantiates ShopifyClient and calls loadCustomers.
    async ({ limit, next }) => { const client = new ShopifyClient(); try { const response = await client.loadCustomers( SHOPIFY_ACCESS_TOKEN, MYSHOPIFY_DOMAIN, limit, next ); return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }], }; } catch (error) { return handleError("Failed to retrieve customers data", error); } }
  • Core implementation of customer loading via Shopify REST API GET /customers.json with pagination (limit, page_info), extracts next page from Link header.
    async loadCustomers( accessToken: string, shop: string, limit?: number, next?: string ): Promise<LoadCustomersResponse> { const res = await this.shopifyHTTPRequest<{ customers: any[] }>({ method: "GET", url: `https://${shop}/admin/api/${this.SHOPIFY_API_VERSION}/customers.json`, accessToken, params: { limit: limit ?? 250, page_info: next, fields: ["id", "email", "tags"].join(","), }, }); const customers = res.data.customers; const nextPageInfo = ShopifyClient.getShopifyOrdersNextPage( res.headers.get("link") ); return { customers, next: nextPageInfo }; }
  • Type definition for the response of loadCustomers: array of ShopifyCustomer and optional next page cursor.
    export type LoadCustomersResponse = { customers: Array<ShopifyCustomer>; next?: string | undefined; };
  • Interface definition for ShopifyClientPort.loadCustomers method signature.
    loadCustomers( accessToken: string, myshopifyDomain: string, limit?: number, next?: string ): Promise<LoadCustomersResponse>;

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/smithery-ai/shopify-mcp-server-main-1'

If you have feedback or need assistance with the MCP directory API, please join our Discord server