update_teacher_role
Update a teacher role by specifying its ID and new name.
Instructions
Update a teacher role.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | ID of the teacher role to update | |
| name | Yes | The name of the teacher role. |
Implementation Reference
- src/tools/teacher_roles.ts:77-96 (handler)Handler: Registers the 'update_teacher_role' MCP tool. Uses apiPatch to send a PATCH request to /teacher_roles/:id with the id and name fields, then formats the response.
server.registerTool( "update_teacher_role", { description: "Update a teacher role.", annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true }, inputSchema: { id: z.number().int().positive().describe("ID of the teacher role to update"), name: z.string().describe("The name of the teacher role."), }, }, async ({ id, ...body }) => { try { const record = await apiPatch<EduframeRecord>(`/teacher_roles/${id}`, body); void logResponse("update_teacher_role", { id, ...body }, record); return formatUpdate(record, "teacher role"); } catch (error) { return formatError(error); } }, ); - src/tools/teacher_roles.ts:82-85 (schema)Input schema: requires 'id' (positive int) and 'name' (string).
inputSchema: { id: z.number().int().positive().describe("ID of the teacher role to update"), name: z.string().describe("The name of the teacher role."), }, - src/tools/teacher_roles.ts:77-96 (registration)Tool registration: called from registerTeacherRoleTools() in teacher_roles.ts, which is invoked via registerAllTools() in tools/index.ts.
server.registerTool( "update_teacher_role", { description: "Update a teacher role.", annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true }, inputSchema: { id: z.number().int().positive().describe("ID of the teacher role to update"), name: z.string().describe("The name of the teacher role."), }, }, async ({ id, ...body }) => { try { const record = await apiPatch<EduframeRecord>(`/teacher_roles/${id}`, body); void logResponse("update_teacher_role", { id, ...body }, record); return formatUpdate(record, "teacher role"); } catch (error) { return formatError(error); } }, ); - src/api.ts:201-212 (helper)Helper: apiPatch sends a PATCH request used by the update_teacher_role handler.
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)Helper: formatUpdate creates a success message for the updated teacher role.
export function formatUpdate(record: EduframeRecord, resourceName: string): CallToolResult { return { content: [ { type: "text", text: `Successfully updated ${resourceName}:\n\n${formatJSON(record)}${RESPONSE_LOG_HINT}`, }, ], }; }