create_teacher
Assigns teacher role to a user by providing their user ID. Enables managing teacher status in Eduframe.
Instructions
Create a new teacher
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| user_id | No | The id of the user to make a teacher |
Implementation Reference
- src/tools/teachers.ts:61-70 (handler)The actual handler/executor for the 'create_teacher' tool. Receives a body object (with optional user_id), calls apiPost to /teachers, logs the response, and formats the result.
async (body) => { try { const record = await apiPost<EduframeRecord>("/teachers", body); void logResponse("create_teacher", body, record); return formatCreate(record, "teacher"); } catch (error) { return formatError(error); } }, ); - src/tools/teachers.ts:56-60 (schema)The schema/input definitions for the 'create_teacher' tool. Contains description, annotations (non-readonly, non-destructive, non-idempotent), and inputSchema with an optional user_id.
{ description: "Create a new teacher", annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false }, inputSchema: { user_id: z.number().int().optional().describe("The id of the user to make a teacher") }, }, - src/tools/teachers.ts:54-70 (registration)Registration of the 'create_teacher' tool on the MCP server using server.registerTool() inside registerTeacherTools.
server.registerTool( "create_teacher", { description: "Create a new teacher", annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false }, inputSchema: { user_id: z.number().int().optional().describe("The id of the user to make a teacher") }, }, async (body) => { try { const record = await apiPost<EduframeRecord>("/teachers", body); void logResponse("create_teacher", body, record); return formatCreate(record, "teacher"); } catch (error) { return formatError(error); } }, ); - src/api.ts:163-174 (helper)The apiPost helper function used by the create_teacher handler to POST to the Eduframe API at /teachers.
export async function apiPost<T>(path: string, body: unknown): Promise<T> { const { token } = getConfig(); const url = buildUrl(path); const response = await fetch(url.toString(), { method: "POST", headers: buildHeaders(token), body: JSON.stringify(body), }); return handleResponse<T>(response); } - src/formatters.ts:85-94 (helper)The formatCreate helper used to format the successful creation response.
export function formatCreate(record: EduframeRecord, resourceName: string): CallToolResult { return { content: [ { type: "text", text: `Successfully created ${resourceName}:\n\n${formatJSON(record)}${RESPONSE_LOG_HINT}`, }, ], }; }