Skip to main content
Glama

update_variants

Update one or more product variants in a single call: modify price, compareAtPrice, SKU, barcode, taxable status, inventory policy (DENY or CONTINUE), and option values without changing inventory quantities.

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 main handler function for the 'update_variants' MCP tool. Calls the Shopify GraphQL mutation productVariantsBulkUpdate with the provided productId and variants, throws on user errors, and returns a formatted result listing 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 update_variants input validation. Requires productId (string) and variants (array of variantUpdateSchema, 1-100 items).
    const updateVariantsSchema = {
      productId: z.string().describe("Product GID."),
      variants: z.array(variantUpdateSchema).min(1).max(100),
    };
  • The per-variant update schema (variantUpdateSchema). Defines editable fields: id (required), price, compareAtPrice (nullable), sku, barcode, taxable, inventoryPolicy, optionValues.
    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(),
    });
  • src/server.ts:20-64 (registration)
    Import and registration of registerVariantTools in the main server setup, which registers update_variants (along with other variant tools) on the McpServer.
    import { registerVariantTools } from "./tools/variants.js";
    import { registerFulfillmentTools } from "./tools/fulfillment.js";
    import { registerWebhookTools } from "./tools/webhooks.js";
    import { registerMetaobjectTools } from "./tools/metaobjects.js";
    import { registerAnalyticsTools } from "./tools/analytics.js";
    import { registerBridgeTools } from "./tools/bridge.js";
    
    export interface ServerConfig {
      host: string;
      port: number;
      shopifyStore: string;
      shopifyAccessToken: string;
      shopifyApiVersion?: string;
      comfyUIUrl?: string;
      comfyUIPublicUrl?: string;
      comfyUIDefaultCkpt: string;
    }
    
    interface Session {
      server: McpServer;
      transport: StreamableHTTPServerTransport;
    }
    
    function buildContext(config: ServerConfig) {
      const shopify = new ShopifyClient({
        store: config.shopifyStore,
        accessToken: config.shopifyAccessToken,
        apiVersion: config.shopifyApiVersion,
      });
      const comfyui = config.comfyUIUrl
        ? new ComfyUIClient({
            baseUrl: config.comfyUIUrl,
            publicUrl: config.comfyUIPublicUrl ?? config.comfyUIUrl,
          })
        : null;
      const buildServer = () => {
        const s = new McpServer({ name: "shopify-mcp", version: "0.1.0" });
        registerProductTools(s, shopify);
        registerOrderTools(s, shopify);
        registerInventoryTools(s, shopify);
        registerCustomerTools(s, shopify);
        registerMetafieldTools(s, shopify);
        registerDraftOrderTools(s, shopify);
        registerCollectionTools(s, shopify);
        registerVariantTools(s, shopify);
  • The GraphQL mutation string (VARIANTS_BULK_UPDATE_MUTATION) used by the update_variants handler to call productVariantsBulkUpdate.
    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 }
        }
      }
    `;
Behavior5/5

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

Despite no annotations, the description fully discloses behavior: it updates only provided fields, explains field-specific semantics (e.g., compareAtPrice clearing, inventoryPolicy options), and clarifies the audit trail separation.

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?

Two sentences efficiently convey purpose, editable fields, and alternative tool. Information is front-loaded and every sentence is purposeful.

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?

Fully explains what the tool does, its parameters, and when to use alternatives. No output schema, but the description is sufficient for correct invocation.

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?

Adds value beyond the 50% schema coverage by explaining inventoryPolicy values, compareAtPrice null handling, and optionValues usage. The schema has basic descriptions, but the description enhances clarity.

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 existing variants in a single call. It lists editable fields and distinguishes from sibling tools by referencing 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 directs users to use set_inventory_quantity for inventory changes, explaining this tool deliberately avoids quantities. It also notes that only provided fields are written, guiding proper usage.

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