Skip to main content
Glama

update_customer

Update an existing customer's profile information including email, name, phone, tags, and note. Partial updates allowed—only changed fields are submitted. Tags fully replace existing set; use dedicated mutations for additive tag changes.

Instructions

Update an existing customer's profile fields — email, name, phone, tags, internal note. Only provide fields you want changed; omitted fields stay as-is. Tags is a full replacement (use add_tags / remove_tags for additive/subtractive changes). Email and phone changes still need to satisfy the per-store uniqueness constraint. To change addresses, use Shopify's address-specific mutations (not yet exposed by this server). To change marketing consent, the dedicated customerEmailMarketingConsentUpdate mutation is preferred.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesCustomer GID or numeric ID. Get one from list_customers.
emailNoNew email. Must remain unique.
firstNameNo
lastNameNo
phoneNoNew phone in E.164 format.
tagsNoNew tag set. REPLACES all existing tags. Use add_tags / remove_tags for additive/subtractive changes that preserve other tags.
noteNoNew internal staff note. Replaces prior note.

Implementation Reference

  • The actual handler function for the 'update_customer' tool. It builds the input from args, calls the Shopify GraphQL mutation CUSTOMER_UPDATE_MUTATION, handles user errors, and returns the updated customer info.
      async (args) => {
        const input: Record<string, unknown> = { id: toGid(args.id, "Customer") };
        if (args.email !== undefined) input.email = args.email;
        if (args.firstName !== undefined) input.firstName = args.firstName;
        if (args.lastName !== undefined) input.lastName = args.lastName;
        if (args.phone !== undefined) input.phone = args.phone;
        if (args.tags !== undefined) input.tags = args.tags;
        if (args.note !== undefined) input.note = args.note;
    
        const data = await client.graphql<{
          customerUpdate: {
            customer: Customer | null;
            userErrors: ShopifyUserError[];
          };
        }>(CUSTOMER_UPDATE_MUTATION, { input });
        throwIfUserErrors(data.customerUpdate.userErrors, "customerUpdate");
        const c = data.customerUpdate.customer;
        if (!c) {
          return {
            content: [
              { type: "text" as const, text: "customerUpdate returned no customer." },
            ],
          };
        }
        return {
          content: [
            {
              type: "text" as const,
              text: `Updated customer ${c.displayName ?? "(no name)"} <${c.email ?? "(no email)"}> — ${c.id}`,
            },
          ],
        };
      },
    );
  • Zod schema for update_customer input validation. Defines fields: id (required), email, firstName, lastName, phone, tags, note (all optional).
    const updateCustomerSchema = {
      id: z
        .string()
        .describe("Customer GID or numeric ID. Get one from list_customers."),
      email: z.string().email().optional().describe("New email. Must remain unique."),
      firstName: z.string().optional(),
      lastName: z.string().optional(),
      phone: z.string().optional().describe("New phone in E.164 format."),
      tags: z
        .array(z.string())
        .optional()
        .describe(
          "New tag set. REPLACES all existing tags. Use add_tags / remove_tags for additive/subtractive changes that preserve other tags.",
        ),
      note: z.string().optional().describe("New internal staff note. Replaces prior note."),
    };
  • Registration of the 'update_customer' tool via server.tool(), with its description, schema, and handler function.
    server.tool(
      "update_customer",
      "Update an existing customer's profile fields — email, name, phone, tags, internal note. Only provide fields you want changed; omitted fields stay as-is. Tags is a full replacement (use add_tags / remove_tags for additive/subtractive changes). Email and phone changes still need to satisfy the per-store uniqueness constraint. To change addresses, use Shopify's address-specific mutations (not yet exposed by this server). To change marketing consent, the dedicated customerEmailMarketingConsentUpdate mutation is preferred.",
      updateCustomerSchema,
      async (args) => {
        const input: Record<string, unknown> = { id: toGid(args.id, "Customer") };
        if (args.email !== undefined) input.email = args.email;
        if (args.firstName !== undefined) input.firstName = args.firstName;
        if (args.lastName !== undefined) input.lastName = args.lastName;
        if (args.phone !== undefined) input.phone = args.phone;
        if (args.tags !== undefined) input.tags = args.tags;
        if (args.note !== undefined) input.note = args.note;
    
        const data = await client.graphql<{
          customerUpdate: {
            customer: Customer | null;
            userErrors: ShopifyUserError[];
          };
        }>(CUSTOMER_UPDATE_MUTATION, { input });
        throwIfUserErrors(data.customerUpdate.userErrors, "customerUpdate");
        const c = data.customerUpdate.customer;
        if (!c) {
          return {
            content: [
              { type: "text" as const, text: "customerUpdate returned no customer." },
            ],
          };
        }
        return {
          content: [
            {
              type: "text" as const,
              text: `Updated customer ${c.displayName ?? "(no name)"} <${c.email ?? "(no email)"}> — ${c.id}`,
            },
          ],
        };
      },
    );
  • The GraphQL mutation used by the update_customer handler to call Shopify's customerUpdate.
    const CUSTOMER_UPDATE_MUTATION = /* GraphQL */ `
      mutation CustomerUpdate($input: CustomerInput!) {
        customerUpdate(input: $input) {
          customer {
            id
            displayName
            email
            firstName
            lastName
          }
          userErrors { field message }
        }
      }
    `;
  • The toGid helper function used by the handler to convert a numeric or partial ID to a full Shopify GID (e.g., 'gid://shopify/Customer/123').
    export function toGid(id: string, type: string): string {
      if (id.startsWith("gid://")) return id;
      return `gid://shopify/${type}/${id}`;
    }
Behavior4/5

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

With no annotations, the description fully discloses that tags are replaced, note is replaced, and email/phone must be unique. It does not mention authorization or existence checks, but covers key behavioral traits beyond what annotations would provide.

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

Conciseness4/5

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

Three sentences that front-load purpose and usage. Every sentence adds value, though the phrase 'not yet exposed by this server' could be slightly tighter. Still efficient and well-structured.

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

Completeness4/5

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

Covers all parameters, partial update behavior, and alternatives. No output schema, but description doesn't need to explain return values. Missing error handling details, but given complexity, it's fairly complete.

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 description coverage is 71%; the description adds meaning for tags (full replacement), note (replaces prior), and uniqueness constraints. It also explains how to get an id. For firstName and lastName, it groups them under 'name' but could be clearer. Overall compensates well for schema gaps.

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?

The description clearly states 'Update an existing customer's profile fields' and lists specific fields (email, name, phone, tags, internal note). It distinguishes from sibling tools like add_tags, remove_tags, and mentions alternative mutations for addresses and marketing consent.

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

Usage Guidelines5/5

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

Explicit guidance on partial updates: 'Only provide fields you want changed; omitted fields stay as-is.' Warns that tags is a full replacement and suggests using add_tags/remove_tags for additive changes. Also mentions uniqueness constraints for email/phone and points to other mutations for addresses and marketing consent.

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