collection_fields_create_option
Add a custom dropdown or selection field to a Webflow CMS collection with predefined choices, enabling structured content management through selectable options.
Instructions
Create a new option field in a CMS collection with predefined choices.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| collection_id | Yes | Unique identifier for the Collection. | |
| request | Yes |
Implementation Reference
- src/tools/cms.ts:130-154 (registration)Registration of the 'collection_fields_create_option' MCP tool, including title, description, input schema (referencing OptionFieldSchema), and inline handler function that calls the Webflow API to create an option field."collection_fields_create_option", { title: "Create Option Field", description: "Create a new option field in a CMS collection with predefined choices.", inputSchema: z.object({ collection_id: z .string() .describe("Unique identifier for the Collection."), request: OptionFieldSchema, }), }, async ({ collection_id, request }) => { try { const response = await getClient().collections.fields.create( collection_id, request, requestOptions ); return formatResponse(response); } catch (error) { return formatErrorResponse(error); } } );
- src/tools/cms.ts:142-153 (handler)The handler function for the tool, which invokes the Webflow collections.fields.create API with the provided collection_id and request body, formats the response or error.async ({ collection_id, request }) => { try { const response = await getClient().collections.fields.create( collection_id, request, requestOptions ); return formatResponse(response); } catch (error) { return formatErrorResponse(error); } }
- Zod schema definition for the input 'request' parameter used in creating an option field, defining properties like type='Option', displayName, options array, etc.export const OptionFieldSchema = z.object({ id: z.string().optional().describe("Unique identifier for the Field."), isEditable: z .boolean() .optional() .describe("Indicates if the field is editable."), isRequired: z .boolean() .optional() .describe("Indicates if the field is required."), type: z .literal("Option") .describe('Type of the field. Set this to "Option".'), displayName: z.string().describe("Name of the field."), helpText: z.string().optional().describe("Help text for the field."), metadata: z.object({ options: z.array( z .object({ name: z.string().describe("Name of the option."), id: z .string() .optional() .describe("Unique identifier for the option."), }) .describe("Array of options for the field.") ), }), });