Skip to main content
Glama
devabdultech

Hacker News MCP Server

getStory

Retrieve a specific Hacker News story by its unique ID to access content, comments, and details through the Model Context Protocol.

Instructions

Get a single story by ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesThe ID of the story

Implementation Reference

  • Main handler logic for the 'getStory' tool: fetches story data using hnApi.getItem, formats it with formatStory, constructs a textual response.
    case "getStory": {
      const { id } = args as { id: number };
      const item = await hnApi.getItem(id);
      if (!item || item.type !== "story") {
        throw new McpError(
          ErrorCode.InvalidParams,
          `Story with ID ${id} not found`
        );
      }
      const story = formatStory(item);
      const text =
        `Story ID: ${story.id}\n` +
        `Title: ${story.title}\n` +
        `URL: ${story.url || "(text post)"}\n` +
        `Points: ${story.score} | Author: ${story.by} | Comments: ${story.descendants}\n` +
        (story.text ? `\nContent:\n${story.text}\n` : "");
    
      return {
        content: [{ type: "text", text: text.trim() }],
      };
    }
  • src/index.ts:69-79 (registration)
    Tool registration in ListTools handler, defining name, description, and input schema for 'getStory'.
    {
      name: "getStory",
      description: "Get a single story by ID",
      inputSchema: {
        type: "object",
        properties: {
          id: { type: "number", description: "The ID of the story" },
        },
        required: ["id"],
      },
    },
  • hnApi.getItem method: fetches a single Hacker News item by ID from the official Firebase API.
    async getItem(id: number): Promise<any> {
      const response = await fetch(`${API_BASE_URL}/item/${id}.json`);
      return response.json();
    }
  • formatStory function: transforms raw HN item data into a structured Story object used in the handler.
    export function formatStory(item: any): Story {
      return {
        id: item.id,
        title: item.title,
        url: item.url,
        text: item.text,
        by: item.by,
        score: item.score || 0,
        time: item.time,
        descendants: item.descendants || 0,
        kids: item.kids || [],
        type: "story",
      };
    }
  • Input schema definition for the 'getStory' tool, specifying the required 'id' parameter.
    inputSchema: {
      type: "object",
      properties: {
        id: { type: "number", description: "The ID of the story" },
      },
      required: ["id"],
    },
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. While 'Get' implies a read operation, it doesn't specify whether this requires authentication, has rate limits, returns structured data, or handles errors. For a tool with zero annotation coverage, this leaves significant behavioral gaps unaddressed.

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 perfectly concise at just five words, front-loading the essential information with zero wasted words. Every element ('Get', 'single story', 'by ID') earns its place in communicating the core functionality efficiently.

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 lack of annotations and output schema, the description is insufficiently complete. It doesn't explain what format the story returns in, whether it includes metadata, how errors are handled, or any behavioral constraints. For a data retrieval tool with no structured output documentation, more contextual information is needed.

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 single parameter 'id' clearly documented as 'The ID of the story'. The description adds no additional parameter semantics beyond what the schema already provides, so the baseline score of 3 is appropriate when the schema does the heavy lifting.

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 story by ID'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'getStoryWithComments' or 'getStories', 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 'getStoryWithComments' or 'getStories'. There's no mention of prerequisites, context, or comparative use cases, leaving the agent with insufficient information to make optimal tool selection decisions.

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