get_affiliations
Fetch affiliations from Eduframe, filtered by user ID or account ID, with pagination support.
Instructions
Get all affiliations
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) | |
| user_id | No | Filter results on user_id | |
| account_id | No | Filter results on account_id |
Implementation Reference
- src/tools/affiliations.ts:20-32 (handler)Handler function for the get_affiliations tool. Makes a GET request to /affiliations with optional cursor, per_page, user_id, and account_id parameters, formats the list response, and appends a next-cursor hint if pagination is available.
async ({ cursor, per_page, user_id, account_id }) => { try { const result = await apiList<EduframeRecord>("/affiliations", { cursor, per_page, user_id, account_id }); void logResponse("get_affiliations", { cursor, per_page, user_id, account_id }, result); const toolResult = formatList(result.records, "affiliations"); if (result.nextCursor) { toolResult.content.push({ type: "text", text: `\nNext page cursor: ${result.nextCursor}` }); } return toolResult; } catch (error) { return formatError(error); } }, - src/tools/affiliations.ts:10-18 (schema)Schema and metadata for the get_affiliations tool. Defines read-only, non-destructive, idempotent annotations and optional input parameters: cursor, per_page, user_id, account_id.
{ description: "Get all affiliations", 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)"), user_id: z.number().int().optional().describe("Filter results on user_id"), account_id: z.number().int().optional().describe("Filter results on account_id"), }, - src/tools/affiliations.ts:8-33 (registration)Registration of get_affiliations tool on the MCP server via server.registerTool() inside registerAffiliationTools().
server.registerTool( "get_affiliations", { description: "Get all affiliations", 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)"), user_id: z.number().int().optional().describe("Filter results on user_id"), account_id: z.number().int().optional().describe("Filter results on account_id"), }, }, async ({ cursor, per_page, user_id, account_id }) => { try { const result = await apiList<EduframeRecord>("/affiliations", { cursor, per_page, user_id, account_id }); void logResponse("get_affiliations", { cursor, per_page, user_id, account_id }, result); const toolResult = formatList(result.records, "affiliations"); if (result.nextCursor) { toolResult.content.push({ type: "text", text: `\nNext page cursor: ${result.nextCursor}` }); } return toolResult; } catch (error) { return formatError(error); } }, ); - src/api.ts:122-137 (helper)Helper function used by the handler to perform a paginated GET list request against the Eduframe API. Returns typed records plus a nextCursor for cursor-based pagination.
export async function apiList<T>(path: string, query?: Record<string, QueryValue>): Promise<ListResult<T>> { const { token } = getConfig(); const url = buildUrl(path, query); const response = await fetch(url.toString(), { method: "GET", headers: buildHeaders(token), }); await checkResponse(response); const records = (await response.json()) as T[]; const nextCursor = parseNextCursor(response.headers.get("Link")); return { records, nextCursor }; }