Skip to main content
Glama
devabdultech

Hacker News MCP Server

getComment

Retrieve specific Hacker News comments by ID to analyze discussions, verify information, or reference user contributions within the platform.

Instructions

Get a single comment by ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesThe ID of the comment

Implementation Reference

  • Main execution logic for the getComment tool: validates input, fetches the comment from HN API, formats it, and returns formatted text response.
    case "getComment": {
      const validatedArgs = validateInput(CommentRequestSchema, args);
      const { id } = validatedArgs;
      const item = await hnApi.getItem(id);
      if (!item || item.type !== "comment") {
        throw new McpError(
          ErrorCode.InvalidParams,
          `Comment with ID ${id} not found`
        );
      }
      const comment = formatComment(item);
      const text =
        `Comment ID: ${comment.id}\n` +
        `Comment by ${comment.by}:\n` +
        `${comment.text}\n` +
        `Parent ID: ${comment.parent}\n`;
    
      return {
        content: [{ type: "text", text: text.trim() }],
      };
    }
  • src/index.ts:113-122 (registration)
    Tool registration in ListTools handler, defining name, description, and input schema.
      name: "getComment",
      description: "Get a single comment by ID",
      inputSchema: {
        type: "object",
        properties: {
          id: { type: "number", description: "The ID of the comment" },
        },
        required: ["id"],
      },
    },
  • Zod validation schema for getComment input, ensuring id is a positive integer.
    export const CommentRequestSchema = z.object({
      id: z.number().int().positive(),
    });
  • Helper function to format raw HN item data into a structured Comment object, used in the getComment handler.
    export function formatComment(item: any): Comment {
      return {
        id: item.id,
        text: item.text || "",
        by: item.by || "deleted",
        time: item.time,
        parent: item.parent,
        kids: item.kids || [],
        type: "comment",
      };
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure but offers minimal information. It doesn't specify whether this is a read-only operation, what happens if the ID doesn't exist, authentication requirements, rate limits, or return format. While 'Get' implies retrieval, critical behavioral traits are undocumented.

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, efficient sentence that directly states the tool's purpose without unnecessary words. It's appropriately sized for a simple retrieval tool and front-loads the essential information, making it easy for an agent to parse quickly.

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?

For a tool with no annotations and no output schema, the description is insufficiently complete. It lacks details on error handling, return values, authentication, and how it differs from sibling tools. Given the context of multiple sibling retrieval tools, more differentiation and behavioral context are needed for effective agent use.

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?

The schema description coverage is 100%, with the 'id' parameter fully documented in the schema. The description adds no additional semantic context beyond implying the ID is used to retrieve a specific comment, which the schema already covers. This meets the baseline for high schema coverage.

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 ('a single comment by ID'), making the purpose immediately understandable. However, it doesn't differentiate this tool from sibling tools like 'getComments' or 'getCommentTree', which would require more specific scope information to earn a perfect score.

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 like 'getComments' (for multiple comments) or 'getCommentTree' (for hierarchical comments). There's no mention of prerequisites, error conditions, or typical use cases, leaving the agent with minimal contextual direction.

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/devabdultech/hn-mcp'

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