Skip to main content
Glama

update_content_type

Modify an existing content type by updating its title, schema, field rules, and options. Use this MCP server tool to adjust content structure, visibility conditions, and URL patterns efficiently.

Instructions

Updates an existing content type identified by its UID. Allows modification of title, schema, options, and field rules.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
field_rulesNoField visibility rules for showing/hiding fields based on conditions
optionsNoContent type options like webpage/content block settings and URL patterns
schemaNoArray of schema fields defining the content 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
titleNoNew content type title
uidYesContent type UID to update

Implementation Reference

  • The handler function for the 'update_content_type' tool. It fetches the existing content type details, merges the provided updates (title, schema, options, field_rules) with the current data, constructs the payload, performs a PUT request to the Contentstack API endpoint `/content_types/{uid}`, and returns success or detailed error message.
      async ({ uid, title, schema, options, field_rules }) => {
        try {
          // First fetch existing content type
          const fetchResponse = await axios.get<ContentTypeResponse>(`${API_BASE_URL}/content_types/${uid}`, {
            headers: getHeaders(),
          })
    
          const existingContentType = fetchResponse.data.content_type
    
          // Prepare update payload
          const payload: ContentTypePayload = {
            content_type: {
              ...existingContentType,
              title: title || existingContentType.title,
              schema: schema ? (schema as ContentTypeSchema[]) : existingContentType.schema,
            },
          }
    
          // Update options if provided
          if (options) {
            payload.content_type.options = {
              ...existingContentType.options,
              ...options,
            }
          }
    
          // Update field_rules if provided
          if (field_rules) {
            payload.content_type.field_rules = field_rules as ContentTypeFieldRule[]
          }
    
          // Update content type
          const response = await axios.put<ContentTypeResponse>(`${API_BASE_URL}/content_types/${uid}`, payload, {
            headers: getHeaders(),
          })
    
          return {
            content: [
              {
                type: 'text',
                text: `Content type "${uid}" updated successfully.`,
              },
            ],
          }
        } catch (error) {
          const errorMessage = handleError(error as ApiError)
          return {
            content: [
              {
                type: 'text',
                text: `Error updating content type: ${errorMessage}\n\nPlease ensure your schema adheres to the Contentstack schema specification. Schema should be an array of field objects. Example field objects:
    
    // Single line text field example
    {
      "display_name": "Field Name",
      "uid": "field_uid",
      "data_type": "text",
      "field_metadata": {
        "description": "Field description"
      },
      "multiple": false,
      "mandatory": false,
      "unique": false
    }
    
    // Select field example
    {
      "display_name": "Category",
      "uid": "category",
      "data_type": "text",
      "display_type": "dropdown",
      "enum": {
        "advanced": false,
        "choices": [
          {"value": "Technology"},
          {"value": "Finance"},
          {"value": "Health"}
        ]
      },
      "multiple": true,
      "mandatory": false,
      "unique": false
    }`,
              },
            ],
            isError: true,
          }
        }
      },
  • Input schema using Zod for validating parameters of the update_content_type tool: uid (required string), title (optional string), schema (optional array of field objects), options (optional object with content type settings), field_rules (optional array of conditional rules).
    {
      uid: z.string().describe('Content type UID to update'),
      title: z.string().optional().describe('New content type title'),
      schema: z
        .array(z.object({}).passthrough())
        .optional()
        .describe(
          'Array of schema fields defining the content 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',
        ),
      options: z
        .object({
          is_page: z.boolean().optional().describe('Set to true for webpage content types, false for content blocks'),
          singleton: z.boolean().optional().describe('Set to true for single content types, false for multiple'),
          title: z.string().optional().describe('Field to use as the title'),
          sub_title: z.array(z.string()).optional().describe('Fields to use as subtitles'),
          url_pattern: z.string().optional().describe('Default URL pattern for entries'),
          url_prefix: z.string().optional().describe('Path prefix for entries'),
        })
        .optional()
        .describe('Content type options like webpage/content block settings and URL patterns'),
      field_rules: z
        .array(
          z.object({
            conditions: z.array(
              z.object({
                operand_field: z.string().describe('Field on which to apply condition'),
                operator: z.string().describe('Operator for condition (e.g., equals, contains)'),
                value: z.any().describe('Expected value for the condition'),
              }),
            ),
            actions: z.array(
              z.object({
                action: z.string().describe('Action to perform (show/hide)'),
                target_field: z.string().describe('Field to show/hide based on condition'),
              }),
            ),
            match_type: z.string().describe('Whether all or any conditions should be met'),
          }),
        )
        .optional()
        .describe('Field visibility rules for showing/hiding fields based on conditions'),
    },
  • src/index.ts:409-543 (registration)
    Registration of the 'update_content_type' tool on the MCP server using server.tool(), specifying the tool name, description, input schema, and handler function.
    server.tool(
      'update_content_type',
      'Updates an existing content type identified by its UID. Allows modification of title, schema, options, and field rules.',
      {
        uid: z.string().describe('Content type UID to update'),
        title: z.string().optional().describe('New content type title'),
        schema: z
          .array(z.object({}).passthrough())
          .optional()
          .describe(
            'Array of schema fields defining the content 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',
          ),
        options: z
          .object({
            is_page: z.boolean().optional().describe('Set to true for webpage content types, false for content blocks'),
            singleton: z.boolean().optional().describe('Set to true for single content types, false for multiple'),
            title: z.string().optional().describe('Field to use as the title'),
            sub_title: z.array(z.string()).optional().describe('Fields to use as subtitles'),
            url_pattern: z.string().optional().describe('Default URL pattern for entries'),
            url_prefix: z.string().optional().describe('Path prefix for entries'),
          })
          .optional()
          .describe('Content type options like webpage/content block settings and URL patterns'),
        field_rules: z
          .array(
            z.object({
              conditions: z.array(
                z.object({
                  operand_field: z.string().describe('Field on which to apply condition'),
                  operator: z.string().describe('Operator for condition (e.g., equals, contains)'),
                  value: z.any().describe('Expected value for the condition'),
                }),
              ),
              actions: z.array(
                z.object({
                  action: z.string().describe('Action to perform (show/hide)'),
                  target_field: z.string().describe('Field to show/hide based on condition'),
                }),
              ),
              match_type: z.string().describe('Whether all or any conditions should be met'),
            }),
          )
          .optional()
          .describe('Field visibility rules for showing/hiding fields based on conditions'),
      },
      async ({ uid, title, schema, options, field_rules }) => {
        try {
          // First fetch existing content type
          const fetchResponse = await axios.get<ContentTypeResponse>(`${API_BASE_URL}/content_types/${uid}`, {
            headers: getHeaders(),
          })
    
          const existingContentType = fetchResponse.data.content_type
    
          // Prepare update payload
          const payload: ContentTypePayload = {
            content_type: {
              ...existingContentType,
              title: title || existingContentType.title,
              schema: schema ? (schema as ContentTypeSchema[]) : existingContentType.schema,
            },
          }
    
          // Update options if provided
          if (options) {
            payload.content_type.options = {
              ...existingContentType.options,
              ...options,
            }
          }
    
          // Update field_rules if provided
          if (field_rules) {
            payload.content_type.field_rules = field_rules as ContentTypeFieldRule[]
          }
    
          // Update content type
          const response = await axios.put<ContentTypeResponse>(`${API_BASE_URL}/content_types/${uid}`, payload, {
            headers: getHeaders(),
          })
    
          return {
            content: [
              {
                type: 'text',
                text: `Content type "${uid}" updated successfully.`,
              },
            ],
          }
        } catch (error) {
          const errorMessage = handleError(error as ApiError)
          return {
            content: [
              {
                type: 'text',
                text: `Error updating content type: ${errorMessage}\n\nPlease ensure your schema adheres to the Contentstack schema specification. Schema should be an array of field objects. Example field objects:
    
    // Single line text field example
    {
      "display_name": "Field Name",
      "uid": "field_uid",
      "data_type": "text",
      "field_metadata": {
        "description": "Field description"
      },
      "multiple": false,
      "mandatory": false,
      "unique": false
    }
    
    // Select field example
    {
      "display_name": "Category",
      "uid": "category",
      "data_type": "text",
      "display_type": "dropdown",
      "enum": {
        "advanced": false,
        "choices": [
          {"value": "Technology"},
          {"value": "Finance"},
          {"value": "Health"}
        ]
      },
      "multiple": true,
      "mandatory": false,
      "unique": false
    }`,
              },
            ],
            isError: true,
          }
        }
      },
    )
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. While it correctly identifies this as an update/mutation operation, it doesn't disclose important behavioral traits: whether this requires specific permissions, whether changes are reversible, what happens to existing entries when schema changes, or what the response looks like. For a mutation tool affecting content structure with no annotation coverage, this is a significant gap.

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 front-loads the core purpose and lists the modifiable components. Every word earns its place with zero waste or redundancy. It's appropriately sized for the tool's complexity.

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?

For a mutation tool with 5 parameters (including complex nested objects), no annotations, and no output schema, the description is incomplete. It doesn't address behavioral aspects like permissions, side effects, or response format. While the schema covers parameter details well, the description fails to provide the contextual completeness needed for safe and effective tool invocation.

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?

Schema description coverage is 100%, so the schema already documents all 5 parameters thoroughly. The description lists the four modifiable aspects (title, schema, options, field rules) which correspond to parameters, but doesn't add meaningful semantic context beyond what's in the schema descriptions. The baseline of 3 is appropriate when the schema does the heavy lifting.

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 verb ('Updates') and resource ('existing content type identified by its UID'), and specifies what can be modified ('title, schema, options, and field rules'). It distinguishes from 'create_content_type' by specifying 'existing' content type, but doesn't explicitly differentiate from 'update_entry' or 'update_global_field' which operate on 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 'update_entry' or 'update_global_field'. It doesn't mention prerequisites (e.g., needing the UID of an existing content type) or when not to use it. The only implicit guidance is that it updates existing content types, but this is already covered in purpose clarity.

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