Skip to main content
Glama
imprvhub

mcp-claude-hackernews

hn_story

Fetch detailed information for a specific Hacker News story by providing its unique ID. Use this tool to quickly retrieve targeted story data from the Hacker News platform.

Instructions

Get details for a specific story by ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
story_idYesThe ID of the story to fetch

Implementation Reference

  • Executes the hn_story tool: validates story_id argument, fetches story details using HackerNewsAPI.getItemDetails, formats the story data, and returns formatted text response.
    if (name === "hn_story") {
      const storyId = typeof args?.story_id === 'number' ? args.story_id : NaN;
      if (isNaN(storyId)) {
        throw new Error('Story ID must be a number');
      }
      const story = await api.getItemDetails(storyId) as Story | null;
      if (!story) {
        throw new Error(`Story with ID ${storyId} not found`);
      }
      const formattedStory = {
        id: story.id,
        title: story.title,
        by: story.by,
        time: api.formatTime(story.time),
        url: story.url,
        text: story.text ? api.cleanText(story.text) : '',
        score: story.score,
        commentsCount: story.kids?.length || 0
      };
      return {
        content: [
          {
            type: "text",
            text: formatStoryAsText(formattedStory)
          }
        ]
      };
    }
  • index.ts:194-207 (registration)
    Registers the hn_story tool in the ListTools response, including name, description, and input schema requiring story_id.
    {
      name: "hn_story",
      description: "Get details for a specific story by ID",
      inputSchema: {
        type: "object",
        properties: {
          story_id: {
            type: "number",
            description: "The ID of the story to fetch"
          }
        },
        required: ["story_id"]
      }
    },
  • Formats the story details into a readable text string used by the hn_story handler.
    function formatStoryAsText(story: FormattedStory): string {
      if (!story) {
        return "Story not found.";
      }
      
      let result = `Title: ${story.title}
    ID: ${story.id}
    By: ${story.by}
    Published: ${story.time}
    Score: ${story.score}
    Comments: ${story.commentsCount}
    URL: ${story.url || 'N/A'}`;
    
      if (story.text) {
        result += `\n\nContent:\n${story.text}`;
      }
      
      return result;
    }
  • Fetches item details (story or comment) from Hacker News API by ID, used by hn_story handler.
    async getItemDetails(itemId: number): Promise<Story | Comment | null> {
      try {
        const response = await axios.get(`${baseUrl}/item/${itemId}.json`);
        return response.data;
      } catch (error) {
        console.error(`Error fetching item ${itemId}:`, error);
        return null;
      }
    }
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. It states the action ('Get details') but lacks information on permissions, rate limits, error handling, or response format. This is a significant gap for a tool with no annotation coverage.

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 front-loads the core purpose without any wasted words. It is appropriately sized for a simple tool with one parameter.

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 incomplete. It doesn't explain what 'details' include, potential errors, or how it differs from sibling tools, leaving gaps in understanding for effective tool 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 parameter 'story_id' fully documented in the schema. The description adds no additional meaning beyond what the schema provides, such as format examples or constraints, so it 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 verb ('Get details') and resource ('for a specific story by ID'), making the purpose immediately understandable. It doesn't explicitly differentiate from sibling tools like hn_best or hn_latest, which might fetch lists of stories rather than individual details, so it misses the highest score for sibling differentiation.

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 sibling tools like hn_best or hn_top, which might be used for different types of story retrieval, leaving the agent without context for tool selection.

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

Related 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/imprvhub/mcp-claude-hackernews'

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