Skip to main content
Glama

delete_variants

Delete multiple variants from a Shopify product permanently. Keeps at least one variant per product; variants in completed orders remain visible. Irreversible action.

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

  • Input schema for delete_variants: requires productId and an array of 1-100 variantIds.
    const deleteVariantsSchema = {
      productId: z.string().describe("Product GID."),
      variantIds: z.array(z.string()).min(1).max(100),
    };
  • Handler for delete_variants tool. Calls the Shopify productVariantsBulkDelete mutation and reports the count of deleted variants.
    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's productVariantsBulkDelete.
    const VARIANTS_BULK_DELETE_MUTATION = /* GraphQL */ `
      mutation VariantsBulkDelete($productId: ID!, $variantsIds: [ID!]!) {
        productVariantsBulkDelete(productId: $productId, variantsIds: $variantsIds) {
          product { id }
          userErrors { field message }
        }
      }
    `;
  • src/server.ts:64-64 (registration)
    Registration call that wires up all variant tools (including delete_variants) onto the MCP server.
    registerVariantTools(s, shopify);
Behavior4/5

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

With no annotations, the description carries the full burden of behavioral disclosure. It states the operation is irreversible and describes key constraints (minimum one variant per product) and special behavior (variants in completed orders are kept-but-hidden). This adds valuable context beyond basic mutation. However, it doesn't mention response details, error handling, or synchronous vs. async execution.

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, each serving a distinct purpose: purpose, constraint, edge case. It is concise with no redundant information, and the structure is logical and easy to parse.

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

Completeness3/5

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

The description covers key behavioral aspects (irreversibility, constraints, historical preservation). However, without an output schema, it does not inform the agent about the expected return value or error responses. Also, it omits details on atomicity of partial deletions and potential timeouts. Overall, adequate but with minor gaps.

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?

Schema description coverage is 50%: productId has a description ('Product GID.'), but variantIds does not. The tool description does not elaborate on the format or semantics of variantIds, nor does it clarify that they are Shopify GIDs. Despite the 50% coverage, the description fails to compensate for the missing schema detail for variantIds.

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 explicitly states 'Permanently delete one or more variants from a product.' This clearly identifies the verb (delete), resource (variants), and scope (one or more from a product), distinguishing it from sibling tools like create_variants or update_variants.

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

Usage Guidelines4/5

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

The description provides guidance on when to use this tool vs. alternatives, such as using update_product with status:ARCHIVED for full product deletion. It also explains the constraint that each product must keep at least one variant and the behavior for completed orders. This is clear, though it could be more explicit about when not to use (e.g., for disabling variants).

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