get_blueprints
Retrieve a paginated list of available print-on-demand blueprints. Use page and limit parameters to control the number of results per request.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "get_blueprints"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| page | No | Page number | |
| limit | No | Number of blueprints per page |
Implementation Reference
- src/index.ts:424-456 (registration)The MCP tool registration for 'get_blueprints' in the main server file. It defines schema (page, limit), imports the service, validates client, and delegates to the handler.
// Get blueprints tool 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 }): Promise<{ content: any[], isError?: boolean }> => { // Import the printify blueprints service const { getBlueprints } = 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 getBlueprints(printifyClient, { page, limit }); // Return the result if (result.success) { return result.response as { content: any[], isError?: boolean }; } else { return result.errorResponse as { content: any[], isError: boolean }; } } ); - The handler function that contains the actual tool logic. Calls printifyClient.getBlueprints() and formats the result as a text response.
export async function getBlueprints( printifyClient: PrintifyAPI, options: { page?: number; limit?: number; } = {} ) { 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.'); } // Set default options const page = options.page || 1; const limit = options.limit || 10; // Get blueprints const blueprints = await printifyClient.getBlueprints(); return { success: true, blueprints, response: { content: [{ type: "text", text: `Available blueprints (page ${page}, limit ${limit}):\n\n${JSON.stringify(blueprints, null, 2)}` }] } }; } catch (error: any) { console.error('Error getting blueprints:', error); return { success: false, error, errorResponse: formatErrorResponse( error, 'Get Blueprints', { Page: options.page, Limit: options.limit }, [ 'Check that your Printify API key is valid', 'Ensure your Printify account is properly connected' ] ) }; } } - src/printify-api.ts:404-413 (helper)The API client method on the PrintifyAPI class that calls the Printify SDK's catalog.listBlueprints() to fetch blueprints from the Printify API.
// Get catalog blueprints async getBlueprints() { try { // Use the catalog.listBlueprints method return await this.client.catalog.listBlueprints(); } catch (error) { console.error('Error fetching blueprints:', error); throw error; } } - src/index.ts:425-456 (schema)The input schema for the tool, defined using Zod with optional page (default 1) and limit (default 10) parameters.
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 }): Promise<{ content: any[], isError?: boolean }> => { // Import the printify blueprints service const { getBlueprints } = 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 getBlueprints(printifyClient, { page, limit }); // Return the result if (result.success) { return result.response as { content: any[], isError?: boolean }; } else { return result.errorResponse as { content: any[], isError: boolean }; } } );