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
| Name | Required | Description | Default |
|---|---|---|---|
| content_type_uid | Yes | Content type UID | |
| entry_uid | Yes | Entry UID to retrieve | |
| include_reference_content_type_uid | No | Include content type UIDs in references | |
| include_references | No | References to include | |
| locale | No | Locale code (e.g., 'en-us') |
Implementation Reference
- src/index.ts:864-903 (handler)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, } }
- src/index.ts:853-863 (schema)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, } } }, )