Skip to main content
Glama
imprvhub

mcp-claude-hackernews

hn_top

Fetch top-ranked stories from Hacker News. Control the number of stories to retrieve with a limit parameter between 1 and 50, defaulting to 10.

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

  • index.ts:162-176 (registration)
    Tool 'hn_top' is registered in the ListToolsRequestSchema handler with its name, description, and input schema.
    {
      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
          }
        }
      }
  • Input schema for hn_top: optional 'limit' number (1-50, default 10).
    inputSchema: {
      type: "object",
      properties: {
        limit: {
          type: "number",
          description: "Number of stories to fetch (1-50, default: 10)",
          minimum: 1,
          maximum: 50,
          default: 10
        }
      }
    }
  • Handler for 'hn_top' tool: calls api.getTopStories(limit), formats results, stores them in lastStoriesList, and returns text content.
    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)
          }
        ]
      };
    }
  • HackerNewsAPI.getTopStories() fetches top story IDs from /topstories.json, retrieves details, and filters for story type.
    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 [];
      }
    }
Behavior2/5

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

The description implies read-only behavior ('Get'), but lacks details about rate limits, authentication, or response structure. With no annotations, the description carries full burden and is insufficient.

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?

A single, clear sentence that is well front-loaded. Every word is necessary; no extraneous information.

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?

For a simple tool with one parameter and no output schema, the description covers the basic action. However, it could mention the return format (e.g., list of story IDs or details) to be fully 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 input schema already describes the 'limit' parameter with range and default (100% coverage). The description adds no new parameter meaning, so baseline 3 is appropriate.

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 clearly states the action ('Get') and resource ('top-ranked stories from Hacker News'), making the tool's purpose unmistakable. It distinguishes from siblings like 'hn_best' and 'hn_latest' by specifying 'top-ranked'.

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 usage guidance is provided. The description does not indicate when to use this tool over alternatives like 'hn_best' or 'hn_latest', nor does it mention prerequisites or context.

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