Skip to main content
Glama

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
NameRequiredDescriptionDefault
content_type_uidYesContent type UID
entry_uidYesEntry UID to unpublish
environmentYesEnvironment to unpublish from
localeNoLocale code (defaults to en-us)en-us

Implementation Reference

  • 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,
        }
      }
    },
  • 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,
          }
        }
      },
    )

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