Skip to main content
Glama

get content

Retrieve content from TabNews API by providing a username and slug, enabling integration with MCP TabNews for streamlined data fetching and analysis.

Instructions

get content from tabnews api

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
slugYesThe slug to get the content
usernameYesThe username to get the content

Implementation Reference

  • The handler function for the 'get content' tool. It fetches content using the service, formats it as MCP text content with JSON, and handles errors.
    handler: async (params: GetContentParams): Promise<McpResponse> => { try { const result = await getContent({ username: params.username, slug: params.slug, }); const content: McpTextContent = { type: "text", text: `Content ${params.slug} from ${ params.username }:\n\n${JSON.stringify(result, null, 2)}`, }; return { content: [content], }; } catch (error) { if (error instanceof Error) { throw new Error(`Failed to get content: ${error.message}`); } else { throw new Error("Failed to get content"); } } },
  • Zod input schema defining required string parameters: username and slug.
    parameters: { username: z.string().describe("The username to get the content"), slug: z.string().describe("The slug to get the content"), },
  • src/index.ts:45-50 (registration)
    MCP server registration of the 'get content' tool using server.tool() with its properties.
    server.tool( getContentTool.name, getContentTool.description, getContentTool.parameters, getContentTool.handler );
  • Supporting API service function that performs the HTTP fetch to retrieve content from TabNews API.
    export async function getContent({ username, slug, }: GetContentParams): Promise<TabNewsContentWithBody> { const response = await fetch( `${TABNEWS_API_URL}/contents/${username}/${slug}` ); const data = await response.json(); return data as TabNewsContentWithBody; }

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