Skip to main content
Glama
paabloLC

MCP Hacker News

by paabloLC

getComments

Fetch comments for Hacker News items to analyze discussions and community feedback on posts, supporting threaded conversations with configurable depth.

Instructions

Get comments for a specific item

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesThe item ID to fetch comments for
depthNoMaximum depth of comments to fetch (default: 2)

Implementation Reference

  • The main handler (execute) function for the 'getComments' tool. Fetches the item by ID, retrieves its top-level comments (kids), fetches up to 20 comments, formats them with metadata, and returns a JSON response.
    execute: async (args: any) => {
      const item = await fetchFromAPI<HackerNewsItem>(`/item/${args.id}`);
    
      if (!item || !item.kids) {
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify({ error: "No comments found" }),
            },
          ],
        };
      }
    
      const depth = Math.min(args.depth || 2, 3);
      const comments = await fetchMultipleItems(item.kids, 20);
    
      const formattedComments = comments.map((comment) => ({
        id: comment.id,
        author: comment.by,
        time: comment.time ? formatTime(comment.time) : "unknown",
        text: comment.text,
        parent: comment.parent,
        kids: comment.kids?.length || 0,
        hnUrl: `https://news.ycombinator.com/item?id=${comment.id}`,
      }));
    
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(
              {
                message: `Comments for item ${args.id}`,
                totalComments: item.descendants || 0,
                topLevelComments: formattedComments.length,
                comments: formattedComments,
              },
              null,
              2
            ),
          },
        ],
      };
    },
  • Input schema defining the parameters for the 'getComments' tool: required 'id' (number) and optional 'depth' (number, default 2).
    inputSchema: {
      type: "object",
      properties: {
        id: {
          type: "number",
          description: "The item ID to fetch comments for",
        },
        depth: {
          type: "number",
          description: "Maximum depth of comments to fetch (default: 2)",
          default: 2,
        },
      },
      required: ["id"],
    },
  • src/index.ts:52-65 (registration)
    MCP server registration for tool calls: looks up tool by name from the imported tools array (which includes getComments) and invokes its execute function.
    if (json.method === "tools/call") {
      const tool = tools.find((tool) => tool.name === json.params.name);
      if (tool) {
        const toolResponse = await tool.execute(json.params.arguments);
        sendResponse(json.id, toolResponse);
      } else {
        sendResponse(json.id, {
          error: {
            code: -32602,
            message: `MCP error -32602: Tool ${json.params.name} not found`,
          },
        });
      }
    }
  • src/index.ts:43-50 (registration)
    MCP server lists available tools, including getComments with name, description, and schema.
    if (json.method === "tools/list") {
      sendResponse(json.id, {
        tools: tools.map((tool) => ({
          name: tool.name,
          description: tool.description,
          inputSchema: tool.inputSchema,
        })),
      });
  • Uses helper fetchMultipleItems to fetch comment details (imported from fetch-actions.ts).
    const comments = await fetchMultipleItems(item.kids, 20);
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool 'Get comments' but doesn't describe what the return format looks like, whether it's paginated, if there are rate limits, or any error conditions. For a read operation with no annotation coverage, this leaves significant gaps in understanding how the tool behaves beyond its basic purpose.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, clear sentence that efficiently conveys the tool's purpose without any wasted words. It's front-loaded with the essential information and appropriately sized for a simple retrieval tool. Every word earns its place by directly contributing to understanding what the tool does.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (2 parameters, no output schema, no annotations), the description is incomplete. It lacks information about return values, error handling, or behavioral traits like pagination or rate limits. While the purpose is clear, the description doesn't provide enough context for an agent to fully understand how to use the tool effectively in practice.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the input schema already documents both parameters ('id' and 'depth') with clear descriptions. The tool description adds no additional meaning beyond what the schema provides, such as explaining what 'depth' means in the context of comments or providing examples. With high schema coverage, the baseline score of 3 is appropriate as the description doesn't compensate but also doesn't detract.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Get') and resource ('comments for a specific item'), making the purpose immediately understandable. However, it doesn't differentiate this tool from potential sibling tools that might also retrieve comments, though none are listed among the provided siblings. The description avoids tautology by specifying what is being retrieved rather than just restating the tool name.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention any prerequisites, context for usage, or comparisons with sibling tools like 'getItem' that might also provide comment-related data. The agent is left to infer usage based on the tool name and parameters alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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/paabloLC/mcp-hacker-news'

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