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
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | GID of the collection to update. | |
| title | No | New display title. Omit to leave unchanged. | |
| description | No | New HTML body for the collection page. Pass an empty string to clear it. | |
| handle | No | New URL slug. Changing a handle breaks any external links pointing at the old URL — Shopify does NOT auto-redirect. |
Implementation Reference
- src/tools/collections.ts:387-420 (handler)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}`, }, ], }; }, - src/tools/collections.ts:198-215 (schema)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.", ), }; - src/tools/collections.ts:387-421 (registration)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}`, }, ], }; }, ); - src/tools/collections.ts:76-87 (helper)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 } } } `;