Skip to main content
Glama
clavia-labs

Shopify Update MCP Server

by clavia-labs

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>;

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It mentions 'pagination support' which hints at behavior for large result sets, but fails to disclose critical details: whether this is a read-only operation, what permissions are required, rate limits, error conditions, or the format of returned data. For a tool with no annotations, this leaves significant behavioral gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero waste. It's front-loaded with the core purpose and includes a key behavioral hint (pagination). Every word earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations and no output schema, the description is incomplete for a data retrieval tool. It doesn't explain what data is returned (e.g., customer fields), how pagination works in practice, or error handling. For a tool with 2 parameters and complex behavior implied by pagination, more context is needed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents both parameters ('limit' and 'next'). The description adds no additional meaning about parameters beyond implying pagination through 'next', which is already clear from the schema. Baseline 3 is appropriate when schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Get') and resource ('shopify customers'), making the purpose understandable. It distinguishes from siblings like 'tag-customer' or 'get-order' by specifying customers as the target. However, it doesn't explicitly differentiate from other customer-related tools (none listed), so it's not a perfect 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description mentions 'pagination support' which implies usage for large datasets, but provides no explicit guidance on when to use this tool versus alternatives like 'get-order' or 'get-products'. No prerequisites, exclusions, or comparisons to sibling tools are stated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.