Skip to main content
Glama

get-customers

Retrieve customer data from Shopify stores using search queries and pagination controls to manage customer relationships and analyze store performance.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
searchQueryNo
limitNo

Implementation Reference

  • The execute function that implements the core logic for fetching customers from Shopify GraphQL API. It handles the query construction, executes the GraphQL request, parses the response, and formats the customer data with details like name, email, phone, addresses, amount spent, and order count.
    execute: async (input: GetCustomersInput) => {
      try {
        const { searchQuery, limit } = input;
    
        const query = gql`
          query GetCustomers($first: Int!, $query: String) {
            customers(first: $first, query: $query) {
              edges {
                node {
                  id
                  firstName
                  lastName
                  email
                  phone
                  createdAt
                  updatedAt
                  tags
                  defaultAddress {
                    address1
                    address2
                    city
                    provinceCode
                    zip
                    country
                    phone
                  }
                  addresses {
                    address1
                    address2
                    city
                    provinceCode
                    zip
                    country
                    phone
                  }
                  amountSpent {
                    amount
                    currencyCode
                  }
                  numberOfOrders
                }
              }
            }
          }
        `;
    
        const variables = {
          first: limit,
          query: searchQuery
        };
    
        const data = (await shopifyClient.request(query, variables)) as {
          customers: any;
        };
    
        // Extract and format customer data
        const customers = data.customers.edges.map((edge: any) => {
          const customer = edge.node;
    
          return {
            id: customer.id,
            firstName: customer.firstName,
            lastName: customer.lastName,
            email: customer.email,
            phone: customer.phone,
            createdAt: customer.createdAt,
            updatedAt: customer.updatedAt,
            tags: customer.tags,
            defaultAddress: customer.defaultAddress,
            addresses: customer.addresses,
            amountSpent: customer.amountSpent,
            numberOfOrders: customer.numberOfOrders
          };
        });
    
        return { customers };
      } catch (error) {
        console.error("Error fetching customers:", error);
        throw new Error(
          `Failed to fetch customers: ${
            error instanceof Error ? error.message : String(error)
          }`
        );
      }
  • Input schema definition using Zod that validates the tool's input parameters: searchQuery (optional string for filtering by name/email) and limit (number with default value of 10).
    const GetCustomersInputSchema = z.object({
      searchQuery: z.string().optional(),
      limit: z.number().default(10)
    });
  • Tool definition object containing the tool name ('get-customers'), description, schema reference, and initialize method that sets up the GraphQL client dependency.
    const getCustomers = {
      name: "get-customers",
      description: "Get customers or search by name/email",
      schema: GetCustomersInputSchema,
    
      // Add initialize method to set up the GraphQL client
      initialize(client: GraphQLClient) {
        shopifyClient = client;
      },
  • src/index.ts:109-121 (registration)
    Registration of the 'get-customers' tool with the MCP server using server.tool(), defining the input schema with searchQuery and limit parameters, and wiring up the execute handler to return JSON-formatted results.
    server.tool(
      "get-customers",
      {
        searchQuery: z.string().optional(),
        limit: z.number().default(10)
      },
      async (args) => {
        const result = await getCustomers.execute(args);
        return {
          content: [{ type: "text", text: JSON.stringify(result) }]
        };
      }
    );
  • src/index.ts:65-65 (registration)
    Initialization call that injects the configured Shopify GraphQL client into the getCustomers tool before registration.
    getCustomers.initialize(shopifyClient);
Behavior1/5

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

Tool has no description.

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

Conciseness1/5

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

Tool has no description.

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

Completeness1/5

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

Tool has no description.

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

Parameters1/5

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

Tool has no description.

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

Purpose1/5

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

Tool has no description.

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

Usage Guidelines1/5

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

Tool has no description.

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/anass319/shopify-MCP'

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