cancel_enrollment
Cancel an enrollment by providing its ID. Use this tool to remove or invalidate a student's enrollment record.
Instructions
Cancel an enrollment
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | ID of the enrollment |
Implementation Reference
- src/tools/enrollments.ts:98-114 (handler)The handler function for 'cancel_enrollment' tool, registered via server.registerTool. It takes an enrollment ID, calls apiPut to POST to /enrollments/{id}/cancel, logs the response, and returns the formatted enrollment record.
server.registerTool( "cancel_enrollment", { description: "Cancel an enrollment", annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true }, inputSchema: { id: z.number().int().positive().describe("ID of the enrollment") }, }, async ({ id }) => { try { const record = await apiPut<EduframeRecord>(`/enrollments/${id}/cancel`, {}); void logResponse("cancel_enrollment", { id }, record); return formatShow(record, "enrollment"); } catch (error) { return formatError(error); } }, ); - src/tools/enrollments.ts:100-103 (schema)Input schema for 'cancel_enrollment' — requires an 'id' field (positive integer) describing the enrollment ID.
{ description: "Cancel an enrollment", annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true }, inputSchema: { id: z.number().int().positive().describe("ID of the enrollment") }, - src/tools/enrollments.ts:98-115 (registration)Tool registered via server.registerTool with name 'cancel_enrollment' inside registerEnrollmentTools(). The registration function is exported from enrollments.ts, imported in src/tools/index.ts, and called from registerAllTools().
server.registerTool( "cancel_enrollment", { description: "Cancel an enrollment", annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true }, inputSchema: { id: z.number().int().positive().describe("ID of the enrollment") }, }, async ({ id }) => { try { const record = await apiPut<EduframeRecord>(`/enrollments/${id}/cancel`, {}); void logResponse("cancel_enrollment", { id }, record); return formatShow(record, "enrollment"); } catch (error) { return formatError(error); } }, ); } - src/api.ts:182-193 (helper)The apiPut helper used by the handler — performs an HTTP PUT request to the given API path with a JSON body.
export async function apiPut<T>(path: string, body: unknown): Promise<T> { const { token } = getConfig(); const url = buildUrl(path); const response = await fetch(url.toString(), { method: "PUT", headers: buildHeaders(token), body: JSON.stringify(body), }); return handleResponse<T>(response); }