update_catalog_variant
Update a catalog variant by providing its ID. Optionally set publication status and update edition description sections.
Instructions
Update a catalog variant
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | ID of the catalog variant to update | |
| is_published | No | Boolean showing if the variant is published or not. | |
| edition_description_section_contents_attributes | No | Array of edition description section contents to update.   |
Implementation Reference
- src/tools/catalog_variants.ts:96-105 (handler)The handler function for 'update_catalog_variant'. It destructures id from the input, passes the remaining body to apiPatch at /catalog/variants/{id}, logs the response, and returns a formatted update result.
async ({ id, ...body }) => { try { const record = await apiPatch<EduframeRecord>(`/catalog/variants/${id}`, body); void logResponse("update_catalog_variant", { id, ...body }, record); return formatUpdate(record, "catalog variant"); } catch (error) { return formatError(error); } }, ); - src/tools/catalog_variants.ts:77-94 (schema)The input schema for 'update_catalog_variant' defining parameters: id (required, positive int), is_published (optional boolean), edition_description_section_contents_attributes (optional array of objects with content and edition_description_section_id).
inputSchema: { id: z.number().int().positive().describe("ID of the catalog variant to update"), is_published: z.boolean().optional().describe("Boolean showing if the variant is published or not."), edition_description_section_contents_attributes: z .array( z.object({ content: z.string().describe("The content of the edition description section."), edition_description_section_id: z .number() .int() .describe("Identifier of the edition description section."), }), ) .optional() .describe( "Array of edition description section contents to update.\n\n\n\n", ), }, - src/tools/catalog_variants.ts:72-105 (registration)The tool registration call for 'update_catalog_variant' via server.registerTool(). The function registerCatalogVariantTools (exported from this file) is imported and invoked in src/tools/index.ts (line 70) as part of registerAllTools.
server.registerTool( "update_catalog_variant", { description: "Update a catalog variant", annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true }, inputSchema: { id: z.number().int().positive().describe("ID of the catalog variant to update"), is_published: z.boolean().optional().describe("Boolean showing if the variant is published or not."), edition_description_section_contents_attributes: z .array( z.object({ content: z.string().describe("The content of the edition description section."), edition_description_section_id: z .number() .int() .describe("Identifier of the edition description section."), }), ) .optional() .describe( "Array of edition description section contents to update.\n\n\n\n", ), }, }, async ({ id, ...body }) => { try { const record = await apiPatch<EduframeRecord>(`/catalog/variants/${id}`, body); void logResponse("update_catalog_variant", { id, ...body }, record); return formatUpdate(record, "catalog variant"); } catch (error) { return formatError(error); } }, ); - src/api.ts:201-212 (helper)The apiPatch helper function used by the handler to send a PATCH request to /catalog/variants/{id}. It handles authentication via API token and JSON serialization of the request body.
export async function apiPatch<T>(path: string, body: unknown): Promise<T> { const { token } = getConfig(); const url = buildUrl(path); const response = await fetch(url.toString(), { method: "PATCH", headers: buildHeaders(token), body: JSON.stringify(body), }); return handleResponse<T>(response); } - src/formatters.ts:102-111 (helper)The formatUpdate helper function used by the handler to format the updated catalog variant record into a readable response string.
export function formatUpdate(record: EduframeRecord, resourceName: string): CallToolResult { return { content: [ { type: "text", text: `Successfully updated ${resourceName}:\n\n${formatJSON(record)}${RESPONSE_LOG_HINT}`, }, ], }; }