get_authentications_by_user_id
Fetch paginated authentication records for a user, optionally filtered by provider.
Instructions
Get the authentications of an user
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| user_id | Yes | ID of the parent resource | |
| cursor | No | Cursor for fetching the next page of results | |
| per_page | No | Number of results per page (default: 25) | |
| provider | No | Filter results on provider |
Implementation Reference
- src/tools/authentications.ts:30-46 (handler)The async handler function for 'get_authentications_by_user_id'. It calls apiList on `/users/${user_id}/authentications`, logs the response, formats the result with formatList, and appends the next cursor if paginated.
async ({ user_id, cursor, per_page, provider }) => { try { const result = await apiList<EduframeRecord>(`/users/${user_id}/authentications`, { cursor, per_page, provider, }); void logResponse("get_authentications_by_user_id", { user_id, cursor, per_page, provider }, result); const toolResult = formatList(result.records, "authentications"); if (result.nextCursor) { toolResult.content.push({ type: "text", text: `\nNext page cursor: ${result.nextCursor}` }); } return toolResult; } catch (error) { return formatError(error); } }, - src/tools/authentications.ts:17-29 (schema)Input schema definition for 'get_authentications_by_user_id' including user_id (required), cursor, per_page, and provider (optional) parameters with Zod validation.
{ description: "Get the authentications of an user", annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true }, inputSchema: { user_id: z.number().int().positive().describe("ID of the parent resource"), 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)"), provider: z .enum(["azure_active_directory", "eduframe", "openid_connect", "surf_conext"]) .optional() .describe("Filter results on provider"), }, }, - src/tools/authentications.ts:15-47 (registration)Registration of the tool via server.registerTool with name 'get_authentications_by_user_id', its schema, annotations, and handler.
server.registerTool( "get_authentications_by_user_id", { description: "Get the authentications of an user", annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true }, inputSchema: { user_id: z.number().int().positive().describe("ID of the parent resource"), 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)"), provider: z .enum(["azure_active_directory", "eduframe", "openid_connect", "surf_conext"]) .optional() .describe("Filter results on provider"), }, }, async ({ user_id, cursor, per_page, provider }) => { try { const result = await apiList<EduframeRecord>(`/users/${user_id}/authentications`, { cursor, per_page, provider, }); void logResponse("get_authentications_by_user_id", { user_id, cursor, per_page, provider }, result); const toolResult = formatList(result.records, "authentications"); 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)The apiList helper function that performs the actual GET request to the Eduframe REST API with cursor-based pagination support.
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 }; }