Skip to main content
Glama

get comments

Retrieve user comments from TabNews content by specifying the username and slug parameters to analyze discussions and feedback.

Instructions

get comments from a content on tabnews api

Input Schema

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

Implementation Reference

  • The handler function for the 'get comments' tool. It fetches comments using the getContentChildren service and returns a formatted MCP text response with JSON data.
    handler: async (params: GetContentParams): Promise<McpResponse> => {
      try {
        const result = await getContentChildren({
          username: params.username,
          slug: params.slug,
        });
    
        const content: McpTextContent = {
          type: "text",
          text: `Comments:\n\n${JSON.stringify(result, null, 2)}`,
        };
    
        return {
          content: [content],
        };
      } catch (error) {
        if (error instanceof Error) {
          throw new Error(`Failed to get comments: ${error.message}`);
        } else {
          throw new Error("Failed to get comments");
        }
      }
    },
  • Zod schema defining the input parameters for the 'get comments' tool: 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:52-57 (registration)
    Registration of the 'get comments' tool (imported as getContentChildrenTool) with the MCP server using server.tool().
    server.tool(
      getContentChildrenTool.name,
      getContentChildrenTool.description,
      getContentChildrenTool.parameters,
      getContentChildrenTool.handler
    );
  • Supporting API service function that fetches the comments (children) from the TabNews API endpoint.
    export async function getContentChildren({
      username,
      slug,
    }: GetContentParams): Promise<TabNewsContentChildren[]> {
      const response = await fetch(
        `${TABNEWS_API_URL}/contents/${username}/${slug}/children`
      );
      const data = await response.json();
    
      return data as TabNewsContentChildren[];
    }

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