Skip to main content
Glama

create_product

Create a Shopify product with default draft status to avoid premature publishing. Optionally attach public image URLs. Get back the product's GID and handle.

Instructions

Create a new product. The product is created first, then any image_urls (publicly fetchable) are attached as a follow-up call — Shopify pulls each URL and hosts the image on its CDN. The default status is DRAFT to prevent accidentally publishing half-configured products to the storefront; pass status=ACTIVE only when you're ready to go live. New products start with a single hidden 'Default Title' variant; to add real variants with options, call create_variants with strategy='REMOVE_STANDALONE_VARIANT'. Returns the new product's GID and handle.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
titleYes
descriptionNoDescription as HTML
vendorNo
product_typeNo
tagsNo
statusNoDRAFT
image_urlsNoImage URLs to attach after creation

Implementation Reference

  • Tool 'create_product' is registered on the MCP server via server.tool(...) with its name, description, schema and handler.
    server.tool(
      "create_product",
      "Create a new product. The product is created first, then any image_urls (publicly fetchable) are attached as a follow-up call — Shopify pulls each URL and hosts the image on its CDN. The default `status` is DRAFT to prevent accidentally publishing half-configured products to the storefront; pass status=ACTIVE only when you're ready to go live. New products start with a single hidden 'Default Title' variant; to add real variants with options, call create_variants with strategy='REMOVE_STANDALONE_VARIANT'. Returns the new product's GID and handle.",
      createProductSchema,
      async (args) => {
        const data = await client.graphql<{
          productCreate: {
            product: Product | null;
            userErrors: ShopifyUserError[];
          };
        }>(CREATE_PRODUCT_MUTATION, {
          input: {
            title: args.title,
            descriptionHtml: args.description,
            vendor: args.vendor,
            productType: args.product_type,
            tags: args.tags,
            status: args.status,
          },
        });
        throwIfUserErrors(data.productCreate.userErrors, "productCreate");
        const product = data.productCreate.product;
        if (!product) throw new Error("productCreate returned no product");
    
        const attached: string[] = [];
        if (args.image_urls?.length) {
          await attachImages(client, product.id, args.image_urls);
          attached.push(...args.image_urls);
        }
    
        const lines = [
          `Created ${args.status} product: ${product.title} (${product.id})`,
          `  handle: ${product.handle}`,
        ];
        if (attached.length) {
          lines.push(`  attached ${attached.length} image(s)`);
        }
        return { content: [{ type: "text" as const, text: lines.join("\n") }] };
      },
    );
  • Input schema for create_product using Zod: title (required string), description, vendor, product_type, tags, status (default DRAFT), and image_urls.
    const createProductSchema = {
      title: z.string().min(1),
      description: z.string().optional().describe("Description as HTML"),
      vendor: z.string().optional(),
      product_type: z.string().optional(),
      tags: z.array(z.string()).optional(),
      status: z.enum(["ACTIVE", "DRAFT", "ARCHIVED"]).default("DRAFT"),
      image_urls: z
        .array(z.string().url())
        .optional()
        .describe("Image URLs to attach after creation"),
    };
  • Handler function that executes the product creation via GraphQL mutation, then optionally attaches images via attachImages helper.
      async (args) => {
        const data = await client.graphql<{
          productCreate: {
            product: Product | null;
            userErrors: ShopifyUserError[];
          };
        }>(CREATE_PRODUCT_MUTATION, {
          input: {
            title: args.title,
            descriptionHtml: args.description,
            vendor: args.vendor,
            productType: args.product_type,
            tags: args.tags,
            status: args.status,
          },
        });
        throwIfUserErrors(data.productCreate.userErrors, "productCreate");
        const product = data.productCreate.product;
        if (!product) throw new Error("productCreate returned no product");
    
        const attached: string[] = [];
        if (args.image_urls?.length) {
          await attachImages(client, product.id, args.image_urls);
          attached.push(...args.image_urls);
        }
    
        const lines = [
          `Created ${args.status} product: ${product.title} (${product.id})`,
          `  handle: ${product.handle}`,
        ];
        if (attached.length) {
          lines.push(`  attached ${attached.length} image(s)`);
        }
        return { content: [{ type: "text" as const, text: lines.join("\n") }] };
      },
    );
  • attachImages helper used by create_product handler to attach image URLs to a product after creation.
    export async function attachImages(
      client: ShopifyClient,
      productId: string,
      imageUrls: string[],
      altText?: string,
    ): Promise<Array<{ id: string }>> {
      const data = await client.graphql<{
        productCreateMedia: {
          media: Array<{ id: string } | null>;
          mediaUserErrors: ShopifyUserError[];
        };
      }>(CREATE_MEDIA_MUTATION, {
        productId,
        media: imageUrls.map((url) => ({
          originalSource: url,
          mediaContentType: "IMAGE",
          alt: altText,
        })),
      });
      throwIfUserErrors(data.productCreateMedia.mediaUserErrors, "productCreateMedia");
      return data.productCreateMedia.media.filter(
        (m): m is { id: string } => m !== null,
      );
    }
  • src/server.ts:57-57 (registration)
    Import and call of registerProductTools which registers create_product along with other product tools.
    registerProductTools(s, shopify);
Behavior4/5

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

With no annotations, the description carries the full burden. It discloses key behaviors: image URLs are fetched by Shopify as a follow-up, default status is DRAFT to prevent premature publishing, and the initial variant is hidden and can be replaced. These details go beyond the schema.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is composed of five sentences, each adding essential information without redundancy. While slightly lengthy, the information is front-loaded and well-structured, making it easy to parse.

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?

Given 7 parameters, no output schema, and no annotations, the description covers the creation process, image attachment, status implications, variant handling, and return values. It is nearly complete but lacks mention of error handling or validation edges.

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

Parameters3/5

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

Schema coverage is low (29%), so the description must compensate. It adds meaningful context for 'status' (explains default and when to use ACTIVE) and 'image_urls' (explains public fetch and hosting). However, other parameters like 'vendor', 'product_type', and 'tags' receive no additional explanation, leaving gaps.

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 product' with a specific verb and resource. It distinguishes from siblings like update_product and create_variants by detailing the creation flow, default status, and image attachment process.

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 explains when to use this tool (to create a product) and provides guidance on default status and variant handling. It explicitly mentions an alternative: call create_variants for adding real variants. However, it does not explicitly state when not to use it (e.g., for updates).

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