unpublish_entry
Remove a published entry from a specific environment and locale. Specify content type UID, entry UID, and environment to unpublish content efficiently.
Instructions
Unpublishes an entry from a specified environment and locale.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content_type_uid | Yes | Content type UID | |
| entry_uid | Yes | Entry UID to unpublish | |
| environment | Yes | Environment to unpublish from | |
| locale | No | Locale code (defaults to en-us) | en-us |
Implementation Reference
- src/index.ts:1142-1178 (handler)The handler function that executes the unpublish_entry tool. It constructs a payload with the specified environment and locale, sends a POST request to the Contentstack API unpublish endpoint, and returns success or error messages.async ({ content_type_uid, entry_uid, environment, locale }) => { try { // Prepare unpublish payload const payload = { entry: { environments: [environment], locales: [locale], }, } // Unpublish the entry const response = await axios.post( `${API_BASE_URL}/content_types/${content_type_uid}/entries/${entry_uid}/unpublish`, payload, { headers: getHeaders() }, ) return { content: [ { type: 'text', text: `Entry "${entry_uid}" unpublished successfully from environment "${environment}" in locale "${locale}".`, }, ], } } catch (error) { return { content: [ { type: 'text', text: handleError(error as ApiError), }, ], isError: true, } } },
- src/index.ts:1136-1141 (schema)The Zod schema defining the input parameters for the unpublish_entry tool: content_type_uid, entry_uid, environment, and locale.{ content_type_uid: z.string().describe('Content type UID'), entry_uid: z.string().describe('Entry UID to unpublish'), environment: z.string().describe('Environment to unpublish from'), locale: z.string().default('en-us').describe('Locale code (defaults to en-us)'), },
- src/index.ts:1133-1179 (registration)The registration of the unpublish_entry tool on the MCP server using server.tool(), specifying the name, description, input schema, and handler function.server.tool( 'unpublish_entry', 'Unpublishes an entry from a specified environment and locale.', { content_type_uid: z.string().describe('Content type UID'), entry_uid: z.string().describe('Entry UID to unpublish'), environment: z.string().describe('Environment to unpublish from'), locale: z.string().default('en-us').describe('Locale code (defaults to en-us)'), }, async ({ content_type_uid, entry_uid, environment, locale }) => { try { // Prepare unpublish payload const payload = { entry: { environments: [environment], locales: [locale], }, } // Unpublish the entry const response = await axios.post( `${API_BASE_URL}/content_types/${content_type_uid}/entries/${entry_uid}/unpublish`, payload, { headers: getHeaders() }, ) return { content: [ { type: 'text', text: `Entry "${entry_uid}" unpublished successfully from environment "${environment}" in locale "${locale}".`, }, ], } } catch (error) { return { content: [ { type: 'text', text: handleError(error as ApiError), }, ], isError: true, } } }, )