Skip to main content
Glama
imprvhub

mcp-claude-hackernews

hn_top

Fetch the top-ranked stories from Hacker News with customizable limits, ensuring you stay updated on trending tech and development topics efficiently.

Instructions

Get the top-ranked stories from Hacker News

Input Schema

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

Implementation Reference

  • Handler logic for the 'hn_top' tool: parses limit argument, fetches top stories via HackerNewsAPI, formats them, stores in lastStoriesList, and returns formatted text response.
    if (name === "hn_top") {
      const limit = typeof args?.limit === 'number' ? args.limit : 10;
      const stories = await api.getTopStories(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)
          }
        ]
      };
  • Input schema and metadata registration for the 'hn_top' tool within the listTools response.
    {
      name: "hn_top",
      description: "Get the top-ranked 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
          }
        }
      }
    },
  • Core helper method in HackerNewsAPI that fetches top story IDs from HN API and resolves full story details.
    async getTopStories(limit = 50): Promise<Story[]> {
      try {
        const response = await axios.get(`${baseUrl}/topstories.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 top stories:', error);
        return [];
      }
    }
  • Helper function to format the list of stories into a numbered, 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?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool fetches stories but doesn't mention whether this is a read-only operation, potential rate limits, authentication needs, or what the output format looks like (e.g., list of stories with titles, scores, URLs). This leaves significant gaps in understanding the tool's behavior.

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 any unnecessary words. It is front-loaded and wastes no space, 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?

Given the lack of annotations and output schema, the description is incomplete. It doesn't explain what 'top-ranked' means, how stories are ranked, what data is returned, or any error conditions. For a tool with siblings offering similar functionality, more context is needed to differentiate and use it effectively.

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 input schema has 100% description coverage, fully documenting the 'limit' parameter with its range and default. The description adds no additional parameter information beyond what the schema provides, such as clarifying what 'top-ranked' entails or other implicit filters. 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 ('top-ranked stories from Hacker News'), making the purpose immediately understandable. However, it doesn't distinguish this tool from its siblings like 'hn_best' or 'hn_latest', which likely serve similar purposes with different ranking criteria.

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 'hn_best' or 'hn_latest'. It lacks any context about what 'top-ranked' means (e.g., by score, time, or other metrics) or prerequisites for usage, leaving the agent to infer usage scenarios.

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