Skip to main content
Glama

create_content_type

Define and create custom content types with structured schemas, field rules, and taxonomies to organize and manage content efficiently.

Instructions

Creates a new content type with the specified schema, options, field rules, and taxonomies.

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
schemaYesArray 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
taxonomiesNoTaxonomies to associate with this content type
titleYesContent type title
uidYesContent type UID (unique identifier)

Implementation Reference

  • The handler function that implements the core logic for creating a new content type. It prepares a payload with title, uid, schema, options, field rules, and taxonomies, then sends a POST request to the Contentstack API endpoint /content_types. Includes error handling with detailed schema guidance.
      async ({ title, uid, schema, options, field_rules, taxonomies }) => {
        try {
          // Prepare the content type payload
          const payload: ContentTypePayload = {
            content_type: {
              title,
              uid,
              schema: schema as ContentTypeSchema[],
              options: options || {
                is_page: true,
                singleton: false,
                title: 'title',
                sub_title: [],
                url_pattern: '/:title',
                url_prefix: '/',
              },
            },
          }
    
          // Add field_rules if provided
          if (field_rules && field_rules.length > 0) {
            payload.content_type.field_rules = field_rules as ContentTypeFieldRule[]
          }
    
          // Add taxonomies if provided
          if (taxonomies && taxonomies.length > 0) {
            // Add the taxonomies field to the content_type object directly, not in schema
            payload.content_type.taxonomies = taxonomies
          }
    
          console.log('Sending payload:', JSON.stringify(payload, null, 2))
    
          const response = await axios.post<ContentTypeResponse>(`${API_BASE_URL}/content_types`, payload, {
            headers: getHeaders(),
          })
    
          console.log('API response:', JSON.stringify(response.data, null, 2))
    
          return {
            content: [
              {
                type: 'text',
                text: `Content type "${title}" created successfully with UID "${uid}".`,
              },
            ],
          }
        } catch (error) {
          const errorMessage = handleError(error as ApiError)
          return {
            content: [
              {
                type: 'text',
                text: `Error creating 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:
    
    // Title field example
    {
      "display_name": "Title",
      "uid": "title",
      "data_type": "text",
      "mandatory": true,
      "unique": true,
      "field_metadata": {
        "_default": true
      },
      "multiple": false
    }
    
    // Rich text editor example
    {
      "display_name": "Description",
      "uid": "description",
      "data_type": "text",
      "field_metadata": {
        "allow_rich_text": true,
        "description": "",
        "multiline": false,
        "rich_text_type": "advanced"
      },
      "multiple": false,
      "mandatory": false,
      "unique": false
    }`,
              },
            ],
            isError: true,
          }
        }
      },
  • Zod validation schema defining the input parameters for the tool: title, uid, schema (array of fields), options, field_rules (conditional visibility), and taxonomies.
      title: z.string().describe('Content type title'),
      uid: z.string().describe('Content type UID (unique identifier)'),
      schema: z
        .array(z.object({}).passthrough())
        .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'),
      taxonomies: z
        .array(
          z.object({
            taxonomy_uid: z.string().describe('Taxonomy UID to link'),
            max_terms: z.number().optional().describe('Maximum number of terms allowed (up to 25)'),
            mandatory: z.boolean().optional().describe('Whether this taxonomy is required'),
            non_localizable: z.boolean().optional().describe('Whether this taxonomy is non-localizable'),
          }),
        )
        .optional()
        .describe('Taxonomies to associate with this content type'),
    },
  • src/index.ts:264-406 (registration)
    The server.tool() call that registers the 'create_content_type' tool with the MCP server, providing the name, description, input schema, and handler implementation.
      'create_content_type',
      'Creates a new content type with the specified schema, options, field rules, and taxonomies.',
      {
        title: z.string().describe('Content type title'),
        uid: z.string().describe('Content type UID (unique identifier)'),
        schema: z
          .array(z.object({}).passthrough())
          .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'),
        taxonomies: z
          .array(
            z.object({
              taxonomy_uid: z.string().describe('Taxonomy UID to link'),
              max_terms: z.number().optional().describe('Maximum number of terms allowed (up to 25)'),
              mandatory: z.boolean().optional().describe('Whether this taxonomy is required'),
              non_localizable: z.boolean().optional().describe('Whether this taxonomy is non-localizable'),
            }),
          )
          .optional()
          .describe('Taxonomies to associate with this content type'),
      },
      async ({ title, uid, schema, options, field_rules, taxonomies }) => {
        try {
          // Prepare the content type payload
          const payload: ContentTypePayload = {
            content_type: {
              title,
              uid,
              schema: schema as ContentTypeSchema[],
              options: options || {
                is_page: true,
                singleton: false,
                title: 'title',
                sub_title: [],
                url_pattern: '/:title',
                url_prefix: '/',
              },
            },
          }
    
          // Add field_rules if provided
          if (field_rules && field_rules.length > 0) {
            payload.content_type.field_rules = field_rules as ContentTypeFieldRule[]
          }
    
          // Add taxonomies if provided
          if (taxonomies && taxonomies.length > 0) {
            // Add the taxonomies field to the content_type object directly, not in schema
            payload.content_type.taxonomies = taxonomies
          }
    
          console.log('Sending payload:', JSON.stringify(payload, null, 2))
    
          const response = await axios.post<ContentTypeResponse>(`${API_BASE_URL}/content_types`, payload, {
            headers: getHeaders(),
          })
    
          console.log('API response:', JSON.stringify(response.data, null, 2))
    
          return {
            content: [
              {
                type: 'text',
                text: `Content type "${title}" created successfully with UID "${uid}".`,
              },
            ],
          }
        } catch (error) {
          const errorMessage = handleError(error as ApiError)
          return {
            content: [
              {
                type: 'text',
                text: `Error creating 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:
    
    // Title field example
    {
      "display_name": "Title",
      "uid": "title",
      "data_type": "text",
      "mandatory": true,
      "unique": true,
      "field_metadata": {
        "_default": true
      },
      "multiple": false
    }
    
    // Rich text editor example
    {
      "display_name": "Description",
      "uid": "description",
      "data_type": "text",
      "field_metadata": {
        "allow_rich_text": true,
        "description": "",
        "multiline": false,
        "rich_text_type": "advanced"
      },
      "multiple": false,
      "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 the full burden of behavioral disclosure. While 'creates' implies a write operation, it doesn't specify permissions needed, whether this is a destructive operation (overwrites existing content types with same UID?), what happens on success/failure, or any rate limits. The description mentions components like 'schema, options, field rules, and taxonomies' but doesn't explain their behavioral 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, well-structured sentence that efficiently communicates the core functionality. It front-loads the main action ('Creates a new content type') and lists the key components without unnecessary elaboration. Every word earns its place.

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 complex creation tool with 6 parameters (including nested objects), no annotations, and no output schema, the description is insufficient. It doesn't explain what happens after creation (e.g., returns the created content type object?), error conditions, or how this tool integrates with the broader content management system represented by sibling tools.

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 main parameter categories (schema, options, field rules, taxonomies) which adds some semantic context beyond the schema. However, with 100% schema description coverage, the schema already documents all 6 parameters thoroughly. The description doesn't add significant parameter-specific details like format examples, constraints, or relationships between parameters.

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 'creates' and the resource 'new content type', specifying what the tool does. It distinguishes from siblings like 'update_content_type' by focusing on creation rather than modification. However, it doesn't explicitly differentiate from 'create_entry' or 'create_global_field' in terms of resource type hierarchy.

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. It doesn't mention prerequisites, when not to use it, or how it relates to sibling tools like 'create_entry' (which likely creates entries within content types) or 'create_global_field' (which might create reusable fields).

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