Skip to main content
Glama

reorder_variants

Reorder variants on a Shopify product by assigning unique 1-indexed positions. Only specify variants with changed positions; others remain unchanged. Controls display order on product page and admin.

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

  • Zod schema for reorder_variants: accepts productId (string) and positions (array of {id: string, position: int >=1})
    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),
    };
  • Handler for reorder_variants: calls productVariantsBulkReorder mutation with productId and positions, throws on user errors, returns success message
    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).`,
            },
          ],
        };
      },
    );
  • GraphQL mutation VARIANTS_BULK_REORDER_MUTATION used by the reorder_variants tool
    const VARIANTS_BULK_REORDER_MUTATION = /* GraphQL */ `
      mutation VariantsBulkReorder(
        $productId: ID!
        $positions: [ProductVariantPositionInput!]!
      ) {
        productVariantsBulkReorder(productId: $productId, positions: $positions) {
          userErrors { field message }
        }
      }
    `;
  • src/server.ts:64-64 (registration)
    Registration of variant tools (including reorder_variants) on the MCP server
    registerVariantTools(s, shopify);
Behavior4/5

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

No annotations provided, so description carries full burden. It discloses 1-indexed unique positions, effect on product page and admin, and partial update behavior. It does not discuss permissions or side effects, but the mutation is low-risk and well-described.

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?

Four sentences, all essential information, no redundancy. The main purpose is front-loaded, and each sentence adds value without being verbose.

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 no output schema and simple inputs, the description covers what the tool does, constraints, and partial update behavior. It is complete for an agent to use correctly without ambiguity.

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 schema constraints: positions must be unique across all variants and only changing ones need be provided. The schema only defines structure and minimum, so the description enriches parameter understanding.

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 the verb 'Set' and the resource 'display order of variants on a product', with clear specifics about indexing and uniqueness. It distinguishes itself from sibling tools like update_variants by focusing solely on order.

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 clear context: only provide variants whose positions are changing, others stay. It implies this is for reordering only, but does not explicitly mention alternatives or when-not-to-use, though the tool name and context suffice.

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