Skip to main content
Glama

reorder_variants

Reorder product variants by assigning unique 1-indexed positions. Only specify variants whose positions are changing; others remain unchanged.

Instructions

Set the display order of variants on a product. Positions are 1-indexed and must be unique across all variants in the product (you can't have two variants both at position 2). Affects the order variants appear on the product page and in Shopify admin. Only provide the variants whose positions are changing — others stay where they are.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
productIdYesProduct GID.
positionsYes

Implementation Reference

  • The handler function for the 'reorder_variants' tool. It calls the Shopify GraphQL mutation productVariantsBulkReorder with the product ID and the array of positions (variant ID + 1-indexed position), throws on user errors, and returns a summary string.
    server.tool(
      "reorder_variants",
      "Set the display order of variants on a product. Positions are 1-indexed and must be unique across all variants in the product (you can't have two variants both at position 2). Affects the order variants appear on the product page and in Shopify admin. Only provide the variants whose positions are changing — others stay where they are.",
      reorderVariantsSchema,
      async (args) => {
        const data = await client.graphql<{
          productVariantsBulkReorder: {
            userErrors: ShopifyUserError[];
          };
        }>(VARIANTS_BULK_REORDER_MUTATION, {
          productId: args.productId,
          positions: args.positions,
        });
        throwIfUserErrors(
          data.productVariantsBulkReorder.userErrors,
          "productVariantsBulkReorder",
        );
        return {
          content: [
            {
              type: "text" as const,
              text: `Reordered ${args.positions.length} variant(s).`,
            },
          ],
        };
      },
    );
  • Zod schema for the 'reorder_variants' tool. Accepts a productId (string GID) and an array of positions, each containing a variant id (string GID) and a 1-indexed integer position.
    const reorderVariantsSchema = {
      productId: z.string().describe("Product GID."),
      positions: z
        .array(
          z.object({
            id: z.string().describe("Variant GID."),
            position: z.number().int().min(1),
          }),
        )
        .min(1),
    };
  • src/server.ts:64-64 (registration)
    Registration call: registerVariantTools is invoked in the buildServer function, which wires the tool to the MCP server.
    registerVariantTools(s, shopify);
  • The GraphQL mutation string VARIANTS_BULK_REORDER_MUTATION used by the reorder_variants handler to call Shopify's productVariantsBulkReorder endpoint.
    const VARIANTS_BULK_REORDER_MUTATION = /* GraphQL */ `
      mutation VariantsBulkReorder(
        $productId: ID!
        $positions: [ProductVariantPositionInput!]!
      ) {
        productVariantsBulkReorder(productId: $productId, positions: $positions) {
          userErrors { field message }
        }
      }
    `;
Behavior4/5

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

With no annotations, the description carries full burden. It discloses that positions are 1-indexed and must be unique across variants, and that changes affect display order. It does not mention potential side effects like error handling or permissions, but for a mutation tool, it sufficiently explains the core behavior.

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, front-loaded with the purpose, and every sentence adds value. It is concise with no redundant information.

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?

Given the tool's simplicity (2 required params, no output schema), the description fully covers constraints and usage. It explains position indexing, uniqueness, and partial updates. The agent can confidently invoke this tool without missing context.

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

Parameters5/5

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

The input schema provides minimal descriptions for productId and positions, but the description adds significant meaning: positions are 1-indexed, must be unique, and only changing variants need to be provided. This compensates for schema brevity and gives the agent clear instructions on how to fill the fields.

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 verb 'Set' and resource 'display order of variants on a product', specifying that it affects order on product page and admin. This distinguishes it from sibling tools like 'update_variants' or 'create_variants' which handle different aspects of 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 a key guideline: 'Only provide the variants whose positions are changing — others stay where they are.' This tells the agent how to structure input. However, it does not explicitly state when to use this tool over alternatives, though no sibling tool exists for reordering, making the context clear enough.

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