add_option_to_custom_field
Add a new option to a custom field by providing the field identifier, option value, and an enabled status.
Instructions
Add an option to a custom field
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| object_type | Yes | ID of the custom field option | |
| field_slug | Yes | ID of the custom field option | |
| value | Yes | ||
| enabled | Yes | Whether the option can be chosen or not |
Implementation Reference
- The handler function for the 'add_option_to_custom_field' tool. It accepts object_type, field_slug, value, and enabled parameters, makes a POST request to /custom/{object_type}/fields/{field_slug}/options, and returns the created record.
server.registerTool( "add_option_to_custom_field", { description: "Add an option to a custom field", annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true }, inputSchema: { object_type: z.number().int().positive().describe("ID of the custom field option"), field_slug: z.number().int().positive().describe("ID of the custom field option"), value: z.string(), enabled: z.boolean().describe("Whether the option can be chosen or not"), }, }, async ({ object_type, field_slug, ...body }) => { try { const record = await apiPost<EduframeRecord>(`/custom/${object_type}/fields/${field_slug}/options`, body); void logResponse("add_option_to_custom_field", { object_type, field_slug, ...body }, record); return formatShow(record, "custom field option"); } catch (error) { return formatError(error); } }, ); - Input schema for the 'add_option_to_custom_field' tool, using Zod for validation. Defines object_type (number), field_slug (number), value (string), and enabled (boolean).
inputSchema: { object_type: z.number().int().positive().describe("ID of the custom field option"), field_slug: z.number().int().positive().describe("ID of the custom field option"), value: z.string(), enabled: z.boolean().describe("Whether the option can be chosen or not"), }, }, - src/tools/custom_field_options.ts:7-133 (registration)The registration function 'registerCustomFieldOptionTools' that registers all custom field option tools (including 'add_option_to_custom_field') on the MCP server via server.registerTool().
export function registerCustomFieldOptionTools(server: McpServer): void { server.registerTool( "get_options_of_custom_field", { description: "Get all options 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"), 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 ({ object_type, field_slug, cursor, per_page }) => { try { const result = await apiList<EduframeRecord>(`/custom/${object_type}/fields/${field_slug}/options`, { cursor, per_page, }); void logResponse("get_options_of_custom_field", { object_type, field_slug, cursor, per_page }, result); const toolResult = formatList(result.records, "custom field options"); if (result.nextCursor) { toolResult.content.push({ type: "text", text: `\nNext page cursor: ${result.nextCursor}` }); } return toolResult; } catch (error) { return formatError(error); } }, ); 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); } }, ); server.registerTool( "update_option_of_custom_field", { description: "Update an option of a custom field", annotations: { readOnlyHint: false, 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 update"), value: z.string().optional(), enabled: z.boolean().optional().describe("Whether the option can be chosen or not"), }, }, async ({ object_type, field_slug, id, ...body }) => { try { const record = await apiPatch<EduframeRecord>( `/custom/${object_type}/fields/${field_slug}/options/${option_id}`, body, ); void logResponse("update_option_of_custom_field", { object_type, field_slug, id, ...body }, record); return formatUpdate(record, "custom field option"); } catch (error) { return formatError(error); } }, ); server.registerTool( "delete_option_of_custom_field", { description: "Delete an option from custom field", annotations: { readOnlyHint: false, destructiveHint: true, 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 delete"), }, }, async ({ object_type, field_slug, id }) => { try { const record = await apiDelete<EduframeRecord>( `/custom/${object_type}/fields/${field_slug}/options/${option_id}`, ); void logResponse("delete_option_of_custom_field", { object_type, field_slug, id }, record); return formatDelete(record, "custom field option"); } catch (error) { return formatError(error); } }, ); server.registerTool( "add_option_to_custom_field", { description: "Add an option to a custom field", annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true }, inputSchema: { object_type: z.number().int().positive().describe("ID of the custom field option"), field_slug: z.number().int().positive().describe("ID of the custom field option"), value: z.string(), enabled: z.boolean().describe("Whether the option can be chosen or not"), }, }, async ({ object_type, field_slug, ...body }) => { try { const record = await apiPost<EduframeRecord>(`/custom/${object_type}/fields/${field_slug}/options`, body); void logResponse("add_option_to_custom_field", { object_type, field_slug, ...body }, record); return formatShow(record, "custom field option"); } catch (error) { return formatError(error); } }, ); } - src/tools/index.ts:128-131 (registration)The 'registerAllTools' function that iterates over all tool registration functions, including 'registerCustomFieldOptionTools', to register them on the MCP server.
export function registerAllTools(server: McpServer): void { for (const register of tools) { register(server); } - src/tools/index.ts:18-81 (registration)Import and array entry that pulls in 'registerCustomFieldOptionTools' from 'custom_field_options.ts' and adds it to the tools registration list.
import { registerCustomFieldOptionTools } from "./custom_field_options"; import { registerCustomObjectTools } from "./custom_objects"; import { registerCustomRecordTools } from "./custom_records"; import { registerDiscountCodeTools } from "./discount_codes"; import { registerEditionDescriptionSectionTools } from "./edition_description_sections"; import { registerEducatorTools } from "./educators"; import { registerEmailTools } from "./emails"; import { registerEnrollmentTools } from "./enrollments"; import { registerGradeTools } from "./grades"; import { registerInvoiceVatTools } from "./invoice_vats"; import { registerInvoiceTools } from "./invoices"; import { registerLabelTools } from "./labels"; import { registerLeadTools } from "./leads"; import { registerMaterialGroupTools } from "./material_groups"; import { registerMaterialTools } from "./materials"; import { registerMeetingLocationTools } from "./meeting_locations"; import { registerMeetingTools } from "./meetings"; import { registerOrderTools } from "./orders"; import { registerOrganizationTools } from "./organizations"; import { registerPaymentMethodTools } from "./payment_methods"; import { registerPaymentOptionTools } from "./payment_options"; import { registerPaymentTools } from "./payments"; import { registerPlannedCourseTools } from "./planned_courses"; import { registerPlanningAttendeeTools } from "./planning_attendees"; import { registerPlanningConflictTools } from "./planning_conflicts"; import { registerPlanningEventTools } from "./planning_events"; import { registerPlanningLocationTools } from "./planning_locations"; import { registerPlanningMaterialTools } from "./planning_materials"; import { registerPlanningRequiredTeacherGroupAttendeeTools } from "./planning_required_teacher_group_attendees"; import { registerPlanningTeacherTools } from "./planning_teachers"; import { registerProgramEditionTools } from "./program_editions"; import { registerProgramElementTools } from "./program_elements"; import { registerProgramEnrollmentTools } from "./program_enrollments"; import { registerProgramPersonalProgramElementTools } from "./program_personal_program_elements"; import { registerProgramProgramTools } from "./program_programs"; import { registerReferralTools } from "./referrals"; import { registerSignupQuestionTools } from "./signup_questions"; import { registerTaskTools } from "./tasks"; import { registerTeacherEnrollmentTools } from "./teacher_enrollments"; import { registerTeacherRoleTools } from "./teacher_roles"; import { registerTeacherTools } from "./teachers"; import { registerTheseTools } from "./theses"; import { registerUserTools } from "./users"; import { registerWebhookNotificationTools } from "./webhook_notifications"; import { registerWebhookTools } from "./webhooks"; const tools: Array<(server: McpServer) => void> = [ registerAccountTools, registerAffiliationTools, registerAttendanceTools, registerAuthenticationTools, registerCatalogProductTools, registerCatalogVariantTools, registerCategorieTools, registerCertificateTools, registerCommentTools, registerCourseLocationTools, registerCourseTabTools, registerCourseVariantTools, registerCourseTools, registerCreditCategorieTools, registerCreditTools, registerCustomAssociationTools, registerCustomFieldOptionTools,