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,
          }
        }
      },
    )
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool creates a new global field but doesn't mention whether this is a destructive operation, what permissions are required, if there are rate limits, or what happens on success/failure. For a creation tool with zero annotation coverage, this leaves significant gaps in understanding its behavior and implications.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose and parameters. It's front-loaded with the core action and avoids unnecessary details, making it easy to parse quickly. Every word contributes to understanding the tool's function.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of creating a global field with three required parameters, no annotations, and no output schema, the description is incomplete. It doesn't cover behavioral aspects like error handling, authentication needs, or what the tool returns upon success. For a creation tool in a system with multiple resource types, more context is needed to guide proper usage.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description lists the parameters (title, UID, schema) but doesn't add meaning beyond what the input schema provides. Since schema description coverage is 100%, the schema already documents these parameters thoroughly. The description doesn't explain parameter interactions, constraints, or provide examples, so it meets the baseline for high schema coverage without adding extra value.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('creates') and resource ('new global field'), making the purpose evident. It distinguishes this tool from siblings like 'update_global_field' by specifying creation rather than modification. However, it doesn't explicitly differentiate from 'create_content_type' or 'create_entry', which are similar creation operations for different resources.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'create_content_type' or 'create_entry'. It mentions the required parameters but doesn't indicate prerequisites, such as whether a global field must be unique or if there are constraints on UID format. No explicit when-not-to-use scenarios or comparisons with sibling tools are included.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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