get_payment_options
Retrieve all payment option records from Eduframe. Supports pagination with cursor and per_page parameters.
Instructions
Get all payment option 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/payment_options.ts:18-30 (handler)The async handler function that executes the tool logic. It calls apiList('/payment_options') with cursor and per_page parameters, logs the response, formats the result using formatList, and appends a nextCursor link if pagination is available.
async ({ cursor, per_page }) => { try { const result = await apiList<EduframeRecord>("/payment_options", { cursor, per_page }); void logResponse("get_payment_options", { cursor, per_page }, result); const toolResult = formatList(result.records, "payment options"); if (result.nextCursor) { toolResult.content.push({ type: "text", text: `\nNext page cursor: ${result.nextCursor}` }); } return toolResult; } catch (error) { return formatError(error); } }, - src/tools/payment_options.ts:10-16 (schema)Input schema for get_payment_options: optional cursor string and optional per_page positive integer.
{ description: "Get all payment option 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)"), }, - src/tools/payment_options.ts:7-31 (registration)Registration of the tool via server.registerTool with name 'get_payment_options', description, annotations, input schema, and handler function.
export function registerPaymentOptionTools(server: McpServer): void { server.registerTool( "get_payment_options", { description: "Get all payment option 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>("/payment_options", { cursor, per_page }); void logResponse("get_payment_options", { cursor, per_page }, result); const toolResult = formatList(result.records, "payment options"); 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 used by the handler to perform a GET request to '/payment_options' 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 }; } - src/formatters.ts:40-60 (helper)The formatList helper function used to format the list of payment option records into a human-readable text response.
export function formatList(records: EduframeRecord[], resourceName: string): CallToolResult { if (records.length === 0) { return { content: [ { type: "text", text: `No ${resourceName} found.`, }, ], }; } return { content: [ { type: "text", text: `Found ${records.length} ${resourceName}:\n\n${formatJSON(records)}${RESPONSE_LOG_HINT}`, }, ], }; }