Skip to main content
Glama
imprvhub

mcp-claude-hackernews

hn_latest

Retrieve recent Hacker News stories. Specify a number (1-50) to control how many are returned.

Instructions

Get the latest/newest stories from Hacker News

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoNumber of stories to fetch (1-50, default: 10)

Implementation Reference

  • The handler function for the 'hn_latest' tool. Fetches latest/newest stories from Hacker News via the API, formats them, stores the result in lastStoriesList, and returns formatted text content.
    if (name === "hn_latest") {
      const limit = typeof args?.limit === 'number' ? args.limit : 10;
      const stories = await api.getLatestStories(limit);
      const formattedStories = stories.map(story => ({
        id: story.id,
        title: story.title,
        by: story.by,
        time: api.formatTime(story.time),
        url: story.url,
        score: story.score,
        commentsCount: story.kids?.length || 0
      }));
      lastStoriesList = formattedStories;
      return {
        content: [
          {
            type: "text",
            text: formatStoriesAsText(formattedStories)
          }
        ]
      };
    }
  • Registration of the 'hn_latest' tool with its name, description, and input schema. The schema defines an optional 'limit' parameter (number, 1-50, default 10).
    {
      name: "hn_latest",
      description: "Get the latest/newest stories from Hacker News",
      inputSchema: {
        type: "object",
        properties: {
          limit: {
            type: "number",
            description: "Number of stories to fetch (1-50, default: 10)",
            minimum: 1,
            maximum: 50,
            default: 10
          }
        }
      }
    },
  • index.ts:146-161 (registration)
    Tool registration via the ListToolsRequestSchema handler, listing 'hn_latest' as one of the available tools.
    {
      name: "hn_latest",
      description: "Get the latest/newest stories from Hacker News",
      inputSchema: {
        type: "object",
        properties: {
          limit: {
            type: "number",
            description: "Number of stories to fetch (1-50, default: 10)",
            minimum: 1,
            maximum: 50,
            default: 10
          }
        }
      }
    },
  • The getLatestStories() method on the HackerNewsAPI class that fetches story IDs from the /newstories.json endpoint, retrieves each story's details, and returns only story-type items.
    async getLatestStories(limit = 50): Promise<Story[]> {
      try {
        const response = await axios.get(`${baseUrl}/newstories.json`);
        const storyIds = response.data || [];
        const storyPromises = storyIds.slice(0, limit).map((id: number) => this.getItemDetails(id));
        const stories = await Promise.all(storyPromises);
        return stories.filter((story): story is Story => story !== null && story.type === 'story');
      } catch (error) {
        console.error('Error fetching latest stories:', error);
        return [];
      }
    }
  • The formatStoriesAsText() helper used by the hn_latest handler to format the list of stories into a readable text output.
    function formatStoriesAsText(stories: FormattedStory[]): string {
      if (!stories || stories.length === 0) {
        return "No stories found.";
      }
      
      return stories.map((story, index) => {
        return `${index + 1}. ${story.title}
       ID: ${story.id}
       By: ${story.by}
       Published: ${story.time}
       Score: ${story.score}
       Comments: ${story.commentsCount}
       URL: ${story.url || 'N/A'}
       ------------------------------`;
      }).join('\n\n');
    }
Behavior2/5

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

No annotations are provided, and the description does not disclose behavioral traits such as authentication requirements, rate limits, or any side effects. It only states the action without depth.

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 of 8 words, front-loading the core purpose without any redundant or unnecessary text.

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

Completeness3/5

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

Given the tool's simplicity and lack of output schema, the description minimally conveys purpose but omits return format or any usage context, making it adequate but not complete.

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 covers the sole parameter (limit) with full description, default, and range. The description adds no additional meaning beyond what the schema already provides.

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

Purpose5/5

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

The description specifies the verb 'Get' and resource 'latest/newest stories from Hacker News', clearly distinguishing it from sibling tools like hn_best and hn_top, which imply different sorting.

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?

No guidance is given on when to use this tool versus alternatives like hn_best or hn_top. The description lacks explicit context for 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

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