Skip to main content
Glama

get contents

Retrieve TabNews API contents by specifying page number, items per page, and sorting strategy (relevant, new, or old). Streamlines content access for integration projects.

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

  • The handler function that executes the logic for the "get contents" tool. It fetches contents via the API service and returns formatted JSON as MCP text content.
    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 for input parameters of the "get contents" tool: optional page, per_page, and strategy (relevant/new/old).
    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"), },
  • src/index.ts:31-36 (registration)
    Registration of the "get contents" tool with the MCP server by calling server.tool() with name, description, parameters, and handler.
    server.tool( getContentsTool.name, getContentsTool.description, getContentsTool.parameters, getContentsTool.handler );
  • Helper function getContents that performs the actual API fetch to TabNews /contents endpoint with pagination and strategy parameters.
    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[]; }
  • TypeScript interface defining the input parameters for getContents, used in the tool handler and API service.
    export interface GetContentsParams { page?: number; per_page?: number; strategy?: ContentStrategy; }

Other Tools

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

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