Skip to main content
Glama

get_content_type

Retrieve a specific content type by its UID using this tool. Optionally include global field schemas for detailed schema analysis.

Instructions

Retrieves a specific content type by its UID, optionally including the global field schema.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
include_global_field_schemaNoInclude global field schemas
uidYesContent type UID to retrieve

Implementation Reference

  • src/index.ts:698-738 (registration)
    Registration of the 'get_content_type' tool using server.tool(), including description, input schema with Zod validation, and the handler function.
    server.tool(
      'get_content_type',
      'Retrieves a specific content type by its UID, optionally including the global field schema.',
      {
        uid: z.string().describe('Content type UID to retrieve'),
        include_global_field_schema: z.boolean().optional().default(false).describe('Include global field schemas'),
      },
      async ({ uid, include_global_field_schema }) => {
        try {
          const url = new URL(`${API_BASE_URL}/content_types/${uid}`)
    
          // Add query parameter if needed
          if (include_global_field_schema) {
            url.searchParams.append('include_global_field_schema', 'true')
          }
    
          const response = await axios.get<ContentTypeResponse>(url.toString(), {
            headers: getHeaders(),
          })
    
          return {
            content: [
              {
                type: 'text',
                text: `Content type retrieved successfully:\n\n${JSON.stringify(response.data.content_type, null, 2)}`,
              },
            ],
          }
        } catch (error) {
          return {
            content: [
              {
                type: 'text',
                text: `Error retrieving content type: ${handleError(error as ApiError)}`,
              },
            ],
            isError: true,
          }
        }
      },
    )
  • The handler function implements the core logic: constructs the Contentstack API URL for the specific content type UID, optionally appends global field schema query param, fetches data using axios, formats and returns the response or error.
    async ({ uid, include_global_field_schema }) => {
      try {
        const url = new URL(`${API_BASE_URL}/content_types/${uid}`)
    
        // Add query parameter if needed
        if (include_global_field_schema) {
          url.searchParams.append('include_global_field_schema', 'true')
        }
    
        const response = await axios.get<ContentTypeResponse>(url.toString(), {
          headers: getHeaders(),
        })
    
        return {
          content: [
            {
              type: 'text',
              text: `Content type retrieved successfully:\n\n${JSON.stringify(response.data.content_type, null, 2)}`,
            },
          ],
        }
      } catch (error) {
        return {
          content: [
            {
              type: 'text',
              text: `Error retrieving content type: ${handleError(error as ApiError)}`,
            },
          ],
          isError: true,
        }
      }
    },
  • Input schema defined using Zod for validation: requires 'uid' string, optional boolean 'include_global_field_schema' defaulting to false.
    {
      uid: z.string().describe('Content type UID to retrieve'),
      include_global_field_schema: z.boolean().optional().default(false).describe('Include global field schemas'),
    },

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