Skip to main content
Glama

create_collection

Create a manual collection on Shopify with a required title. Optionally add a description, custom URL handle, or seed product IDs. Returns the collection's GID for subsequent management.

Instructions

Create a new manual collection (rule-based 'smart' collections aren't supported here — use the Shopify admin for those). Title is required; description, handle, and an initial product list are optional. Returns the new collection's GID, which you'll need for subsequent add_products_to_collection or update_collection calls. Side effect: collection becomes immediately visible in the storefront unless you've configured publication channels separately.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
titleYesDisplay title shown to shoppers. Required.
descriptionNoHTML body for the collection page. Plain text works; HTML tags render.
handleNoURL slug (e.g. 'summer-sale'). Defaults to a slugified title. Must be unique per shop.
productIdsNoProduct GIDs to seed into the new (manual) collection. Smart collections built from rules aren't supported by this tool — use the Shopify admin UI for those.

Implementation Reference

  • The handler function for the create_collection tool. It builds the GraphQL input from args (title required; optional descriptionHtml, handle, products), executes CREATE_COLLECTION_MUTATION via the Shopify client, checks for user errors, and returns the created collection's title/handle/id.
    async (args) => {
      const input: Record<string, unknown> = { title: args.title };
      if (args.description) input.descriptionHtml = args.description;
      if (args.handle) input.handle = args.handle;
      if (args.productIds) input.products = args.productIds;
    
      const data = await client.graphql<{
        collectionCreate: {
          collection: Collection | null;
          userErrors: ShopifyUserError[];
        };
      }>(CREATE_COLLECTION_MUTATION, { input });
      throwIfUserErrors(data.collectionCreate.userErrors, "collectionCreate");
      const c = data.collectionCreate.collection;
      if (!c) {
        return {
          content: [
            { type: "text" as const, text: "collectionCreate returned no collection." },
          ],
        };
      }
      return {
        content: [
          {
            type: "text" as const,
            text: `Created collection "${c.title}" — ${c.handle} — ${c.id}`,
          },
        ],
      };
    },
  • The Zod-based input schema for create_collection. Defines title (required, min 1), description (optional HTML), handle (optional URL slug), and productIds (optional array of product GIDs).
    const createCollectionSchema = {
      title: z
        .string()
        .min(1)
        .describe("Display title shown to shoppers. Required."),
      description: z
        .string()
        .optional()
        .describe(
          "HTML body for the collection page. Plain text works; HTML tags render.",
        ),
      handle: z
        .string()
        .optional()
        .describe(
          "URL slug (e.g. 'summer-sale'). Defaults to a slugified title. Must be unique per shop.",
        ),
      productIds: z
        .array(z.string())
        .optional()
        .describe(
          "Product GIDs to seed into the new (manual) collection. Smart collections built from rules aren't supported by this tool — use the Shopify admin UI for those.",
        ),
    };
  • Registration of the 'create_collection' tool on the MCP server via server.tool(), including its description string and schema reference.
    server.tool(
      "create_collection",
      "Create a new manual collection (rule-based 'smart' collections aren't supported here — use the Shopify admin for those). Title is required; description, handle, and an initial product list are optional. Returns the new collection's GID, which you'll need for subsequent add_products_to_collection or update_collection calls. Side effect: collection becomes immediately visible in the storefront unless you've configured publication channels separately.",
      createCollectionSchema,
      async (args) => {
        const input: Record<string, unknown> = { title: args.title };
        if (args.description) input.descriptionHtml = args.description;
        if (args.handle) input.handle = args.handle;
        if (args.productIds) input.products = args.productIds;
    
        const data = await client.graphql<{
          collectionCreate: {
            collection: Collection | null;
            userErrors: ShopifyUserError[];
          };
        }>(CREATE_COLLECTION_MUTATION, { input });
        throwIfUserErrors(data.collectionCreate.userErrors, "collectionCreate");
        const c = data.collectionCreate.collection;
        if (!c) {
          return {
            content: [
              { type: "text" as const, text: "collectionCreate returned no collection." },
            ],
          };
        }
        return {
          content: [
            {
              type: "text" as const,
              text: `Created collection "${c.title}" — ${c.handle} — ${c.id}`,
            },
          ],
        };
      },
    );
  • The GraphQL mutation (CREATE_COLLECTION_MUTATION) that creates a collection via Shopify's CollectionCreate mutation.
    const CREATE_COLLECTION_MUTATION = /* GraphQL */ `
      mutation CollectionCreate($input: CollectionInput!) {
        collectionCreate(input: $input) {
          collection {
            id
            handle
            title
          }
          userErrors { field message }
        }
      }
  • src/server.ts:63-63 (registration)
    The call to registerCollectionTools(s, shopify) in server.ts that wires all collection tools (including create_collection) into the MCP server.
    registerCollectionTools(s, shopify);
Behavior4/5

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

With no annotations provided, the description carries full burden. It discloses the side effect that the collection becomes visible in the storefront unless publication channels are configured separately, and notes that the return value is a GID. It does not cover authentication or rate limits, but for a creation tool, the transparency is good.

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 useful: first states purpose and limitation, second lists required vs optional, third explains return value and side effect. No wasted words, perfectly front-loaded.

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 has 4 parameters, no annotations, and no output schema, the description adequately covers: purpose, required fields, return value (GID), side effect, and a usage pointer to sibling tools. It is complete for an agent to understand and invoke correctly.

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 description coverage is 100%, so baseline is 3. The description adds value by explaining that handle defaults to slugified title and must be unique, and that productIds are for seeding manual collections (not smart). This goes beyond the schema's definitions.

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 'Create a new manual collection' and explicitly distinguishes from rule-based smart collections, which are unsupported. It provides a specific verb (create) and resource (collection), differentiating it from sibling tools like update_collection or delete_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?

The description tells when to use this tool (for manual collections) and when not to (smart collections should use the Shopify admin). It also explains the return value (GID) and how it is needed for subsequent calls like add_products_to_collection, providing clear context for usage.

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