Skip to main content
Glama

contentful-mcp

summarizer.ts1.28 kB
/* eslint-disable @typescript-eslint/no-explicit-any */ export interface SummarizeOptions { maxItems?: number indent?: number showTotal?: boolean remainingMessage?: string } export const summarizeData = (data: any, options: SummarizeOptions = {}): any => { const { maxItems = 3, remainingMessage = "To see more items, please ask me to retrieve the next page." } = options // Handle Contentful-style responses with items and total if (data && typeof data === "object" && "items" in data && "total" in data) { const items = data.items const total = data.total if (items.length <= maxItems) { return data } return { items: items.slice(0, maxItems), total: total, showing: maxItems, remaining: total - maxItems, message: remainingMessage, skip: maxItems // Add skip value for next page } } // Handle plain arrays if (Array.isArray(data)) { if (data.length <= maxItems) { return data } return { items: data.slice(0, maxItems), total: data.length, showing: maxItems, remaining: data.length - maxItems, message: remainingMessage, skip: maxItems // Add skip value for next page } } // Return non-array data as-is return data }

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/ivo-toby/contentful-mcp'

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