### Start Printify MCP Server (Bash) Source: https://github.com/tsavo/printify-mcp/blob/main/README.md Starts the Printify MCP server using the npm start script defined in the package.json file. This command runs the compiled application, making it available for Claude Desktop to connect to. ```bash npm start ``` -------------------------------- ### Install Dependencies and Build Project (Bash) Source: https://github.com/tsavo/printify-mcp/blob/main/README.md Installs the necessary project dependencies using npm and then runs the build script defined in the package.json file to compile the project. This prepares the project for execution. ```bash npm install npm run build ``` -------------------------------- ### Copying .env Example File (Bash) Source: https://github.com/tsavo/printify-mcp/blob/main/README.md Copies the example environment file `.env.example` to `.env` in the project root directory. This provides a template for configuring the server with necessary API keys and settings. ```bash cp .env.example .env # Then edit the .env file with your actual API keys ``` -------------------------------- ### Installing Printify MCP Server Dependencies (Bash) Source: https://github.com/tsavo/printify-mcp/blob/main/README.md Clones the repository, navigates into the directory, installs Node.js dependencies using npm, and builds the project for production. Requires Git and Node.js/npm. ```bash # Clone the repository git clone https://github.com/tsavo/printify-mcp.git cd printify-mcp # Install dependencies npm install # Build the project npm run build ``` -------------------------------- ### Start Printify MCP Server (Production) Source: https://github.com/tsavo/printify-mcp/blob/main/README.md Starts the Printify MCP server in its standard production mode using the stdio transport. The server will initialize the Printify API client using the configured environment variables. ```bash npm start ``` -------------------------------- ### Build and Start with Docker Compose (Bash) Source: https://github.com/tsavo/printify-mcp/blob/main/README.md Command to build the Docker image (if necessary) and start the services defined in the `docker-compose.yml` file. The `-d` flag runs the containers in detached mode. ```bash docker-compose up -d ``` -------------------------------- ### Example Image Upload Response (JSON) Source: https://github.com/tsavo/printify-mcp/blob/main/src/docs/images.md Provides an example of the JSON response received after successfully uploading an image, including its unique ID, file name, dimensions, and a preview URL. ```json { "id": "680325163d2a2ac0a2d2937c", "file_name": "front.png", "width": 1200, "height": 1200, "preview_url": "https://images.printify.com/mockup/680325163d2a2ac0a2d2937c/12.png" } ``` -------------------------------- ### Install Printify MCP Globally via npm Source: https://github.com/tsavo/printify-mcp/blob/main/README.md Installs the Printify MCP package globally using npm. This allows the server to be run directly from the command line as `printify-mcp`, which is useful for configuring Claude Desktop. ```bash npm install -g @tsavo/printify-mcp ``` -------------------------------- ### Complete Printify Product Creation Workflow (JavaScript) Source: https://github.com/tsavo/printify-mcp/blob/main/src/docs/product_creation.md Shows a full end-to-end example of creating a t-shirt product using the Printify API, including steps for getting blueprints, print providers, and variants, generating and uploading images, and finally creating the product with all collected data. ```javascript // Step 1: Get blueprints and choose one get_blueprints() // Selected blueprint ID 12 (Unisex Jersey Short Sleeve Tee) // Step 2: Get print providers for this blueprint get_print_providers({ blueprintId: "12" }) // Selected print provider ID 29 (Monster Digital) // Step 3: Get variants for this blueprint and print provider get_variants({ blueprintId: "12", printProviderId: "29" }) // Selected variant IDs 18100 (Black / S), 18101 (Black / M), 18102 (Black / L) // Step 4: Generate and upload front image const frontImage = await generate_and_upload_image({ prompt: "A futuristic cityscape with neon lights and tall skyscrapers, horizon city logo design", fileName: "horizon-city-front" }) // Got image ID: 68032b22ae74bf725ed406ec // Step 4b: Generate and upload back image const backImage = await generate_and_upload_image({ prompt: "A minimalist 'Horizon City' text logo with futuristic font, suitable for the back of a t-shirt", fileName: "horizon-city-back" }) // Got image ID: 68032b377e36fbdd32791027 // Step 5: Create the product create_product({ title: "Horizon City Skyline T-Shirt", description: "Step into the future with our Horizon City Skyline T-Shirt. This premium unisex tee features a stunning futuristic cityscape with neon lights and towering skyscrapers on the front, and a sleek minimalist Horizon City logo on the back.", blueprintId: 12, printProviderId: 29, variants: [ { variantId: 18100, price: 2499 }, { variantId: 18101, price: 2499 }, { variantId: 18102, price: 2499 } ], printAreas: { "front": { position: "front", imageId: "68032b22ae74bf725ed406ec" }, "back": { position: "back", imageId: "68032b377e36fbdd32791027" } } }) // Product created with ID: 68032b43a24efbac6502b6f7 ``` -------------------------------- ### Start Printify MCP Server (Development) Source: https://github.com/tsavo/printify-mcp/blob/main/README.md Starts the Printify MCP server in development mode. This mode typically includes features like automatic reloading when source files are modified. ```bash npm run dev ``` -------------------------------- ### Getting Documentation - TypeScript Source: https://github.com/tsavo/printify-mcp/blob/main/docs/index.ts.md Provides detailed documentation on various predefined topics related to product management, blueprints, print providers, variants, images, and publishing. ```typescript server.tool( "how_to_use", { topic: z.enum([ "product-creation", "blueprints", "print-providers", "variants", "images", "publishing" ]).describe("The topic to get documentation for") }, async ({ topic }) => { // ... } ); ``` -------------------------------- ### Example .env Configuration File Source: https://github.com/tsavo/printify-mcp/blob/main/README.md Shows the required and optional environment variables for configuring the Printify MCP server. Includes API keys for Printify, ImgBB (for high-res images), and Replicate (for AI image generation), plus an optional shop ID. ```ini # Required for all functionality PRINTIFY_API_KEY=your_printify_api_key # Required if using the Flux 1.1 Pro Ultra model for image generation # The Ultra model generates high-resolution images that are too large for direct base64 upload IMGBB_API_KEY=your_imgbb_api_key # Optional: If not provided, the first shop in your account will be used PRINTIFY_SHOP_ID=your_shop_id # Optional: Only needed if you want to use image generation features REPLICATE_API_TOKEN=your_replicate_api_token ``` -------------------------------- ### Example Printify Blueprint Object - JSON Source: https://github.com/tsavo/printify-mcp/blob/main/src/docs/blueprints.md An example JSON object representing a single Printify blueprint, illustrating the structure and key properties returned when retrieving blueprint information. ```JSON { "id": 12, "title": "Unisex Jersey Short Sleeve Tee", "description": "A comfortable unisex t-shirt", "brand": "Bella+Canvas", "model": "3001" } ``` -------------------------------- ### Printify MCP .env Configuration File (Plaintext) Source: https://github.com/tsavo/printify-mcp/blob/main/README.md Example content for a `.env` file used to configure the Printify MCP Docker container. Contains API keys and optional shop ID. Includes placeholders for user-specific values and notes on optional/required keys for image generation features. ```plaintext PRINTIFY_API_KEY=their_printify_api_key PRINTIFY_SHOP_ID=their_shop_id (optional) # Optional: Only needed if they want to use image generation features REPLICATE_API_TOKEN=their_replicate_api_token # Required if using the Flux 1.1 Pro Ultra model for image generation IMGBB_API_KEY=their_imgbb_api_key ``` -------------------------------- ### Getting Blueprint Details - TypeScript Source: https://github.com/tsavo/printify-mcp/blob/main/docs/index.ts.md Gets detailed information for a specific product blueprint using its unique identifier. ```typescript server.tool( "get-blueprint", { blueprintId: z.string().describe("Blueprint ID") }, async ({ blueprintId }) => { // ... } ); ``` -------------------------------- ### Getting Product Details - TypeScript Source: https://github.com/tsavo/printify-mcp/blob/main/docs/index.ts.md Gets details of a specific product by its unique identifier. Requires the product ID as input. ```typescript server.tool( "get-product", { productId: z.string().describe("Product ID") }, async ({ productId }) => { // ... } ); ``` -------------------------------- ### Create .env File (Option 3A) Source: https://github.com/tsavo/printify-mcp/blob/main/README.md Example content for a `.env` file containing necessary API keys and an optional shop ID for the Printify MCP application. This file is used to configure the application when mounted as a volume. ```plaintext PRINTIFY_API_KEY=your_printify_api_key PRINTIFY_SHOP_ID=your_shop_id (optional) REPLICATE_API_TOKEN=your_replicate_api_token IMGBB_API_KEY=your_imgbb_api_key (required for Flux 1.1 Pro Ultra model) ``` -------------------------------- ### Set API Keys as Environment Variables (Windows) Source: https://github.com/tsavo/printify-mcp/blob/main/README.md Provides commands to set the required Printify, Replicate, and ImgBB API keys as environment variables directly in the Windows command prompt before starting the server. ```bash # On Windows set PRINTIFY_API_KEY=your_api_key_here set REPLICATE_API_TOKEN=your_replicate_token_here set IMGBB_API_KEY=your_imgbb_api_key_here npm start ``` -------------------------------- ### Getting Product Blueprints - TypeScript Source: https://github.com/tsavo/printify-mcp/blob/main/docs/index.ts.md Retrieves a list of available product blueprints. Supports pagination via optional page and limit parameters. ```typescript server.tool( "get-blueprints", { page: z.number().optional().default(1).describe("Page number"), limit: z.number().optional().default(10).describe("Number of blueprints per page") }, async ({ page, limit }) => { // ... } ); ``` -------------------------------- ### Run Printify MCP via npx Source: https://github.com/tsavo/printify-mcp/blob/main/README.md Executes the Printify MCP package using npx. This method runs the server without requiring a global installation and is an alternative way to configure Claude Desktop. ```bash npx @tsavo/printify-mcp ``` -------------------------------- ### Workflow: Setting Defaults and Generating Multiple Images (JavaScript) Source: https://github.com/tsavo/printify-mcp/blob/main/src/docs/image_generation.md This example demonstrates a workflow in JavaScript where common generation parameters like the model, aspect ratio, raw setting, and guidance scale are set as defaults at the beginning. Subsequent calls to `generate_and_upload_image` then inherit these defaults, requiring only the prompt and filename for each individual image generation. ```javascript // Set up your preferred defaults at the beginning of your session set_default({ option: "model", value: "black-forest-labs/flux-1.1-pro-ultra" }) // Set default model set_default({ option: "aspectRatio", value: "16:9" }) set_default({ option: "raw", value: true }) set_default({ option: "guidanceScale", value: 8.0 }) // Now generate multiple images with minimal parameters const frontImage = await generate_and_upload_image({ prompt: "A futuristic cityscape with neon lights and tall skyscrapers", fileName: "cityscape-front.png" }) const backImage = await generate_and_upload_image({ prompt: "A minimalist futuristic logo with geometric shapes", fileName: "logo-back.png" }) ``` -------------------------------- ### Error Handling Example - TypeScript Source: https://github.com/tsavo/printify-mcp/blob/main/docs/printify-api.ts.md An example of a catch block demonstrating the error handling pattern used in the client. It logs the error and then throws an enhanced version of the error, including relevant request data for better debugging. ```typescript catch (error: any) { console.error('Error uploading image:', error); throw this.enhanceError(error, { fileName, sourceType: typeof source, sourceLength: source.length }); } ``` -------------------------------- ### Managing Printify Products (JavaScript) Source: https://github.com/tsavo/printify-mcp/blob/main/README.md Provides examples of common operations for managing products via the Printify API using specific JavaScript functions. Includes listing all products, retrieving details for a single product, updating product information (title, description, variants), publishing a product to sales channels, and deleting a product. ```javascript // List products list-products_printify() // Get details of a specific product get-product_printify({ productId: "68032b43a24efbac6502b6f7" }) // Update a product update-product_printify({ productId: "68032b43a24efbac6502b6f7", title: "Updated Horizon City Skyline T-Shirt", description: "Updated description...", variants: [ { variantId: 18100, price: 2999 }, { variantId: 18101, price: 2999 }, { variantId: 18102, price: 2999 } ] }) // Publish a product to external sales channels publish-product_printify({ productId: "68032b43a24efbac6502b6f7", publishDetails: { title: true, description: true, images: true, variants: true, tags: true } }) // Delete a product delete-product_printify({ productId: "68032b43a24efbac6502b6f7" }) ``` -------------------------------- ### Example Variants Array for Printify Product Creation (JSON) Source: https://github.com/tsavo/printify-mcp/blob/main/src/docs/variants.md Shows the required format for the variants array when creating a product via the Printify API. Each object includes the variant ID and the desired retail price in cents. ```JSON [ { "variantId": 18100, "price": 2499 }, { "variantId": 18101, "price": 2499 }, { "variantId": 18102, "price": 2499 } ] ``` -------------------------------- ### Example Printify Variant Object (JSON) Source: https://github.com/tsavo/printify-mcp/blob/main/src/docs/variants.md Illustrates the structure of a single variant object returned by the Printify API, showing its unique ID, title, options (like color and size), and the cost from the print provider. ```JSON { "id": 18100, "title": "Black / S", "options": { "color": "Black", "size": "S" }, "cost": 1992 } ``` -------------------------------- ### Set API Keys as Environment Variables (macOS/Linux) Source: https://github.com/tsavo/printify-mcp/blob/main/README.md Provides commands to set the required Printify, Replicate, and ImgBB API keys as environment variables directly in the macOS/Linux terminal before starting the server. ```bash # On macOS/Linux export PRINTIFY_API_KEY=your_api_key_here export REPLICATE_API_TOKEN=your_replicate_token_here export IMGBB_API_KEY=your_imgbb_api_key_here npm start ``` -------------------------------- ### Getting Available Shops (TypeScript) Source: https://github.com/tsavo/printify-mcp/blob/main/docs/printify-api.ts.md Synchronously returns the array of shops that were fetched during initialization. ```typescript getAvailableShops(): PrintifyShop[] ``` -------------------------------- ### Getting Shops List (TypeScript) Source: https://github.com/tsavo/printify-mcp/blob/main/docs/printify-api.ts.md Asynchronously fetches and returns a list of all available shops from the Printify API. ```typescript async getShops() ``` -------------------------------- ### Getting Products List (TypeScript) Source: https://github.com/tsavo/printify-mcp/blob/main/docs/printify-api.ts.md Asynchronously fetches and returns a paginated list of products from the Printify API, allowing specification of page number and limit. ```typescript async getProducts(page = 1, limit = 10) ``` -------------------------------- ### Create .env File (Option 3B) Source: https://github.com/tsavo/printify-mcp/blob/main/README.md Example content for a `.env` file containing necessary API keys and an optional shop ID for the Printify MCP application when using Docker Compose. This file is an alternative to setting variables directly in `docker-compose.yml`. ```plaintext PRINTIFY_API_KEY=your_printify_api_key PRINTIFY_SHOP_ID=your_shop_id (optional) # Optional: Only needed if you want to use image generation features REPLICATE_API_TOKEN=your_replicate_api_token # Required if using the Flux 1.1 Pro Ultra model for image generation IMGBB_API_KEY=your_imgbb_api_key ``` -------------------------------- ### Create Printify Product with AI Images (JavaScript) Source: https://github.com/tsavo/printify-mcp/blob/main/README.md Demonstrates a JavaScript workflow for creating a Printify t-shirt product. It covers steps like getting blueprints, print providers, and variants, generating and uploading images using AI, and finally creating the product with specified variants and print areas. ```javascript // Step 1: Get blueprints and choose one get-blueprints_printify() // Selected blueprint ID 12 (Unisex Jersey Short Sleeve Tee) // Step 2: Get print providers for this blueprint get-print-providers_printify({ blueprintId: "12" }) // Selected print provider ID 29 (Monster Digital) // Step 3: Get variants for this blueprint and print provider get-variants_printify({ blueprintId: "12", printProviderId: "29" }) // Selected variant IDs 18100 (Black / S), 18101 (Black / M), 18102 (Black / L) // Step 4: Generate and upload front image const frontImage = await generate-and-upload-image_printify({ prompt: "A futuristic cityscape with neon lights and tall skyscrapers, horizon city logo design", fileName: "horizon-city-front" }) // Got image ID: 68032b22ae74bf725ed406ec // Step 4b: Generate and upload back image const backImage = await generate-and-upload-image_printify({ prompt: "A minimalist 'Horizon City' text logo with futuristic font, suitable for the back of a t-shirt", fileName: "horizon-city-back" }) // Got image ID: 68032b377e36fbdd32791027 // Step 5: Create the product create-product_printify({ title: "Horizon City Skyline T-Shirt", description: "Step into the future with our Horizon City Skyline T-Shirt. This premium unisex tee features a stunning futuristic cityscape with neon lights and towering skyscrapers on the front, and a sleek minimalist Horizon City logo on the back.", blueprintId: 12, printProviderId: 29, variants: [ { variantId: 18100, price: 2499 }, { variantId: 18101, price: 2499 }, { variantId: 18102, price: 2499 } ], printAreas: { "front": { position: "front", imageId: "68032b22ae74bf725ed406ec" }, "back": { position: "back", imageId: "68032b377e36fbdd32791027" } } }) // Product created with ID: 68032b43a24efbac6502b6f7 ``` -------------------------------- ### Getting Catalog Blueprints (TypeScript) Source: https://github.com/tsavo/printify-mcp/blob/main/docs/printify-api.ts.md Asynchronously fetches and returns a list of available catalog blueprints from the Printify API. ```typescript async getBlueprints() ``` -------------------------------- ### Getting Print Providers for Blueprint - TypeScript Source: https://github.com/tsavo/printify-mcp/blob/main/docs/index.ts.md Retrieves the list of available print providers that support a specific product blueprint. ```typescript server.tool( "get-print-providers", { blueprintId: z.string().describe("Blueprint ID") }, async ({ blueprintId }) => { // ... } ); ``` -------------------------------- ### Getting Variants for Blueprint and Provider - TypeScript Source: https://github.com/tsavo/printify-mcp/blob/main/docs/index.ts.md Retrieves the available product variants for a specific blueprint offered by a particular print provider. ```typescript server.tool( "get-variants", { blueprintId: z.string().describe("Blueprint ID"), printProviderId: z.string().describe("Print provider ID") }, async ({ blueprintId, printProviderId }) => { // ... } ); ``` -------------------------------- ### Get Compiled File Path (macOS/Linux Bash) Source: https://github.com/tsavo/printify-mcp/blob/main/README.md Uses the `realpath` command to get the full absolute path of the compiled 'index.js' file located in the 'dist' directory. This path is required for configuring Claude Desktop. ```bash realpath dist/index.js ``` -------------------------------- ### Getting Specific Product (TypeScript) Source: https://github.com/tsavo/printify-mcp/blob/main/docs/printify-api.ts.md Asynchronously fetches and returns the details of a single product identified by its ID from the Printify API. ```typescript async getProduct(productId: string) ``` -------------------------------- ### Getting Specific Blueprint (TypeScript) Source: https://github.com/tsavo/printify-mcp/blob/main/docs/printify-api.ts.md Asynchronously fetches and returns the details of a specific blueprint identified by its ID from the Printify API. ```typescript async getBlueprint(blueprintId: string) ``` -------------------------------- ### Getting Print Providers for a Blueprint (JavaScript) Source: https://github.com/tsavo/printify-mcp/blob/main/src/docs/print_providers.md This function call retrieves a list of print providers that are available for a specific product blueprint. It requires the unique identifier of the blueprint as a parameter. ```JavaScript get_print_providers({ blueprintId: "12" }) ``` -------------------------------- ### Getting Product Details - Printify API - JavaScript Source: https://github.com/tsavo/printify-mcp/blob/main/src/docs/publishing.md This snippet shows how to call the get_product API endpoint to retrieve detailed information about a specific product. It requires the unique identifier of the product. ```JavaScript get_product({ productId: "your-product-id" }) ``` -------------------------------- ### Getting Current Shop (TypeScript) Source: https://github.com/tsavo/printify-mcp/blob/main/docs/printify-api.ts.md Synchronously returns the details of the currently selected shop object, or null if none is selected. ```typescript getCurrentShop(): PrintifyShop | null ``` -------------------------------- ### Get Product Variants - Printify - JavaScript Source: https://github.com/tsavo/printify-mcp/blob/main/src/docs/product_creation.md Fetches all available variants (combinations of size, color, etc.) for a specific blueprint and print provider combination. This step requires both the blueprint ID and the print provider ID. The response details each variant's ID, title, options, and placeholders. ```javascript // Get available variants (sizes, colors, etc.) get_variants_printify({ blueprintId: "12", // Replace with your blueprint ID printProviderId: "29" // Replace with your print provider ID }) ``` -------------------------------- ### Get Available Blueprints - Printify - JavaScript Source: https://github.com/tsavo/printify-mcp/blob/main/src/docs/product_creation.md Fetches a list of all available product blueprints from Printify. The response includes essential details like the unique ID, title, description, and brand for each blueprint. The blueprint ID is required for subsequent steps in the product creation workflow. ```javascript // Get a list of all available blueprints get_blueprints_printify() ``` -------------------------------- ### Getting Available Variants for Blueprint and Print Provider (JavaScript) Source: https://github.com/tsavo/printify-mcp/blob/main/src/docs/print_providers.md This function call retrieves the specific product variants (like colors and sizes) that are available for a given blueprint when fulfilled by a particular print provider. It requires both the blueprint ID and the print provider ID. ```JavaScript get_variants({ blueprintId: "12", printProviderId: "29" }) ``` -------------------------------- ### Getting Print Providers for Blueprint (TypeScript) Source: https://github.com/tsavo/printify-mcp/blob/main/docs/printify-api.ts.md Asynchronously fetches and returns a list of print providers associated with a specific blueprint ID from the Printify API. ```typescript async getPrintProviders(blueprintId: string) ``` -------------------------------- ### Getting Current Shop ID (TypeScript) Source: https://github.com/tsavo/printify-mcp/blob/main/docs/printify-api.ts.md Synchronously returns the ID of the currently selected shop, or null if none is selected. ```typescript getCurrentShopId(): string | null ``` -------------------------------- ### Getting Printify Variants - TypeScript Source: https://github.com/tsavo/printify-mcp/blob/main/docs/printify-api.ts.md Asynchronously retrieves a list of product variants for a specific blueprint and print provider using their respective IDs. Returns a promise that resolves with the variant data. ```typescript async getVariants(blueprintId: string, printProviderId: string) ``` -------------------------------- ### Get Print Providers for Blueprint - Printify - JavaScript Source: https://github.com/tsavo/printify-mcp/blob/main/src/docs/product_creation.md Retrieves the list of print providers capable of fulfilling orders for a specific product blueprint. This step requires the unique ID of the chosen blueprint obtained from the previous step. The response includes the ID and title for each available provider. ```javascript // Get print providers for your selected blueprint get_print_providers_printify({ blueprintId: "12" }) // Replace 12 with your chosen blueprint ID ``` -------------------------------- ### Get Compiled File Path (Windows Cmd) Source: https://github.com/tsavo/printify-mcp/blob/main/README.md Changes the directory to the 'dist' folder and then prints the full absolute path of the 'index.js' file within that directory using Windows command prompt commands. This path is needed for configuring Claude Desktop. ```cmd cd dist echo %CD%\index.js ``` -------------------------------- ### Initializing MCP Server (TypeScript) Source: https://github.com/tsavo/printify-mcp/blob/main/docs/index.ts.md Initializes the Model Context Protocol (MCP) server instance. Sets the server's name and version. This is the first step in setting up the MCP server. ```TypeScript // Create an MCP server const server = new McpServer({ name: "Printify-MCP", version: "1.0.0" }); ``` -------------------------------- ### Overriding Default Parameters for Image Generation - JavaScript Source: https://github.com/tsavo/printify-mcp/blob/main/src/docs/image_generation.md Demonstrates how to override default image generation parameters directly within a tool call (`generate_and_upload_image` is used as an example). Parameters specified in the tool call, such as `model`, `aspectRatio`, `guidanceScale`, and `raw`, will take precedence over the default settings for that specific generation request. ```javascript generate_and_upload_image({ prompt: "A beautiful mountain landscape", fileName: "mountain.png", model: "black-forest-labs/flux-1.1-pro" // Override just for this generation }) ``` ```javascript generate_and_upload_image({ prompt: "A beautiful mountain landscape", fileName: "mountain.png", // Override defaults for this generation only model: "black-forest-labs/flux-1.1-pro", aspectRatio: "4:3", guidanceScale: 8.0, raw: true }) ``` -------------------------------- ### Creating a New Product - TypeScript Source: https://github.com/tsavo/printify-mcp/blob/main/docs/index.ts.md Creates a new product with detailed specifications including title, description, blueprint, print provider, variants, and optional print areas. Uses a complex Zod schema for input validation. ```typescript 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 }) => { // ... } ); ``` -------------------------------- ### Initializing Printify and Replicate API Clients (TypeScript) Source: https://github.com/tsavo/printify-mcp/blob/main/docs/index.ts.md Asynchronously initializes the Printify and Replicate API clients based on environment variables. Checks for `PRINTIFY_API_KEY` and `REPLICATE_API_TOKEN` and logs errors if they are missing. The Printify client is initialized with the API key and optional shop ID, fetching available shops upon successful initialization. ```TypeScript // Auto-initialize the API clients when the server starts (async () => { try { // Initialize Printify API client const printifyApiKey = process.env.PRINTIFY_API_KEY; if (!printifyApiKey) { console.error("PRINTIFY_API_KEY environment variable is not set. The Printify API client will not be initialized."); } else { // Create the client with the API key and shop ID if available printifyClient = new PrintifyAPI(printifyApiKey, process.env.PRINTIFY_SHOP_ID); // Initialize the client and fetch shops const shops = await printifyClient.initialize(); // ... } // Initialize Replicate API client if environment variable is set const replicateApiToken = process.env.REPLICATE_API_TOKEN; if (!replicateApiToken) { console.error("REPLICATE_API_TOKEN environment variable is not set. The Replicate API client will not be initialized."); } else { replicateClient = new ReplicateClient(replicateApiToken); console.log('Replicate API client initialized successfully.'); } } catch (error) { console.error("Error initializing API clients:", error); } })(); ``` -------------------------------- ### Creating a Product with Printify API (JavaScript) Source: https://github.com/tsavo/printify-mcp/blob/main/src/docs/product_creation.md Demonstrates how to create a product using the `create_product` function, providing details like title, description, blueprint ID, print provider ID, variants with pricing, and print areas with image IDs. It uses information gathered from previous steps (1-4). ```javascript // Create the product with all gathered information create_product({ title: "Horizon City Skyline T-Shirt", // Product title description: "Step into the future with our Horizon City Skyline T-Shirt. This premium unisex tee features a stunning futuristic cityscape with neon lights and towering skyscrapers.", // Detailed description // IDs from previous steps blueprintId: 12, // From Step 1 printProviderId: 29, // From Step 2 // Variants from Step 3 with pricing (in cents) variants: [ { variantId: 18100, price: 2499 }, // Black / S for $24.99 { variantId: 18101, price: 2499 }, // Black / M for $24.99 { variantId: 18102, price: 2499 } // Black / L for $24.99 ], // Print areas with image IDs from Step 4 printAreas: { "front": { position: "front", imageId: "680325163d2a2ac0a2d2937c" }, "back": { position: "back", imageId: "680325163d2a2ac0a2d2937d" } } }) ``` -------------------------------- ### Initializing PrintifyAPI Client (TypeScript) Source: https://github.com/tsavo/printify-mcp/blob/main/docs/printify-api.ts.md Asynchronously fetches available shops from the API, stores them, sets a default shop if needed, and creates the SDK client instance. It handles potential API call failures by falling back to mock data. ```typescript async initialize(): Promise ``` -------------------------------- ### Generating AI Images Using Default Settings (JavaScript) Source: https://github.com/tsavo/printify-mcp/blob/main/src/docs/images.md Demonstrates how to generate and upload an image using the `generate_and_upload_image` function when default parameters have been set, requiring only the prompt and file name. ```javascript generate_and_upload_image({ prompt: "A vibrant t-shirt design with abstract geometric patterns", fileName: "geometric-design.png" }) ``` -------------------------------- ### Configure API Keys via .env File Source: https://github.com/tsavo/printify-mcp/blob/main/README.md Shows the structure of the .env file required to configure API keys for Printify, Replicate, and ImgBB. Includes optional settings for a default Printify shop ID. ```dotenv PRINTIFY_API_KEY=your_api_key_here # Optional: Set a default shop ID # PRINTIFY_SHOP_ID=your_shop_id_here # For image generation with Replicate REPLICATE_API_TOKEN=your_replicate_token_here # Required if using the Flux 1.1 Pro Ultra model for image generation IMGBB_API_KEY=your_imgbb_api_key_here ``` -------------------------------- ### Building Printify MCP Docker Image (Bash) Source: https://github.com/tsavo/printify-mcp/blob/main/README.md Builds the Docker image for the Printify MCP server using the Dockerfile in the current directory. Tags the image with the name `tsavo/printify-mcp` and the tag `latest`. ```bash docker build -t tsavo/printify-mcp:latest . ``` -------------------------------- ### Defining 'list-products' Tool (TypeScript) Source: https://github.com/tsavo/printify-mcp/blob/main/docs/index.ts.md Defines the 'list-products' tool using the `server.tool()` method. This tool accepts optional `page` and `limit` parameters, defined using Zod with default values and descriptions. The handler is an asynchronous function that receives these parameters and is expected to list products in the current shop with pagination. ```TypeScript server.tool( "list-products", { page: z.number().optional().default(1).describe("Page number"), limit: z.number().optional().default(10).describe("Number of products per page") }, async ({ page, limit }) => { // ... } ); ``` -------------------------------- ### Setting Environment Variables (Windows Command Prompt) Source: https://github.com/tsavo/printify-mcp/blob/main/README.md Demonstrates how to set the required and optional environment variables for the Printify MCP server using the Windows Command Prompt `set` command. These variables configure API keys and the target shop ID. ```cmd :: Required set PRINTIFY_API_KEY=your_printify_api_key :: Optional set PRINTIFY_SHOP_ID=your_shop_id :: Optional - only for image generation set REPLICATE_API_TOKEN=your_replicate_api_token ``` -------------------------------- ### Initializing ReplicateClient in TypeScript Source: https://github.com/tsavo/printify-mcp/blob/main/docs/replicate-client.ts.md Initializes the Replicate client with the provided API token and creates a temporary directory for downloaded images if it doesn't already exist. ```typescript constructor(apiToken: string) ``` -------------------------------- ### Defining AI Product Description Prompt (TypeScript) Source: https://github.com/tsavo/printify-mcp/blob/main/docs/index.ts.md Registers a prompt named "generate-product-description" with the server. It defines the expected input arguments using Zod schema, including product name, category, optional target audience, and optional comma-separated key features. ```typescript server.prompt( "generate-product-description", { productName: z.string(), category: z.string(), targetAudience: z.string().optional(), keyFeatures: z.string().optional().describe("Comma-separated list of key features") }, (args) => { // ... } ); ``` -------------------------------- ### Create Printify MCP Directory (Bash) Source: https://github.com/tsavo/printify-mcp/blob/main/README.md Creates a new directory named `printify-mcp` and changes the current directory into it. This is the initial step for organizing project files when setting up the application. ```bash mkdir printify-mcp cd printify-mcp ``` -------------------------------- ### Clone Repository (Bash) Source: https://github.com/tsavo/printify-mcp/blob/main/README.md Clones the `printify-mcp` repository from GitHub and changes the current directory into the newly cloned repository folder. This is the initial step for setting up the application using Docker Compose. ```bash git clone https://github.com/tsavo/printify-mcp.git cd printify-mcp ``` -------------------------------- ### Defining 'list-shops' Tool (TypeScript) Source: https://github.com/tsavo/printify-mcp/blob/main/docs/index.ts.md Defines the 'list-shops' tool using the `server.tool()` method. This tool has no input parameters (empty schema `{}`) and its handler is an asynchronous function that is expected to list all available shops in the Printify account. ```TypeScript server.tool( "list-shops", {}, async () => { // ... } ); ``` -------------------------------- ### PrintifyAPI Constructor (TypeScript) Source: https://github.com/tsavo/printify-mcp/blob/main/docs/printify-api.ts.md Initializes the PrintifyAPI class instance with the necessary API token and an optional shop ID. It prepares the client for API interactions. ```typescript constructor(apiToken: string, shopId?: string) ``` -------------------------------- ### Creating Product (TypeScript) Source: https://github.com/tsavo/printify-mcp/blob/main/docs/printify-api.ts.md Asynchronously creates a new product in Printify using the provided product data. It formats the data, handles variants and print areas, and provides enhanced error details. ```typescript async createProduct(productData: any) ``` -------------------------------- ### Following Docker Container Logs - Bash Source: https://github.com/tsavo/printify-mcp/blob/main/README.md Provides the command to view and continuously follow the standard output and error logs for the Printify MCP Docker container in real-time. ```bash docker logs -f printify-mcp ``` -------------------------------- ### Setting Default AI Image Generation Parameters (JavaScript) Source: https://github.com/tsavo/printify-mcp/blob/main/src/docs/images.md Use the `set_default` tool to configure global settings for all future AI image generation requests, including the model, aspect ratio, raw setting, and negative prompt. ```javascript set_default({ option: "model", value: "black-forest-labs/flux-1.1-pro-ultra" }) set_default({ option: "aspectRatio", value: "16:9" }) set_default({ option: "raw", value: true }) set_default({ option: "negativePrompt", value: "low quality, blurry, distorted" }) ``` -------------------------------- ### Uploading Image from URL (JavaScript) Source: https://github.com/tsavo/printify-mcp/blob/main/src/docs/images.md Shows how to upload an image to the system by providing a URL to the image file using the `upload_image` function, specifying the desired file name. ```javascript upload_image({ fileName: "front.png", url: "https://example.com/image.png" }) ``` -------------------------------- ### Clone Printify MCP Repository (Bash) Source: https://github.com/tsavo/printify-mcp/blob/main/README.md Clones the Printify MCP repository from GitHub to the local machine and changes the current directory into the newly cloned repository folder. This is the first step for setting up the project locally without Docker. ```bash git clone https://github.com/tsavo/printify-mcp.git cd printify-mcp ``` -------------------------------- ### Running Printify MCP Docker (.env File) (Bash) Source: https://github.com/tsavo/printify-mcp/blob/main/README.md Runs the Printify MCP Docker container using a local `.env` file for configuration. Mounts the local `.env` file as a read-only volume and the local `temp` directory as a volume inside the container. Sets the container name to `printify-mcp` and runs it interactively. ```bash docker run -it --name printify-mcp \ -v $(pwd)/.env:/app/.env:ro \ -v $(pwd)/temp:/app/temp \ tsavo/printify-mcp:latest ``` -------------------------------- ### Generating and Uploading AI Image (JavaScript) Source: https://github.com/tsavo/printify-mcp/blob/main/src/docs/images.md Illustrates the combined operation of generating an image using AI and immediately uploading it to the system using the `generate_and_upload_image` function, requiring a prompt and file name. ```javascript generate_and_upload_image({ prompt: "blue t-shirt design", fileName: "front.png" }) ``` -------------------------------- ### Viewing Default Image Generation Settings - JavaScript Source: https://github.com/tsavo/printify-mcp/blob/main/src/docs/image_generation.md Demonstrates how to use the `get_defaults` tool to retrieve and display the current default parameters for image generation, including the selected model and all parameter values. ```javascript get_defaults() ``` -------------------------------- ### Defining Product Print Areas with Images (JavaScript) Source: https://github.com/tsavo/printify-mcp/blob/main/src/docs/images.md Illustrates the structure of the `printAreas` object used when creating a product, mapping print area positions (like "front", "back") to the IDs of previously uploaded images. ```javascript { "front": { "position": "front", "imageId": "680325163d2a2ac0a2d2937c" }, "back": { "position": "back", "imageId": "680325163d2a2ac0a2d2938d" } } ``` -------------------------------- ### Pushing Printify MCP Docker Image (Bash) Source: https://github.com/tsavo/printify-mcp/blob/main/README.md Pushes the locally built Docker image tagged `tsavo/printify-mcp:latest` to the configured container registry (e.g., Docker Hub). ```bash docker push tsavo/printify-mcp:latest ``` -------------------------------- ### Publishing a Product - TypeScript Source: https://github.com/tsavo/printify-mcp/blob/main/docs/index.ts.md Publishes a product to external sales channels. Requires the product ID and allows specifying which details (title, description, images, variants, tags) to publish. ```typescript server.tool( "publish-product", { productId: z.string().describe("Product ID"), publishDetails: z.object({ title: z.boolean().optional().default(true).describe("Publish title"), description: z.boolean().optional().default(true).describe("Publish description"), images: z.boolean().optional().default(true).describe("Publish images"), variants: z.boolean().optional().default(true).describe("Publish variants"), tags: z.boolean().optional().default(true).describe("Publish tags") }).optional().describe("Publish details") }, async ({ productId, publishDetails }) => { // ... } ); ``` -------------------------------- ### Running Printify MCP Docker (Env Vars) (Bash) Source: https://github.com/tsavo/printify-mcp/blob/main/README.md Runs the Printify MCP Docker container using environment variables for configuration. Mounts the local `temp` directory as a volume inside the container. Sets the container name to `printify-mcp` and runs it interactively. Optional environment variables for image generation features (`REPLICATE_API_TOKEN`, `IMGBB_API_KEY`) can also be included. ```bash docker run -it --name printify-mcp \ -e PRINTIFY_API_KEY=their_printify_api_key \ -e PRINTIFY_SHOP_ID=their_shop_id_optional \ -v $(pwd)/temp:/app/temp \ tsavo/printify-mcp:latest ``` -------------------------------- ### Run Docker Container with .env Volume (Windows CMD) Source: https://github.com/tsavo/printify-mcp/blob/main/README.md Command to run the Printify MCP Docker container by mounting the local `.env` file as a read-only volume, formatted specifically for Windows Command Prompt using `%cd%`. ```bash docker run -it --name printify-mcp -v %cd%/.env:/app/.env:ro -v %cd%/temp:/app/temp tsavo/printify-mcp:latest ``` -------------------------------- ### Viewing Current AI Image Generation Defaults (JavaScript) Source: https://github.com/tsavo/printify-mcp/blob/main/src/docs/images.md Use the `get_defaults` tool to retrieve and view the currently configured default settings for AI image generation, including the selected model and other parameters. ```javascript get_defaults() ``` -------------------------------- ### Restarting Docker Container with Docker Run - CMD Source: https://github.com/tsavo/printify-mcp/blob/main/README.md Provides the command to restart the Printify MCP Docker container using the docker run command in a Windows Command Prompt environment, mounting environment and temp directories. ```cmd docker run -it --name printify-mcp -v %cd%/.env:/app/.env:ro -v %cd%/temp:/app/temp tsavo/printify-mcp:latest ``` -------------------------------- ### Referencing Documentation Topic (JavaScript) Source: https://github.com/tsavo/printify-mcp/blob/main/src/docs/images.md This snippet shows the syntax used within the documentation to reference a specific topic, in this case, 'image_generation'. It appears to be a function call or similar mechanism for linking documentation sections. ```JavaScript how_to_use({ topic: "image_generation" }) ``` -------------------------------- ### Generating Image with Flux 1.1 Pro Model (JavaScript) Source: https://github.com/tsavo/printify-mcp/blob/main/src/docs/image_generation.md This snippet shows two ways to generate an image using the 'black-forest-labs/flux-1.1-pro' model in JavaScript. It demonstrates setting the model as a default for subsequent generations or overriding the model for a single generation, while also including Pro-specific parameters like `promptUpsampling` and `outputQuality`. ```javascript // Option 1: Set the default model to Pro for all future generations set_default({ option: "model", value: "black-forest-labs/flux-1.1-pro" }) // Then generate with Pro-specific parameters generate_and_upload_image({ prompt: "A beautiful mountain landscape", fileName: "mountain.png", promptUpsampling: true, outputQuality: 95 }) // Option 2: Override the model just for this specific generation generate_and_upload_image({ prompt: "A beautiful mountain landscape", fileName: "mountain.png", model: "black-forest-labs/flux-1.1-pro", // Override default model promptUpsampling: true, outputQuality: 95 }) ``` -------------------------------- ### Restarting Docker Container with Docker Run - PowerShell Source: https://github.com/tsavo/printify-mcp/blob/main/README.md Provides the command to restart the Printify MCP Docker container using the docker run command in a PowerShell environment, mounting environment and temp directories. ```powershell docker run -it --name printify-mcp -v ${PWD}/.env:/app/.env:ro -v ${PWD}/temp:/app/temp tsavo/printify-mcp:latest ``` -------------------------------- ### Run Docker Container with Env Vars (Windows CMD) Source: https://github.com/tsavo/printify-mcp/blob/main/README.md Command to run the Printify MCP Docker container using environment variables passed directly via `-e` flags, specifically formatted for Windows Command Prompt using `^` for line continuation. It includes mounting the `temp` directory. ```bash docker run -it --name printify-mcp ^ -e PRINTIFY_API_KEY=your_printify_api_key ^ -e PRINTIFY_SHOP_ID=your_shop_id_optional ^ -v %cd%/temp:/app/temp ^ tsavo/printify-mcp:latest ``` -------------------------------- ### Logging into Docker Hub (Bash) Source: https://github.com/tsavo/printify-mcp/blob/main/README.md Logs the user into Docker Hub or another configured container registry. Requires user interaction to enter credentials. ```bash docker login ``` -------------------------------- ### Claude Desktop MCP Server Arguments (Bash) Source: https://github.com/tsavo/printify-mcp/blob/main/README.md Arguments string used in Claude Desktop settings to connect to the Printify MCP server running inside a Docker container. Executes the Node.js application within the named `printify-mcp` container. ```bash exec -i printify-mcp node dist/index.js ``` -------------------------------- ### Defining 'switch-shop' Tool (TypeScript) Source: https://github.com/tsavo/printify-mcp/blob/main/docs/index.ts.md Defines the 'switch-shop' tool using the `server.tool()` method. This tool requires a `shopId` parameter, defined using Zod as a string with a description. The handler is an asynchronous function that receives the `shopId` as input and is expected to switch the current shop context. ```TypeScript server.tool( "switch-shop", { shopId: z.string().describe("The ID of the shop to switch to") }, async ({ shopId }) => { // ... } ); ``` -------------------------------- ### Configure Environment Variables (Windows) Source: https://github.com/tsavo/printify-mcp/blob/main/README.md Sets optional environment variables for the Printify MCP server on Windows using the `$env:` syntax. This includes the Printify Shop ID and the Replicate API Token. ```shell $env:PRINTIFY_SHOP_ID = "your_shop_id" # Optional - only for image generation $env:REPLICATE_API_TOKEN = "your_replicate_api_token" ``` -------------------------------- ### Defining AI Image Generation and Upload Tool (TypeScript) Source: https://github.com/tsavo/printify-mcp/blob/main/docs/index.ts.md Registers a tool named "generate-and-upload-image" with the server. It defines the input arguments using Zod schema for image generation parameters like prompt, file name, dimensions, aspect ratio, inference steps, guidance scale, negative prompt, and seed. ```typescript server.tool( "generate-and-upload-image", { prompt: z.string().describe("Text prompt for image generation"), fileName: z.string().describe("File name for the uploaded image"), width: z.number().optional().default(1024).describe("Image width in pixels"), height: z.number().optional().default(1024).describe("Image height in pixels"), aspectRatio: z.string().optional().describe("Aspect ratio (e.g., '16:9', '4:3', '1:1'). If provided, overrides width and height"), numInferenceSteps: z.number().optional().default(25).describe("Number of inference steps"), guidanceScale: z.number().optional().default(7.5).describe("Guidance scale"), negativePrompt: z.string().optional().default("low quality, bad quality, sketches").describe("Negative prompt"), seed: z.number().optional().describe("Random seed for reproducible generation") }, async ({ prompt, fileName, width, height, aspectRatio, numInferenceSteps, guidanceScale, negativePrompt, seed }) => { // ... } ); ```