get_material_group
Retrieve a material group record by specifying its unique ID. Returns the group details from the Eduframe system.
Instructions
Get a material group record
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | ID of the material group to retrieve |
Implementation Reference
- src/tools/material_groups.ts:41-57 (handler)The handler for the 'get_material_group' tool. Registered via server.registerTool('get_material_group', ...). It accepts an id parameter, calls apiGet to fetch the material group from /material_groups/{id}, logs the response, and formats the result using formatShow.
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); } }, ); - src/tools/material_groups.ts:43-46 (schema)Input schema and metadata for the 'get_material_group' tool. The schema defines a single required parameter 'id' (positive integer) and sets annotations: readOnlyHint=true, destructiveHint=false, idempotentHint=true.
{ 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") }, - src/tools/index.ts:128-132 (registration)The registerAllTools function iterates over all tool registration functions, including registerMaterialGroupTools which registers the 'get_material_group' tool (along with other material group tools).
export function registerAllTools(server: McpServer): void { for (const register of tools) { register(server); } } - src/api.ts:145-229 (helper)The apiGet helper function used by the handler. It performs a GET request to the specified API path, handles response parsing and error checking.
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); } /** * Perform a POST request to create a resource. * * @param path - API path, e.g. "/leads" * @param body - Request body */ 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); } /** * Perform a PUT request to update a resource. * * @param path - API path, e.g. "/leads/1" * @param body - Request 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); } /** * Perform a PATCH request to partially update a resource. * * @param path - API path, e.g. "/leads/1" * @param body - Request body */ 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); } /** * Perform a DELETE request to remove a resource. * * @param path - API path, e.g. "/leads/1" */ export async function apiDelete<T>(path: string): Promise<T> { const { token } = getConfig(); const url = buildUrl(path); const response = await fetch(url.toString(), { method: "DELETE", headers: buildHeaders(token), }); return handleResponse<T>(response); }