Skip to main content
Glama

create_product

Generate custom print-on-demand products by specifying title, description, blueprint, provider, variants, and print areas using the Printify MCP Server integration.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
blueprintIdYesBlueprint ID
descriptionYesProduct description
printAreasNoPrint areas for the product
printProviderIdYesPrint provider ID
titleYesProduct title
variantsYesProduct variants

Implementation Reference

  • The inline async handler function that executes the create_product tool logic: checks printifyClient, calls the service createProduct function, and returns formatted response.
    async ({ title, description, blueprintId, printProviderId, variants, printAreas }): Promise<{ content: any[], isError?: boolean }> => {
      // Import the printify products service
      const { createProduct } = await import('./services/printify-products.js');
    
      // Check if client is initialized
      if (!printifyClient) {
        return {
          content: [{
            type: "text",
            text: "Printify API client is not initialized. The PRINTIFY_API_KEY environment variable may not be set."
          }],
          isError: true
        };
      }
    
      // Call the service
      const result = await createProduct(printifyClient, {
        title,
        description,
        blueprintId,
        printProviderId,
        variants,
        printAreas
      });
    
      // Return the result
      if (result.success) {
        return result.response as { content: any[], isError?: boolean };
      } else {
        return result.errorResponse as { content: any[], isError: boolean };
      }
    }
  • Zod input schema defining parameters for the create_product tool.
    {
      title: z.string().describe("Product title"),
      description: z.string().describe("Product description"),
      blueprintId: z.number().describe("Blueprint ID"),
      printProviderId: z.number().describe("Print provider ID"),
      variants: z.array(z.object({
        variantId: z.number().describe("Variant ID"),
        price: z.number().describe("Price in cents (e.g., 1999 for $19.99)"),
        isEnabled: z.boolean().optional().default(true).describe("Whether the variant is enabled")
      })).describe("Product variants"),
      printAreas: z.record(z.string(), z.object({
        position: z.string().describe("Print position (e.g., 'front', 'back')"),
        imageId: z.string().describe("Image ID from Printify uploads")
      })).optional().describe("Print areas for the product")
    },
  • src/index.ts:251-300 (registration)
    MCP server.tool registration for the 'create_product' tool, including schema and handler.
    server.tool(
      "create_product",
      {
        title: z.string().describe("Product title"),
        description: z.string().describe("Product description"),
        blueprintId: z.number().describe("Blueprint ID"),
        printProviderId: z.number().describe("Print provider ID"),
        variants: z.array(z.object({
          variantId: z.number().describe("Variant ID"),
          price: z.number().describe("Price in cents (e.g., 1999 for $19.99)"),
          isEnabled: z.boolean().optional().default(true).describe("Whether the variant is enabled")
        })).describe("Product variants"),
        printAreas: z.record(z.string(), z.object({
          position: z.string().describe("Print position (e.g., 'front', 'back')"),
          imageId: z.string().describe("Image ID from Printify uploads")
        })).optional().describe("Print areas for the product")
      },
      async ({ title, description, blueprintId, printProviderId, variants, printAreas }): Promise<{ content: any[], isError?: boolean }> => {
        // Import the printify products service
        const { createProduct } = await import('./services/printify-products.js');
    
        // Check if client is initialized
        if (!printifyClient) {
          return {
            content: [{
              type: "text",
              text: "Printify API client is not initialized. The PRINTIFY_API_KEY environment variable may not be set."
            }],
            isError: true
          };
        }
    
        // Call the service
        const result = await createProduct(printifyClient, {
          title,
          description,
          blueprintId,
          printProviderId,
          variants,
          printAreas
        });
    
        // Return the result
        if (result.success) {
          return result.response as { content: any[], isError?: boolean };
        } else {
          return result.errorResponse as { content: any[], isError: boolean };
        }
      }
    );
  • Helper service function createProduct that wraps the API call with validation, error handling, and standardized response format.
    export async function createProduct(
      printifyClient: PrintifyAPI,
      productData: {
        title: string;
        description: string;
        blueprintId: number;
        printProviderId: number;
        variants: Array<{
          variantId: number;
          price: number;
          isEnabled?: boolean;
        }>;
        printAreas?: Record<string, {
          position: string;
          imageId: string;
        }>;
      }
    ) {
      try {
        // Validate shop is selected
        const currentShop = printifyClient.getCurrentShop();
        if (!currentShop) {
          throw new Error('No shop is currently selected. Use the list-shops and switch-shop tools to select a shop.');
        }
    
        // Create product
        const product = await printifyClient.createProduct(productData);
    
        return {
          success: true,
          product,
          response: formatSuccessResponse(
            'Product Created Successfully',
            {
              ProductId: product.id,
              Title: product.title,
              Shop: currentShop
            },
            `You can now publish this product using the publish-product tool.`
          )
        };
      } catch (error: any) {
        console.error('Error creating product:', error);
    
        return {
          success: false,
          error,
          errorResponse: formatErrorResponse(
            error,
            'Create Product',
            {
              Title: productData.title,
              BlueprintId: productData.blueprintId,
              PrintProviderId: productData.printProviderId,
              VariantsCount: productData.variants.length,
              Shop: printifyClient.getCurrentShop()
            },
            [
              'Check that the blueprint ID is valid',
              'Check that the print provider ID is valid',
              'Check that the variant IDs are valid',
              'Ensure your Printify account is properly connected',
              'Make sure you have selected a shop'
            ]
          )
        };
      }
    }
  • Low-level PrintifyAPI class method that formats request data and calls the Printify SDK to create the product.
    async createProduct(productData: any) {
      if (!this.shopId) {
        throw new Error('Shop ID is not set. Call setShopId() first.');
      }
    
      try {
        // Format the product data to match the API's expected format
        const formattedData: any = {
          title: productData.title,
          description: productData.description,
          blueprint_id: parseInt(productData.blueprint_id || productData.blueprintId),
          print_provider_id: parseInt(productData.print_provider_id || productData.printProviderId),
          variants: [],
          print_areas: []
        };
    
        // Format variants
        if (productData.variants && Array.isArray(productData.variants)) {
          formattedData.variants = productData.variants.map((variant: any) => {
            return {
              id: parseInt(variant.id || variant.variantId),
              price: parseInt(variant.price),
              is_enabled: variant.isEnabled !== false
            };
          });
        }
    
        // Log the raw data received
        console.log('Raw product data received:', JSON.stringify(productData, null, 2));
    
        // Format print areas - handle both print_areas and printAreas formats
        const printAreasData = productData.print_areas || productData.printAreas;
        if (printAreasData) {
          // Get all variant IDs from the variants array
          const variantIds = formattedData.variants.map((v: any) => v.id);
    
          // Create a print area entry with all variants
          const printAreaEntry: any = {
            variant_ids: variantIds,
            placeholders: []
          };
    
          // Add placeholders for each position (front, back, etc.)
          for (const key in printAreasData) {
            const area = printAreasData[key];
            printAreaEntry.placeholders.push({
              position: area.position,
              images: [
                {
                  id: area.image_id || area.imageId,
                  x: 0.5,
                  y: 0.5,
                  scale: 1,
                  angle: 0
                }
              ]
            });
          }
    
          // Add the print area entry to the formatted data
          formattedData.print_areas.push(printAreaEntry);
        }
    
        console.log(`Creating product with shop ID: ${this.shopId}`);
        console.log('Formatted product data:', JSON.stringify(formattedData, null, 2));
    
        try {
          // Use the products.create method with the formatted data
          const result = await this.client.products.create(formattedData);
          return result;
        } catch (error: any) {
          // Add the formatted data to the error object for better debugging
          error.formattedData = formattedData;
    
          // Log the full error response
          console.error('Full error response:', error);
    
          // If there's a response object, extract and log the full response data
          if (error.response) {
            console.error('Response status:', error.response.status);
            console.error('Response data:', JSON.stringify(error.response.data, null, 2));
    
            // Add the full response data to the error object
            error.fullResponseData = error.response.data;
          }
    
          throw error;
        }
      } catch (error) {
        console.error('Error creating product:', error);
        throw this.enhanceError(error, productData);
      }
    }
Behavior1/5

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

Tool has no description.

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

Conciseness1/5

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

Tool has no description.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Tool has no description.

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

Parameters1/5

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

Tool has no description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose1/5

Does the description clearly state what the tool does and how it differs from similar tools?

Tool has no description.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines1/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Tool has no description.

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

Related 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/TSavo/printify-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server