get_catalog_variants
Retrieve catalog variants with filters for pagination, publication status, product, and variantable type.
Instructions
Get all catalog variants
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cursor | No | Cursor for fetching the next page of results | |
| per_page | No | Number of results per page (default: 25) | |
| published_public | No | Only show published variants and planned_courses that are either planned or in progress | |
| product_id | No | Filter results on product_id | |
| variantable_id | No | Filter results on variantable_id | |
| variantable_type | No | Filter results on variantable_type |
Implementation Reference
- src/tools/catalog_variants.ts:28-51 (handler)The handler function for the 'get_catalog_variants' tool. Calls apiList to fetch catalog variants with optional filters (cursor, per_page, published_public, product_id, variantable_id, variantable_type), logs the response, formats the results using formatList, and appends a next-page cursor if present.
async ({ cursor, per_page, published_public, product_id, variantable_id, variantable_type }) => { try { const result = await apiList<EduframeRecord>("/catalog/variants", { cursor, per_page, published_public, product_id, variantable_id, variantable_type, }); void logResponse( "get_catalog_variants", { cursor, per_page, published_public, product_id, variantable_id, variantable_type }, result, ); const toolResult = formatList(result.records, "catalog variants"); if (result.nextCursor) { toolResult.content.push({ type: "text", text: `\nNext page cursor: ${result.nextCursor}` }); } return toolResult; } catch (error) { return formatError(error); } }, - src/tools/catalog_variants.ts:10-26 (schema)The input schema definition for the 'get_catalog_variants' tool, including optional filters for cursor, per_page, published_public, product_id, variantable_id, and variantable_type.
{ description: "Get all catalog variants", annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true }, inputSchema: { cursor: z.string().optional().describe("Cursor for fetching the next page of results"), per_page: z.number().int().positive().optional().describe("Number of results per page (default: 25)"), published_public: z .enum(["published_public"]) .optional() .describe("Only show published variants and planned_courses that are either planned or in progress"), product_id: z.number().int().optional().describe("Filter results on product_id"), variantable_id: z.number().int().optional().describe("Filter results on variantable_id"), variantable_type: z .enum(["planned_course", "program_edition"]) .optional() .describe("Filter results on variantable_type"), }, - src/tools/catalog_variants.ts:8-52 (registration)Registration of the 'get_catalog_variants' tool using server.registerTool within the registerCatalogVariantTools function.
server.registerTool( "get_catalog_variants", { description: "Get all catalog variants", annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true }, inputSchema: { cursor: z.string().optional().describe("Cursor for fetching the next page of results"), per_page: z.number().int().positive().optional().describe("Number of results per page (default: 25)"), published_public: z .enum(["published_public"]) .optional() .describe("Only show published variants and planned_courses that are either planned or in progress"), product_id: z.number().int().optional().describe("Filter results on product_id"), variantable_id: z.number().int().optional().describe("Filter results on variantable_id"), variantable_type: z .enum(["planned_course", "program_edition"]) .optional() .describe("Filter results on variantable_type"), }, }, async ({ cursor, per_page, published_public, product_id, variantable_id, variantable_type }) => { try { const result = await apiList<EduframeRecord>("/catalog/variants", { cursor, per_page, published_public, product_id, variantable_id, variantable_type, }); void logResponse( "get_catalog_variants", { cursor, per_page, published_public, product_id, variantable_id, variantable_type }, result, ); const toolResult = formatList(result.records, "catalog variants"); if (result.nextCursor) { toolResult.content.push({ type: "text", text: `\nNext page cursor: ${result.nextCursor}` }); } return toolResult; } catch (error) { return formatError(error); } }, ); - src/tools/catalog_variants.ts:30-37 (helper)Calls apiList helper to fetch catalog variants from the /catalog/variants endpoint with the provided filter parameters.
const result = await apiList<EduframeRecord>("/catalog/variants", { cursor, per_page, published_public, product_id, variantable_id, variantable_type, });