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
| Name | Required | Description | Default |
|---|---|---|---|
| include_global_field_schema | No | Include global field schemas | |
| uid | Yes | Content 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, } } }, )
- src/index.ts:705-737 (handler)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, } } },
- src/index.ts:701-704 (schema)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'), },