Skip to main content
Glama

create_product

Creates a new product with title and optional details, defaulting to DRAFT status. After creation, attaches provided image URLs. Returns product 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

  • The tool handler function for 'create_product'. It calls the Shopify GraphQL productCreate mutation with the input (title, descriptionHtml, vendor, productType, tags, status), then optionally attaches image URLs via attachImages, and returns a text result with the product GID and handle.
    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") }] };
      },
  • The input schema for create_product: title (required), description, vendor, product_type, tags, status (defaults to DRAFT), and image_urls (array of URL strings).
    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"),
    };
  • Registration: the tool is registered via server.tool('create_product', ...) inside the registerProductTools function. This function is called from src/server.ts:57.
    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") }] };
      },
    );
  • The GraphQL mutation string CREATE_PRODUCT_MUTATION used by the create_product handler.
    const CREATE_PRODUCT_MUTATION = /* GraphQL */ `
      mutation CreateProduct($input: ProductInput!) {
        productCreate(input: $input) {
          product {
            id
            title
            handle
            status
          }
          userErrors { field message }
        }
      }
    `;
  • The attachImages helper function used by create_product 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,
      );
Behavior5/5

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

With no annotations, the description fully discloses key behaviors: product creation first then image attachment, default DRAFT status to prevent premature publishing, initial hidden 'Default Title' variant, and the need for create_variants to add real options. The return value (GID and handle) is also specified.

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 concise and well-structured: starts with the main action, then discusses image attachment, status, variants, and return value in logical order. Every sentence adds valuable information without redundancy.

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 the parameter count (7), low schema coverage (29%), no output schema, and no annotations, the description covers essential aspects: return value, process steps, and best practices. It could mention prerequisites or side effects (e.g., authentication needs, rate limits) but is otherwise thorough for the tool's complexity.

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 only 29%, but the description adds meaning for key parameters: explains image_urls (attached after creation), status (default DRAFT, use ACTIVE when ready), and alludes to title. However, it does not elaborate on vendor, product_type, or tags beyond the schema, missing an opportunity to fully compensate for low coverage.

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' and details the creation process, distinguishing it from sibling tools like create_variants and update_product. It explains the two-step image attachment, default status, and variant handling, making the purpose unambiguous.

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 provides explicit guidance: use default status DRAFT to avoid accidental publishing, pass status=ACTIVE when ready to go live, and call create_variants for real variants. It also clarifies the image attachment process as a follow-up, helping the agent decide when and how to use the tool.

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