Skip to main content
Glama

publish_entry

Publishes content entries to specified environments and locales in Contentstack, ensuring accurate content distribution across platforms and regions.

Instructions

Publishes an entry to a specified environment and locale.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
content_type_uidYesContent type UID
entry_uidYesEntry UID to publish
environmentYesEnvironment to publish to
localeNoLocale code (defaults to en-us)en-us

Implementation Reference

  • The handler function for the 'publish_entry' tool. It fetches the current entry to get its version, prepares a publish payload with the specified environment and locale, and sends a POST request to the Contentstack API's publish endpoint.
    async ({ content_type_uid, entry_uid, environment, locale }) => { try { // First get the entry to find its current version const entryResponse = await axios.get<EntryResponse>( `${API_BASE_URL}/content_types/${content_type_uid}/entries/${entry_uid}`, { headers: getHeaders(), }, ) const version = entryResponse.data.entry._version // Prepare publish payload const payload = { entry: { environments: [environment], locales: [locale], }, } // Publish the entry const response = await axios.post( `${API_BASE_URL}/content_types/${content_type_uid}/entries/${entry_uid}/publish`, payload, { headers: getHeaders() }, ) return { content: [ { type: 'text', text: `Entry "${entry_uid}" published successfully to environment "${environment}" in locale "${locale}".`, }, ], } } catch (error) { return { content: [ { type: 'text', text: handleError(error as ApiError), }, ], isError: true, } } },
  • Zod schema defining the input parameters for the 'publish_entry' tool: content_type_uid, entry_uid, environment, and locale (with default 'en-us').
    { content_type_uid: z.string().describe('Content type UID'), entry_uid: z.string().describe('Entry UID to publish'), environment: z.string().describe('Environment to publish to'), locale: z.string().default('en-us').describe('Locale code (defaults to en-us)'), },
  • src/index.ts:1075-1130 (registration)
    Registration of the 'publish_entry' tool using server.tool(), including name, description, input schema, and handler function.
    'publish_entry', 'Publishes an entry to a specified environment and locale.', { content_type_uid: z.string().describe('Content type UID'), entry_uid: z.string().describe('Entry UID to publish'), environment: z.string().describe('Environment to publish to'), locale: z.string().default('en-us').describe('Locale code (defaults to en-us)'), }, async ({ content_type_uid, entry_uid, environment, locale }) => { try { // First get the entry to find its current version const entryResponse = await axios.get<EntryResponse>( `${API_BASE_URL}/content_types/${content_type_uid}/entries/${entry_uid}`, { headers: getHeaders(), }, ) const version = entryResponse.data.entry._version // Prepare publish payload const payload = { entry: { environments: [environment], locales: [locale], }, } // Publish the entry const response = await axios.post( `${API_BASE_URL}/content_types/${content_type_uid}/entries/${entry_uid}/publish`, payload, { headers: getHeaders() }, ) return { content: [ { type: 'text', text: `Entry "${entry_uid}" published successfully to 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