Skip to main content
Glama

get_entry

Retrieve a specific entry by its content type and entry UID, with options for locale and including references, to efficiently manage and access content.

Instructions

Retrieves a specific entry by its content type UID and entry UID, with options for locale and including references.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
content_type_uidYesContent type UID
entry_uidYesEntry UID to retrieve
include_reference_content_type_uidNoInclude content type UIDs in references
include_referencesNoReferences to include
localeNoLocale code (e.g., 'en-us')

Implementation Reference

  • The main handler function for the 'get_entry' tool. It constructs the Contentstack API URL with provided parameters (content_type_uid, entry_uid, locale, references), makes a GET request using axios, and returns the entry data or handles errors.
    async ({ content_type_uid, entry_uid, locale, include_references, include_reference_content_type_uid }) => {
      try {
        const url = new URL(`${API_BASE_URL}/content_types/${content_type_uid}/entries/${entry_uid}`)
    
        // Add query parameters if provided
        if (locale) {
          url.searchParams.append('locale', locale)
        }
    
        if (include_references && include_references.length > 0) {
          url.searchParams.append('include[]', include_references.join(','))
        }
    
        if (include_reference_content_type_uid) {
          url.searchParams.append('include_reference_content_type_uid', 'true')
        }
    
        const response = await axios.get<EntryResponse>(url.toString(), {
          headers: getHeaders(),
        })
    
        return {
          content: [
            {
              type: 'text',
              text: `Entry retrieved successfully:\n\n${JSON.stringify(response.data.entry, null, 2)}`,
            },
          ],
        }
      } catch (error) {
        return {
          content: [
            {
              type: 'text',
              text: `Error retrieving entry: ${handleError(error as ApiError)}`,
            },
          ],
          isError: true,
        }
      }
  • Zod schema defining the input parameters for the 'get_entry' tool, including required content_type_uid and entry_uid, and optional locale, include_references, and include_reference_content_type_uid.
    {
      content_type_uid: z.string().describe('Content type UID'),
      entry_uid: z.string().describe('Entry UID to retrieve'),
      locale: z.string().optional().describe("Locale code (e.g., 'en-us')"),
      include_references: z.array(z.string()).optional().describe('References to include'),
      include_reference_content_type_uid: z
        .boolean()
        .optional()
        .default(false)
        .describe('Include content type UIDs in references'),
    },
  • src/index.ts:850-905 (registration)
    The server.tool registration call that defines and registers the 'get_entry' tool with the MCP server, including name, description, input schema, and handler function.
    server.tool(
      'get_entry',
      'Retrieves a specific entry by its content type UID and entry UID, with options for locale and including references.',
      {
        content_type_uid: z.string().describe('Content type UID'),
        entry_uid: z.string().describe('Entry UID to retrieve'),
        locale: z.string().optional().describe("Locale code (e.g., 'en-us')"),
        include_references: z.array(z.string()).optional().describe('References to include'),
        include_reference_content_type_uid: z
          .boolean()
          .optional()
          .default(false)
          .describe('Include content type UIDs in references'),
      },
      async ({ content_type_uid, entry_uid, locale, include_references, include_reference_content_type_uid }) => {
        try {
          const url = new URL(`${API_BASE_URL}/content_types/${content_type_uid}/entries/${entry_uid}`)
    
          // Add query parameters if provided
          if (locale) {
            url.searchParams.append('locale', locale)
          }
    
          if (include_references && include_references.length > 0) {
            url.searchParams.append('include[]', include_references.join(','))
          }
    
          if (include_reference_content_type_uid) {
            url.searchParams.append('include_reference_content_type_uid', 'true')
          }
    
          const response = await axios.get<EntryResponse>(url.toString(), {
            headers: getHeaders(),
          })
    
          return {
            content: [
              {
                type: 'text',
                text: `Entry retrieved successfully:\n\n${JSON.stringify(response.data.entry, null, 2)}`,
              },
            ],
          }
        } catch (error) {
          return {
            content: [
              {
                type: 'text',
                text: `Error retrieving entry: ${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