collection_fields_create_reference
Add reference fields to link items between CMS collections in Webflow. Create connections to organize and relate content across different collections.
Instructions
Create a new reference field in a CMS collection that links to items in another collection.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| collection_id | Yes | Unique identifier for the Collection. | |
| request | Yes |
Implementation Reference
- src/tools/cms.ts:170-181 (handler)The asynchronous handler function that executes the tool logic: calls WebflowClient.collections.fields.create with collection_id and request, 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 defining the structure for the 'request' parameter used in creating a reference field (ReferenceFieldSchema).export const ReferenceFieldSchema = 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 .union([z.literal("MultiReference"), z.literal("Reference")]) .describe("Type of the field. Choose of these appropriate field types."), displayName: z.string().describe("Name of the field."), helpText: z.string().optional().describe("Help text for the field."), metadata: z .object({ collectionId: z.string(), }) .describe( "ID of the referenced collection. Use this only for Reference and MultiReference fields." ), });
- src/tools/cms.ts:157-182 (registration)Registers the 'collection_fields_create_reference' tool with the MCP server inside registerCmsTools, including title, description, input schema, and handler.server.registerTool( "collection_fields_create_reference", { title: "Create Reference Field", description: "Create a new reference field in a CMS collection that links to items in another collection.", inputSchema: z.object({ collection_id: z .string() .describe("Unique identifier for the Collection."), request: ReferenceFieldSchema, }), }, async ({ collection_id, request }) => { try { const response = await getClient().collections.fields.create( collection_id, request, requestOptions ); return formatResponse(response); } catch (error) { return formatErrorResponse(error); } } );