update_material_group
Update an existing material group by specifying its ID and optionally providing a new name.
Instructions
Update a material group.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | ID of the material group to update | |
| name | No | Name of the material group where the course is held. |
Implementation Reference
- src/tools/material_groups.ts:77-96 (handler)Handler for the 'update_material_group' tool. Receives an object with `id` (required) and optional `name`, destructures `id` from the rest of the body, calls `apiPatch` on `/material_groups/${id}`, logs the response, and returns a formatted update result.
server.registerTool( "update_material_group", { description: "Update a material group.", annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true }, inputSchema: { id: z.number().int().positive().describe("ID of the material group to update"), name: z.string().optional().describe("Name of the material group where the course is held."), }, }, async ({ id, ...body }) => { try { const record = await apiPatch<EduframeRecord>(`/material_groups/${id}`, body); void logResponse("update_material_group", { id, ...body }, record); return formatUpdate(record, "material group"); } catch (error) { return formatError(error); } }, ); - src/tools/material_groups.ts:82-85 (schema)Input schema for the 'update_material_group' tool. Defines `id` (required positive integer) and `name` (optional string) using Zod validation.
inputSchema: { id: z.number().int().positive().describe("ID of the material group to update"), name: z.string().optional().describe("Name of the material group where the course is held."), }, - src/tools/material_groups.ts:77-96 (registration)Registration of 'update_material_group' via `server.registerTool()` inside `registerMaterialGroupTools()`, with description and annotations (non-destructive, idempotent).
server.registerTool( "update_material_group", { description: "Update a material group.", annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true }, inputSchema: { id: z.number().int().positive().describe("ID of the material group to update"), name: z.string().optional().describe("Name of the material group where the course is held."), }, }, async ({ id, ...body }) => { try { const record = await apiPatch<EduframeRecord>(`/material_groups/${id}`, body); void logResponse("update_material_group", { id, ...body }, record); return formatUpdate(record, "material group"); } 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 the Eduframe API.
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 that formats the API response into a human-readable tool result.
export function formatUpdate(record: EduframeRecord, resourceName: string): CallToolResult { return { content: [ { type: "text", text: `Successfully updated ${resourceName}:\n\n${formatJSON(record)}${RESPONSE_LOG_HINT}`, }, ], }; }