Skip to main content
Glama

get contents

Retrieve content from TabNews API using pagination and sorting strategies to access articles, posts, or discussions.

Instructions

get contents from tabnews api

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pageNoThe page number to get
per_pageNoThe number of contents per page
strategyNoThe strategy to get the contents

Implementation Reference

  • src/index.ts:31-36 (registration)
    Registration of the "get contents" tool on the MCP server by calling server.tool() with the tool's properties.
    server.tool( getContentsTool.name, getContentsTool.description, getContentsTool.parameters, getContentsTool.handler );
  • The handler function that executes the "get contents" tool logic: fetches data using getContents API helper, formats as JSON text response, handles errors.
    handler: async (params: GetContentsParams): Promise<McpResponse> => { try { const result = await getContents({ page: params.page, per_page: params.per_page, strategy: params.strategy, }); const content: McpTextContent = { type: "text", text: `Contents:\n\n${JSON.stringify(result, null, 2)}`, }; return { content: [content], }; } catch (error) { if (error instanceof Error) { throw new Error(`Failed to get contents: ${error.message}`); } else { throw new Error("Failed to get contents"); } } },
  • Zod schema defining input parameters for the "get contents" tool: page, per_page, strategy.
    parameters: { page: z.number().optional().describe("The page number to get"), per_page: z.number().optional().describe("The number of contents per page"), strategy: z .enum(["relevant", "new", "old"]) .optional() .describe("The strategy to get the contents"), },
  • Helper function getContents that performs the actual API fetch to TabNews /contents endpoint, used by the tool handler.
    export async function getContents({ page = 1, per_page = 30, strategy = "relevant", }: GetContentsParams = {}): Promise<TabNewsContent[]> { const queryParams = new URLSearchParams({ page: page.toString(), per_page: per_page.toString(), strategy: strategy, }); const response = await fetch(`${TABNEWS_API_URL}/contents?${queryParams}`); const data = await response.json(); return data as TabNewsContent[]; }

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/renant/mcp-tabnews'

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