Skip to main content
Glama

update_variants

Update existing product variants in bulk, modifying price, SKU, barcode, tax status, inventory policy, and option values. Inventory quantity changes require a separate tool.

Instructions

Update one or more existing variants in a single call. Editable fields: price, compareAtPrice (set to null to clear), SKU, barcode, taxable, inventoryPolicy (DENY blocks oversells, CONTINUE allows backorders), and optionValues (e.g. rename a size). Per-variant only; only the fields you provide are written. For inventory quantity changes use set_inventory_quantity — this tool deliberately doesn't accept quantities to keep that audit trail in one place.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
productIdYesProduct GID.
variantsYes

Implementation Reference

  • The handler function that executes the 'update_variants' tool logic. It calls the Shopify productVariantsBulkUpdate mutation with the provided productId and variants, throws if there are user errors, and returns a formatted response listing the updated variants.
    server.tool(
      "update_variants",
      "Update one or more existing variants in a single call. Editable fields: price, compareAtPrice (set to null to clear), SKU, barcode, taxable, inventoryPolicy (DENY blocks oversells, CONTINUE allows backorders), and optionValues (e.g. rename a size). Per-variant only; only the fields you provide are written. For inventory quantity changes use set_inventory_quantity — this tool deliberately doesn't accept quantities to keep that audit trail in one place.",
      updateVariantsSchema,
      async (args) => {
        const data = await client.graphql<{
          productVariantsBulkUpdate: {
            productVariants: VariantNode[];
            userErrors: ShopifyUserError[];
          };
        }>(VARIANTS_BULK_UPDATE_MUTATION, {
          productId: args.productId,
          variants: args.variants,
        });
        throwIfUserErrors(
          data.productVariantsBulkUpdate.userErrors,
          "productVariantsBulkUpdate",
        );
        const updated = data.productVariantsBulkUpdate.productVariants;
        return {
          content: [
            {
              type: "text" as const,
              text: [
                `Updated ${updated.length} variant(s):`,
                ...updated.map(
                  (v) =>
                    `  ${v.title} ${v.price}${v.compareAtPrice ? ` (cmp ${v.compareAtPrice})` : ""}${v.sku ? ` SKU:${v.sku}` : ""} — ${v.id}`,
                ),
              ].join("\n"),
            },
          ],
        };
      },
    );
  • The Zod schema for the 'update_variants' tool input. It requires a productId (GID string) and an array of 1-100 variant update objects (each containing an id and optional fields like price, compareAtPrice, sku, barcode, taxable, inventoryPolicy, optionValues).
    const updateVariantsSchema = {
      productId: z.string().describe("Product GID."),
      variants: z.array(variantUpdateSchema).min(1).max(100),
    };
  • The VARIANTS_BULK_UPDATE_MUTATION GraphQL mutation used by the 'update_variants' handler to perform the bulk update on Shopify.
    const VARIANTS_BULK_UPDATE_MUTATION = /* GraphQL */ `
      mutation VariantsBulkUpdate(
        $productId: ID!
        $variants: [ProductVariantsBulkInput!]!
      ) {
        productVariantsBulkUpdate(productId: $productId, variants: $variants) {
          productVariants {
            id
            title
            price
            compareAtPrice
            sku
            barcode
          }
          userErrors { field message }
        }
      }
    `;
  • The variantUpdateSchema Zod schema defining the shape of each variant object in the update array, used by updateVariantsSchema.
    const variantUpdateSchema = z.object({
      id: z.string().describe("Variant GID to update."),
      price: z.string().optional(),
      compareAtPrice: z.string().optional().nullable(),
      sku: z.string().optional(),
      barcode: z.string().optional(),
      taxable: z.boolean().optional(),
      inventoryPolicy: z.enum(["DENY", "CONTINUE"]).optional(),
      optionValues: z.array(optionValueInputSchema).optional(),
    });
Behavior4/5

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

Although no annotations exist, the description explains that updates are per-variant and only specified fields are written, and clarifies the meaning of inventoryPolicy values. It does not cover potential side effects or rate limits, but is still sufficiently transparent for a simple update tool.

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 three sentences: first states purpose, second details fields, third gives sibling guidance. It is front-loaded, efficient, and contains no extraneous information.

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?

The description covers editable fields, usage constraints, and points to the related tool. It lacks explicit mention of return value (though standard for updates) and does not mention any prerequisites, but overall provides sufficient context for an AI to use the tool correctly.

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?

The description adds meaning beyond the schema by listing editable fields (price, compareAtPrice, SKU, etc.), explaining special behavior (compareAtPrice set to null to clear), and providing examples (rename a size for optionValues). This compensates for the schema's 50% description coverage.

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 the tool updates one or more existing variants in a single call, lists editable fields, and distinguishes from the sibling tool set_inventory_quantity for inventory changes.

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?

Explicitly tells when NOT to use this tool (for inventory quantity changes) and directs to the alternative set_inventory_quantity, providing clear usage boundaries.

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