Skip to main content
Glama

create_global_field

Create global fields with defined titles, unique identifiers, and structured schemas in the Contentstack MCP server to streamline content management and organization.

Instructions

Creates a new global field with the specified title, UID, and schema.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
schemaYesArray of schema fields defining the global field structure. Each field object should include properties like: - display_name: Field display name - uid: Unique identifier for the field - data_type: Type of data (text, number, boolean, file, etc.) - field_metadata: Additional metadata for the field - multiple: Whether field accepts multiple values - mandatory: Whether field is required - unique: Whether field values must be unique
titleYesGlobal field title
uidYesGlobal field UID (unique identifier)

Implementation Reference

  • The handler function for the 'create_global_field' tool. It constructs a payload with title, uid, and schema, posts it to the Contentstack API endpoint `/global_fields`, logs the request and response, and returns success or formatted error message with schema examples.
    async ({ title, uid, schema }) => { try { // Prepare the global field payload const payload: GlobalFieldPayload = { global_field: { title, uid, schema: schema as ContentTypeSchema[], }, } console.log('Sending global field payload:', JSON.stringify(payload, null, 2)) const response = await axios.post<GlobalFieldResponse>(`${API_BASE_URL}/global_fields`, payload, { headers: getHeaders(), }) console.log('API response:', JSON.stringify(response.data, null, 2)) return { content: [ { type: 'text', text: `Global field "${title}" created successfully with UID "${uid}".`, }, ], } } catch (error) { const errorMessage = handleError(error as ApiError) return { content: [ { type: 'text', text: `Error creating global field: ${errorMessage}\n\nPlease ensure your schema adheres to the Contentstack schema specification. Schema should be an array of field objects. Example field objects: // Text field example { "display_name": "Name", "uid": "name", "data_type": "text", "multiple": false, "mandatory": false, "unique": false } // Rich text editor example { "data_type": "text", "display_name": "Description", "uid": "description", "field_metadata": { "allow_rich_text": true, "description": "", "multiline": false, "rich_text_type": "advanced", "options": [], "version": 3 }, "multiple": false, "mandatory": false, "unique": false }`, }, ], isError: true, } } },
  • Zod schema defining the input parameters for the 'create_global_field' tool: title (string), uid (string), and schema (array of objects). Includes detailed descriptions.
    { title: z.string().describe('Global field title'), uid: z.string().describe('Global field UID (unique identifier)'), schema: z .array(z.object({}).passthrough()) .describe( 'Array of schema fields defining the global field structure. Each field object should include properties like:\n- display_name: Field display name\n- uid: Unique identifier for the field\n- data_type: Type of data (text, number, boolean, file, etc.)\n- field_metadata: Additional metadata for the field\n- multiple: Whether field accepts multiple values\n- mandatory: Whether field is required\n- unique: Whether field values must be unique', ), },
  • src/index.ts:1182-1262 (registration)
    Registration of the 'create_global_field' tool using server.tool(), including name, description, input schema, and inline handler function.
    server.tool( 'create_global_field', 'Creates a new global field with the specified title, UID, and schema.', { title: z.string().describe('Global field title'), uid: z.string().describe('Global field UID (unique identifier)'), schema: z .array(z.object({}).passthrough()) .describe( 'Array of schema fields defining the global field structure. Each field object should include properties like:\n- display_name: Field display name\n- uid: Unique identifier for the field\n- data_type: Type of data (text, number, boolean, file, etc.)\n- field_metadata: Additional metadata for the field\n- multiple: Whether field accepts multiple values\n- mandatory: Whether field is required\n- unique: Whether field values must be unique', ), }, async ({ title, uid, schema }) => { try { // Prepare the global field payload const payload: GlobalFieldPayload = { global_field: { title, uid, schema: schema as ContentTypeSchema[], }, } console.log('Sending global field payload:', JSON.stringify(payload, null, 2)) const response = await axios.post<GlobalFieldResponse>(`${API_BASE_URL}/global_fields`, payload, { headers: getHeaders(), }) console.log('API response:', JSON.stringify(response.data, null, 2)) return { content: [ { type: 'text', text: `Global field "${title}" created successfully with UID "${uid}".`, }, ], } } catch (error) { const errorMessage = handleError(error as ApiError) return { content: [ { type: 'text', text: `Error creating global field: ${errorMessage}\n\nPlease ensure your schema adheres to the Contentstack schema specification. Schema should be an array of field objects. Example field objects: // Text field example { "display_name": "Name", "uid": "name", "data_type": "text", "multiple": false, "mandatory": false, "unique": false } // Rich text editor example { "data_type": "text", "display_name": "Description", "uid": "description", "field_metadata": { "allow_rich_text": true, "description": "", "multiline": false, "rich_text_type": "advanced", "options": [], "version": 3 }, "multiple": false, "mandatory": false, "unique": false }`, }, ], isError: true, } } }, )
Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/darekrossman/contentstack-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server