get_material_groups
Fetch all material group records with pagination support using cursor and per_page parameters.
Instructions
Get all material group records
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cursor | No | Cursor for fetching the next page of results | |
| per_page | No | Number of results per page (default: 25) |
Implementation Reference
- src/tools/material_groups.ts:26-38 (handler)The handler function for the 'get_material_groups' tool. It calls apiList to fetch material groups, formats the result, and optionally appends a next-cursor message.
async ({ cursor, per_page }) => { try { const result = await apiList<EduframeRecord>("/material_groups", { cursor, per_page }); void logResponse("get_material_groups", { cursor, per_page }, result); const toolResult = formatList(result.records, "material groups"); if (result.nextCursor) { toolResult.content.push({ type: "text", text: `\nNext page cursor: ${result.nextCursor}` }); } return toolResult; } catch (error) { return formatError(error); } }, - src/tools/material_groups.ts:22-24 (schema)Input schema for get_material_groups: optional cursor (string) and per_page (positive integer).
cursor: z.string().optional().describe("Cursor for fetching the next page of results"), per_page: z.number().int().positive().optional().describe("Number of results per page (default: 25)"), }, - src/tools/material_groups.ts:15-115 (registration)The registerMaterialGroupTools function registers the 'get_material_groups' tool (and related material group tools) on the MCP server.
export function registerMaterialGroupTools(server: McpServer): void { server.registerTool( "get_material_groups", { description: "Get all material group records", annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true }, inputSchema: { cursor: z.string().optional().describe("Cursor for fetching the next page of results"), per_page: z.number().int().positive().optional().describe("Number of results per page (default: 25)"), }, }, async ({ cursor, per_page }) => { try { const result = await apiList<EduframeRecord>("/material_groups", { cursor, per_page }); void logResponse("get_material_groups", { cursor, per_page }, result); const toolResult = formatList(result.records, "material groups"); if (result.nextCursor) { toolResult.content.push({ type: "text", text: `\nNext page cursor: ${result.nextCursor}` }); } return toolResult; } catch (error) { return formatError(error); } }, ); server.registerTool( "get_material_group", { description: "Get a material group record", annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true }, inputSchema: { id: z.number().int().positive().describe("ID of the material group to retrieve") }, }, async ({ id }) => { try { const record = await apiGet<EduframeRecord>(`/material_groups/${id}`); void logResponse("get_material_group", { id }, record); return formatShow(record, "material group"); } catch (error) { return formatError(error); } }, ); server.registerTool( "create_material_group", { description: "Create a material group.", annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false }, inputSchema: { name: z.string().describe("Name of the material group where the course is held.") }, }, async (body) => { try { const record = await apiPost<EduframeRecord>("/material_groups", body); void logResponse("create_material_group", body, record); return formatCreate(record, "material group"); } catch (error) { return formatError(error); } }, ); 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); } }, ); server.registerTool( "delete_material_group", { description: "Delete a material group.", annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: true }, inputSchema: { id: z.number().int().positive().describe("ID of the material group to delete") }, }, async ({ id }) => { try { const record = await apiDelete<EduframeRecord>(`/material_groups/${id}`); void logResponse("delete_material_group", { id }, record); return formatDelete(record, "material group"); } catch (error) { return formatError(error); } }, ); } - src/tools/index.ts:128-132 (registration)registerAllTools iterates over all tool registrations (including registerMaterialGroupTools) and calls each with the MCP server.
export function registerAllTools(server: McpServer): void { for (const register of tools) { register(server); } } - src/tools/material_groups.ts:4-12 (helper)Imports for helper utilities: apiList, formatters (formatList, formatError), response logger, and the EduframeRecord type.
import { formatCreate, formatDelete, formatError, formatList, formatShow, formatUpdate, type EduframeRecord, } from "../formatters";