Skip to main content
Glama

update_collection

Update a Shopify collection's title, description, or URL handle. Changing the handle breaks existing links without automatic redirects. Only include fields to change.

Instructions

Update an existing collection's title, description (HTML), or URL handle. Only provide fields you want to change; omitted fields are left untouched. Changing the handle changes the storefront URL — Shopify does NOT create automatic redirects from the old slug, so existing links break. To change collection membership use add_products_to_collection / remove_products_from_collection instead.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesGID of the collection to update.
titleNoNew display title. Omit to leave unchanged.
descriptionNoNew HTML body for the collection page. Pass an empty string to clear it.
handleNoNew URL slug. Changing a handle breaks any external links pointing at the old URL — Shopify does NOT auto-redirect.

Implementation Reference

  • The handler function for 'update_collection' tool. Takes id (required), and optional title, description, and handle fields. Calls Shopify's collectionUpdate GraphQL mutation via ShopifyClient.graphql, with the UPDATE_COLLECTION_MUTATION query. Throws on user errors and returns the updated collection's title, handle, and ID.
    server.tool(
      "update_collection",
      "Update an existing collection's title, description (HTML), or URL handle. Only provide fields you want to change; omitted fields are left untouched. Changing the handle changes the storefront URL — Shopify does NOT create automatic redirects from the old slug, so existing links break. To change collection membership use add_products_to_collection / remove_products_from_collection instead.",
      updateCollectionSchema,
      async (args) => {
        const input: Record<string, unknown> = { id: args.id };
        if (args.title !== undefined) input.title = args.title;
        if (args.description !== undefined) input.descriptionHtml = args.description;
        if (args.handle !== undefined) input.handle = args.handle;
    
        const data = await client.graphql<{
          collectionUpdate: {
            collection: Collection | null;
            userErrors: ShopifyUserError[];
          };
        }>(UPDATE_COLLECTION_MUTATION, { input });
        throwIfUserErrors(data.collectionUpdate.userErrors, "collectionUpdate");
        const c = data.collectionUpdate.collection;
        if (!c) {
          return {
            content: [
              { type: "text" as const, text: "collectionUpdate returned no collection." },
            ],
          };
        }
        return {
          content: [
            {
              type: "text" as const,
              text: `Updated collection "${c.title}" — ${c.handle} — ${c.id}`,
            },
          ],
        };
      },
  • Zod schema for update_collection input validation. Requires 'id' (string), and optionally accepts 'title', 'description', and 'handle' strings.
    const updateCollectionSchema = {
      id: z
        .string()
        .describe("GID of the collection to update."),
      title: z.string().optional().describe("New display title. Omit to leave unchanged."),
      description: z
        .string()
        .optional()
        .describe(
          "New HTML body for the collection page. Pass an empty string to clear it.",
        ),
      handle: z
        .string()
        .optional()
        .describe(
          "New URL slug. Changing a handle breaks any external links pointing at the old URL — Shopify does NOT auto-redirect.",
        ),
    };
  • Registration of the 'update_collection' tool via server.tool() inside registerCollectionTools function. The tool is named 'update_collection', uses the updateCollectionSchema, and the async handler defined inline.
    server.tool(
      "update_collection",
      "Update an existing collection's title, description (HTML), or URL handle. Only provide fields you want to change; omitted fields are left untouched. Changing the handle changes the storefront URL — Shopify does NOT create automatic redirects from the old slug, so existing links break. To change collection membership use add_products_to_collection / remove_products_from_collection instead.",
      updateCollectionSchema,
      async (args) => {
        const input: Record<string, unknown> = { id: args.id };
        if (args.title !== undefined) input.title = args.title;
        if (args.description !== undefined) input.descriptionHtml = args.description;
        if (args.handle !== undefined) input.handle = args.handle;
    
        const data = await client.graphql<{
          collectionUpdate: {
            collection: Collection | null;
            userErrors: ShopifyUserError[];
          };
        }>(UPDATE_COLLECTION_MUTATION, { input });
        throwIfUserErrors(data.collectionUpdate.userErrors, "collectionUpdate");
        const c = data.collectionUpdate.collection;
        if (!c) {
          return {
            content: [
              { type: "text" as const, text: "collectionUpdate returned no collection." },
            ],
          };
        }
        return {
          content: [
            {
              type: "text" as const,
              text: `Updated collection "${c.title}" — ${c.handle} — ${c.id}`,
            },
          ],
        };
      },
    );
  • The GraphQL mutation string used by the update_collection handler. Calls Shopify's collectionUpdate mutation with a CollectionInput, returning the collection's id, handle, title, and any user errors.
    const UPDATE_COLLECTION_MUTATION = /* GraphQL */ `
      mutation CollectionUpdate($input: CollectionInput!) {
        collectionUpdate(input: $input) {
          collection {
            id
            handle
            title
          }
          userErrors { field message }
        }
      }
    `;
Behavior4/5

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

Despite no annotations, the description discloses the critical behavioral trait that changing the handle does not create redirects, breaking existing links. It also notes description is HTML. Could mention more about side effects but sufficiently 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?

Four sentences, front-loaded with purpose, then guidelines, then warning, then alternative tools. No redundancy; every sentence earns its place.

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?

For a 4-parameter tool with no output schema or annotations, the description covers key aspects: updated fields, partial update behavior, handle breakage caution, and referral to siblings. Could add more about error conditions but is adequate.

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?

Schema coverage is 100%, so baseline is 3. The description adds value by clarifying partial update semantics (only provide fields to change) and that empty string clears description, providing context beyond schema.

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 updates an existing collection's title, description (HTML), or URL handle, distinguishing it from creation, deletion, and membership-changing tools like create_collection, delete_collection, and add_products_to_collection.

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 only provide fields to change (omitted fields untouched), warns about handle change breaking links, and directs to sibling tools for membership changes, providing clear when-to-use and when-not-to-use guidance.

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