get_option_of_custom_field
Fetch a custom field option by its ID for a given field slug and parent object type.
Instructions
Get an option of a custom field
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| object_type | Yes | ID of the parent resource | |
| field_slug | Yes | ID of the parent resource | |
| id | Yes | ID of the custom field option to retrieve |
Implementation Reference
- src/tools/custom_field_options.ts:49-57 (handler)Handler function for 'get_option_of_custom_field' tool. Calls apiGet to fetch a single custom field option from /custom/{object_type}/fields/{field_slug}/options/{id}, then formats the result with formatShow.
async ({ object_type, field_slug, id }) => { try { const record = await apiGet<EduframeRecord>(`/custom/${object_type}/fields/${field_slug}/options/${option_id}`); void logResponse("get_option_of_custom_field", { object_type, field_slug, id }, record); return formatShow(record, "custom field option"); } catch (error) { return formatError(error); } }, - Registration and schema definition for 'get_option_of_custom_field'. Registers the tool with input schema requiring object_type (number), field_slug (number), and id (number).
server.registerTool( "get_option_of_custom_field", { description: "Get an option of a custom field", annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true }, inputSchema: { object_type: z.number().int().positive().describe("ID of the parent resource"), field_slug: z.number().int().positive().describe("ID of the parent resource"), id: z.number().int().positive().describe("ID of the custom field option to retrieve"), }, - src/tools/custom_field_options.ts:38-58 (registration)Tool registration via server.registerTool('get_option_of_custom_field', ...) inside registerCustomFieldOptionTools function.
server.registerTool( "get_option_of_custom_field", { description: "Get an option of a custom field", annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true }, inputSchema: { object_type: z.number().int().positive().describe("ID of the parent resource"), field_slug: z.number().int().positive().describe("ID of the parent resource"), id: z.number().int().positive().describe("ID of the custom field option to retrieve"), }, }, async ({ object_type, field_slug, id }) => { try { const record = await apiGet<EduframeRecord>(`/custom/${object_type}/fields/${field_slug}/options/${option_id}`); void logResponse("get_option_of_custom_field", { object_type, field_slug, id }, record); return formatShow(record, "custom field option"); } catch (error) { return formatError(error); } }, ); - src/api.ts:139-145 (helper)apiGet helper function called by the handler. Performs a GET request to the Eduframe API and returns the parsed JSON response.
/** * Perform a GET request to retrieve a single resource. * * @param path - API path, e.g. "/leads/1" * @param query - Optional query parameters */ export async function apiGet<T>(path: string, query?: Record<string, QueryValue>): Promise<T> { - src/formatters.ts:62-77 (helper)formatShow helper used by the handler to format the retrieved custom field option record as a human-readable text result.
/** * Format the response of a SHOW tool call. * * @param record - The resource record returned by the API. * @param resourceName - Human-readable name of the resource type (e.g. "course"). */ export function formatShow(record: EduframeRecord, resourceName: string): CallToolResult { return { content: [ { type: "text", text: `${resourceName}:\n\n${formatJSON(record)}${RESPONSE_LOG_HINT}`, }, ], }; }