get_course_variant
Retrieve a course variant record by providing its ID. Access detailed variant data from the Eduframe system.
Instructions
Get a course variant record
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | ID of the course variant to retrieve |
Implementation Reference
- src/tools/course_variants.ts:40-48 (handler)Handler function for the 'get_course_variant' tool. Calls GET /course_variants/:id via apiGet, logs the response, and formats the result using formatShow.
async ({ id }) => { try { const record = await apiGet<EduframeRecord>(`/course_variants/${id}`); void logResponse("get_course_variant", { id }, record); return formatShow(record, "course variant"); } catch (error) { return formatError(error); } }, - src/tools/course_variants.ts:38-38 (schema)Input schema for get_course_variant: requires a positive integer id parameter.
inputSchema: { id: z.number().int().positive().describe("ID of the course variant to retrieve") }, - src/tools/course_variants.ts:33-49 (registration)Registration of the 'get_course_variant' tool via McpServer.registerTool, with schema and handler.
server.registerTool( "get_course_variant", { description: "Get a course variant record", annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true }, inputSchema: { id: z.number().int().positive().describe("ID of the course variant to retrieve") }, }, async ({ id }) => { try { const record = await apiGet<EduframeRecord>(`/course_variants/${id}`); void logResponse("get_course_variant", { id }, record); return formatShow(record, "course variant"); } catch (error) { return formatError(error); } }, ); - src/api.ts:145-155 (helper)Helper function apiGet used by the handler to perform a GET request to /course_variants/:id.
export async function apiGet<T>(path: string, query?: Record<string, QueryValue>): Promise<T> { const { token } = getConfig(); const url = buildUrl(path, query); const response = await fetch(url.toString(), { method: "GET", headers: buildHeaders(token), }); return handleResponse<T>(response); } - src/formatters.ts:68-77 (helper)Helper function formatShow used to format the course variant record as a human-readable text response.
export function formatShow(record: EduframeRecord, resourceName: string): CallToolResult { return { content: [ { type: "text", text: `${resourceName}:\n\n${formatJSON(record)}${RESPONSE_LOG_HINT}`, }, ], }; }