Skip to main content
Glama

delete_variants

Permanently delete one or more variants from a given product. Ensure at least one variant remains; Shopify automatically preserves variants in completed orders.

Instructions

Permanently delete one or more variants from a product. Irreversible. Each product must keep at least one variant — Shopify rejects requests that would empty the product (delete the whole product via update_product status:ARCHIVED, or use the admin UI for full deletion). Variants in completed orders are kept-but-hidden by Shopify automatically; the historical record on the order is preserved.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
productIdYesProduct GID.
variantIdsYes

Implementation Reference

  • Schema definition for delete_variants tool input: productId (string) and variantIds (array of strings, 1-100 items).
    const deleteVariantsSchema = {
      productId: z.string().describe("Product GID."),
      variantIds: z.array(z.string()).min(1).max(100),
    };
  • Handler for the delete_variants tool. Calls the Shopify GraphQL mutation productVariantsBulkDelete with productId and variantIds, throws on user errors, and returns a confirmation message.
    server.tool(
      "delete_variants",
      "Permanently delete one or more variants from a product. Irreversible. Each product must keep at least one variant — Shopify rejects requests that would empty the product (delete the whole product via update_product status:ARCHIVED, or use the admin UI for full deletion). Variants in completed orders are kept-but-hidden by Shopify automatically; the historical record on the order is preserved.",
      deleteVariantsSchema,
      async (args) => {
        const data = await client.graphql<{
          productVariantsBulkDelete: {
            product: { id: string } | null;
            userErrors: ShopifyUserError[];
          };
        }>(VARIANTS_BULK_DELETE_MUTATION, {
          productId: args.productId,
          variantsIds: args.variantIds,
        });
        throwIfUserErrors(
          data.productVariantsBulkDelete.userErrors,
          "productVariantsBulkDelete",
        );
        return {
          content: [
            {
              type: "text" as const,
              text: `Deleted ${args.variantIds.length} variant(s) from ${args.productId}.`,
            },
          ],
        };
      },
    );
  • Registration of the delete_variants tool via server.tool() inside registerVariantTools().
    server.tool(
      "delete_variants",
      "Permanently delete one or more variants from a product. Irreversible. Each product must keep at least one variant — Shopify rejects requests that would empty the product (delete the whole product via update_product status:ARCHIVED, or use the admin UI for full deletion). Variants in completed orders are kept-but-hidden by Shopify automatically; the historical record on the order is preserved.",
      deleteVariantsSchema,
      async (args) => {
        const data = await client.graphql<{
          productVariantsBulkDelete: {
            product: { id: string } | null;
            userErrors: ShopifyUserError[];
          };
        }>(VARIANTS_BULK_DELETE_MUTATION, {
          productId: args.productId,
          variantsIds: args.variantIds,
        });
        throwIfUserErrors(
          data.productVariantsBulkDelete.userErrors,
          "productVariantsBulkDelete",
        );
        return {
          content: [
            {
              type: "text" as const,
              text: `Deleted ${args.variantIds.length} variant(s) from ${args.productId}.`,
            },
          ],
        };
      },
    );
  • GraphQL mutation string used by the delete_variants handler to delete variants via Shopify API.
    const VARIANTS_BULK_DELETE_MUTATION = /* GraphQL */ `
      mutation VariantsBulkDelete($productId: ID!, $variantsIds: [ID!]!) {
        productVariantsBulkDelete(productId: $productId, variantsIds: $variantsIds) {
          product { id }
          userErrors { field message }
        }
      }
    `;
Behavior4/5

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

With no annotations provided, the description carries full burden. It discloses irreversibility, the constraint on minimum variants, and how completed order variants are handled (kept-but-hidden). Lacks info on authorization or rate limits, but is otherwise transparent.

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?

Three sentences, each adding critical information: action, irreversibility constraint, and nuance about order preservation. No wasted words; front-loaded with the primary purpose.

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?

Given no output schema and no annotations, the description covers the main behavioral aspects of the tool: irreversibility, the constraint on emptying a product, and order preservation. Missing details on error handling or return values, but sufficient for a deletion tool.

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

Parameters2/5

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

Input schema has 50% coverage: productId has a basic description ('Product GID.'), variantIds has none. The description implies variantIds by saying 'one or more variants' but adds no detail about format or constraints beyond schema. Does not clarify that productId is a GID or how to obtain it.

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 it 'permanently delete[s] one or more variants from a product', specifying the action, resource, and scope. It distinguishes from siblings like delete_product by mentioning the alternative for whole product deletion.

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 says 'permanently delete' indicates finality. Provides when-to-use guidance by noting that 'Each product must keep at least one variant' and that 'Shopify rejects requests that would empty the product', advising against deleting the last variant. Also clarifies behavior for completed orders.

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