Skip to main content
Glama

list_customers

Retrieve a paginated list of customers from your Shopify store, sorted newest first. Filter by email, tags, order count, spend, marketing consent, or account state. Returns customer GIDs for use in draft orders or marketing segmentation.

Instructions

List customers in the store, newest first by creation date. Returns each customer's display name, email, lifetime order count, and total amount spent (in shop currency). Supports Shopify's customer query syntax for filtering by email, tag, order count, spend, marketing-consent, account state, and more. Cursor-paginated; pass after to advance pages. Use this to find customer GIDs before referencing them in draft orders or to segment for marketing.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
firstNoPage size (1-100).
queryNoShopify customer query syntax. Examples: 'email:*@gmail.com' (domain match), 'tag:vip' (tagged), 'orders_count:>=5' (repeat customer), 'amount_spent:>=500' (high value), 'state:enabled', 'accepts_marketing:true'. Combine with AND/OR.
afterNoCursor from the previous page's pageInfo for pagination. Omit on the first call.

Implementation Reference

  • Tool handler for 'list_customers' — executes Shopify GraphQL query, formats output with customer info (name, email, orders, amount spent), returns text content.
    server.tool(
      "list_customers",
      "List customers in the store, newest first by creation date. Returns each customer's display name, email, lifetime order count, and total amount spent (in shop currency). Supports Shopify's customer query syntax for filtering by email, tag, order count, spend, marketing-consent, account state, and more. Cursor-paginated; pass `after` to advance pages. Use this to find customer GIDs before referencing them in draft orders or to segment for marketing.",
      listCustomersSchema,
      async (args) => {
        const data = await client.graphql<{ customers: Connection<Customer> }>(
          LIST_CUSTOMERS_QUERY,
          { first: args.first, query: args.query, after: args.after },
        );
        const lines = [
          `Found ${data.customers.edges.length} customer(s):`,
          ...data.customers.edges.map(({ node }) => {
            const name = node.displayName ?? "(no name)";
            const email = node.email ?? "(no email)";
            const orders = node.numberOfOrders ?? "0";
            const spent = node.amountSpent
              ? `${node.amountSpent.amount} ${node.amountSpent.currencyCode}`
              : "0";
            return `  ${name} <${email}> — ${orders} orders, ${spent} — ${node.id}`;
          }),
        ];
        return { content: [{ type: "text" as const, text: lines.join("\n") }] };
      },
    );
  • Input schema for list_customers: accepts first (page size, default 20), query (optional filter string), after (optional pagination cursor).
    const listCustomersSchema = {
      first: z
        .number()
        .int()
        .min(1)
        .max(100)
        .default(20)
        .describe("Page size (1-100)."),
      query: z
        .string()
        .optional()
        .describe(
          "Shopify customer query syntax. Examples: 'email:*@gmail.com' (domain match), 'tag:vip' (tagged), 'orders_count:>=5' (repeat customer), 'amount_spent:>=500' (high value), 'state:enabled', 'accepts_marketing:true'. Combine with AND/OR.",
        ),
      after: z
        .string()
        .optional()
        .describe(
          "Cursor from the previous page's pageInfo for pagination. Omit on the first call.",
        ),
    };
  • Registration of 'list_customers' via server.tool() in registerCustomerTools function.
    server.tool(
      "list_customers",
      "List customers in the store, newest first by creation date. Returns each customer's display name, email, lifetime order count, and total amount spent (in shop currency). Supports Shopify's customer query syntax for filtering by email, tag, order count, spend, marketing-consent, account state, and more. Cursor-paginated; pass `after` to advance pages. Use this to find customer GIDs before referencing them in draft orders or to segment for marketing.",
      listCustomersSchema,
      async (args) => {
        const data = await client.graphql<{ customers: Connection<Customer> }>(
          LIST_CUSTOMERS_QUERY,
          { first: args.first, query: args.query, after: args.after },
        );
        const lines = [
          `Found ${data.customers.edges.length} customer(s):`,
          ...data.customers.edges.map(({ node }) => {
            const name = node.displayName ?? "(no name)";
            const email = node.email ?? "(no email)";
            const orders = node.numberOfOrders ?? "0";
            const spent = node.amountSpent
              ? `${node.amountSpent.amount} ${node.amountSpent.currencyCode}`
              : "0";
            return `  ${name} <${email}> — ${orders} orders, ${spent} — ${node.id}`;
          }),
        ];
        return { content: [{ type: "text" as const, text: lines.join("\n") }] };
      },
    );
  • GraphQL query used by list_customers to fetch customers from Shopify, sorted by creation date descending, with pagination support.
    const LIST_CUSTOMERS_QUERY = /* GraphQL */ `
      query ListCustomers($first: Int!, $after: String, $query: String) {
        customers(first: $first, after: $after, query: $query, sortKey: CREATED_AT, reverse: true) {
          edges {
            cursor
            node {
              id
              firstName
              lastName
              email
              displayName
              numberOfOrders
              amountSpent { amount currencyCode }
              createdAt
            }
          }
          pageInfo { hasNextPage hasPreviousPage startCursor endCursor }
        }
      }
    `;
Behavior5/5

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

No annotations provided, so description carries full burden. It details returns (display name, email, order count, total spent), pagination (cursor-based, pass 'after'), filter support (query syntax). This gives a complete behavioral picture without contradictions.

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?

Four sentences, front-loaded with core purpose, then output fields, then query and pagination details, ending with use cases. Every sentence is informative and necessary, no fluff.

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

Completeness5/5

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

Given no output schema and no annotations, description covers all necessary aspects: returned fields, ordering, filtering, pagination, and practical usage. Aids agent in correct invocation and interpretation.

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

Parameters4/5

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

Schema coverage is 100%, baseline 3. Description adds value by providing examples for the query parameter (e.g., 'email:*@gmail.com', 'tag:vip') and explains usage of 'after' for pagination flow, enhancing understanding beyond schema descriptions.

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

Purpose5/5

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

Description clearly states 'List customers in the store, newest first by creation date.' and specifies output fields. It includes use cases (finding GIDs for draft orders, marketing segmentation) that differentiate it from sibling tools like create_customer or list_products.

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

Usage Guidelines4/5

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

Explicitly says 'Use this to find customer GIDs before referencing them in draft orders or to segment for marketing.' This provides clear context. No explicit when-not-to-use or alternative tools mentioned, but the use cases imply when it's appropriate.

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

Install Server

Other Tools

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/miller-joe/shopify-mcp'

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