Skip to main content
Glama

get-entries

Retrieve content entries from Contentful CMS by specifying a content type to access structured data for your projects.

Instructions

Get entries for a specific content type

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentTypeYes

Implementation Reference

  • The handler function for the 'get-entries' tool. It takes a contentType parameter, constructs the Contentful API endpoint to fetch entries (limited to 10), fetches the data, and returns it as JSON-formatted text or an error message.
    async (parameters) => { const { contentType } = parameters; const entriesEndpoint = `https://cdn.contentful.com/spaces/${CONTENTFUL_SPACE_ID}/environments/${CONTENTFUL_ENVIRONMENT}/entries?content_type=${contentType}&limit=10`; try { const response = await fetch(entriesEndpoint, { headers: { Authorization: `Bearer ${CONTENTFUL_ACCESS_TOKEN}`, }, }); if (!response.ok) { throw new Error(`HTTP error! Status: ${response.status}`); } const data = await response.json(); return { content: [ { type: "text", text: JSON.stringify(data, null, 2), }, ], }; } catch (error: any) { console.error("Error fetching entries:", error); return { content: [ { type: "text", text: `Error: ${error.message}`, }, ], }; } }
  • Input schema for the 'get-entries' tool, defining 'contentType' as a required string parameter using Zod.
    { contentType: z.string(), },
  • src/index.ts:78-121 (registration)
    Registration of the 'get-entries' tool on the MCP server, specifying name, description, input schema, and handler function.
    server.tool( "get-entries", "Get entries for a specific content type", { contentType: z.string(), }, async (parameters) => { const { contentType } = parameters; const entriesEndpoint = `https://cdn.contentful.com/spaces/${CONTENTFUL_SPACE_ID}/environments/${CONTENTFUL_ENVIRONMENT}/entries?content_type=${contentType}&limit=10`; try { const response = await fetch(entriesEndpoint, { headers: { Authorization: `Bearer ${CONTENTFUL_ACCESS_TOKEN}`, }, }); if (!response.ok) { throw new Error(`HTTP error! Status: ${response.status}`); } const data = await response.json(); return { content: [ { type: "text", text: JSON.stringify(data, null, 2), }, ], }; } catch (error: any) { console.error("Error fetching entries:", error); return { content: [ { type: "text", text: `Error: ${error.message}`, }, ], }; } } );

Other Tools

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/tejedamiguel6/MCP-server-Contenful'

If you have feedback or need assistance with the MCP directory API, please join our Discord server