get_print_providers
Retrieve print providers associated with a specific blueprint ID to streamline product creation and management on Printify's platform. Simplify integration with AI assistants for efficient workflow automation.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| blueprintId | Yes | Blueprint ID |
Implementation Reference
- src/index.ts:492-522 (registration)Registration of the 'get_print_providers' MCP tool, including inline handler function that dynamically imports and calls the service helper, with input schema validation using Zod.server.tool( "get_print_providers", { blueprintId: z.string().describe("Blueprint ID") }, async ({ blueprintId }): Promise<{ content: any[], isError?: boolean }> => { // Import the printify blueprints service const { getPrintProviders } = await import('./services/printify-blueprints.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 getPrintProviders(printifyClient, blueprintId); // Return the result if (result.success) { return result.response as { content: any[], isError?: boolean }; } else { return result.errorResponse as { content: any[], isError: boolean }; } } );
- src/index.ts:494-495 (schema)Input schema for the get_print_providers tool: requires blueprintId as string.{ blueprintId: z.string().describe("Blueprint ID")
- src/index.ts:497-521 (handler)Inline handler function for the MCP tool that executes the tool logic by calling the getPrintProviders helper.async ({ blueprintId }): Promise<{ content: any[], isError?: boolean }> => { // Import the printify blueprints service const { getPrintProviders } = await import('./services/printify-blueprints.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 getPrintProviders(printifyClient, blueprintId); // 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 getPrintProviders that fetches print providers from Printify API for a given blueprint ID and formats the MCP response.export async function getPrintProviders( printifyClient: PrintifyAPI, blueprintId: string ) { try { // Validate client is initialized if (!printifyClient) { throw new Error('Printify API client is not initialized. The PRINTIFY_API_KEY environment variable may not be set.'); } // Get print providers const printProviders = await printifyClient.getPrintProviders(blueprintId); return { success: true, printProviders, response: { content: [{ type: "text", text: `Print providers for blueprint ID ${blueprintId}:\n\n${JSON.stringify(printProviders, null, 2)}` }] } }; } catch (error: any) { console.error('Error getting print providers:', error); return { success: false, error, errorResponse: formatErrorResponse( error, 'Get Print Providers', { BlueprintId: blueprintId }, [ 'Check that the blueprint ID is valid', 'Check that your Printify API key is valid', 'Ensure your Printify account is properly connected' ] ) }; } }