create_entry
Generate and add a new entry for a specific content type in Contentstack MCP, ensuring data aligns with predefined schema requirements.
Instructions
Creates a new entry for a specified content type.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content_type_uid | Yes | Content type UID | |
| entry | Yes | Entry data according to content type schema |
Implementation Reference
- src/index.ts:588-616 (handler)The main handler function for the 'create_entry' tool. It constructs a POST request payload with the provided entry data and sends it to the Contentstack API endpoint `/content_types/{content_type_uid}/entries` to create a new entry. Returns success message with the new entry UID or error details.async ({ content_type_uid, entry }) => { try { const payload = { entry } const response = await axios.post(`${API_BASE_URL}/content_types/${content_type_uid}/entries`, payload, { headers: getHeaders(), }) return { content: [ { type: 'text', text: `Entry created successfully in content type "${content_type_uid}". Entry UID: ${response.data.entry.uid}`, }, ], } } catch (error) { return { content: [ { type: 'text', text: handleError(error as ApiError), }, ], isError: true, } } }, )
- src/index.ts:584-587 (schema)Zod schema defining the input parameters for the 'create_entry' tool: content_type_uid (string) and entry (passthrough object for flexible entry data matching the content type schema).{ content_type_uid: z.string().describe('Content type UID'), entry: z.object({}).passthrough().describe('Entry data according to content type schema'), },
- src/index.ts:581-616 (registration)Registers the 'create_entry' tool on the MCP server using server.tool(), including name, description, input schema, and handler function.server.tool( 'create_entry', 'Creates a new entry for a specified content type.', { content_type_uid: z.string().describe('Content type UID'), entry: z.object({}).passthrough().describe('Entry data according to content type schema'), }, async ({ content_type_uid, entry }) => { try { const payload = { entry } const response = await axios.post(`${API_BASE_URL}/content_types/${content_type_uid}/entries`, payload, { headers: getHeaders(), }) return { content: [ { type: 'text', text: `Entry created successfully in content type "${content_type_uid}". Entry UID: ${response.data.entry.uid}`, }, ], } } catch (error) { return { content: [ { type: 'text', text: handleError(error as ApiError), }, ], isError: true, } } }, )