Skip to main content
Glama
wei
by wei

Get Top Stories by Points

get-top-stories

Retrieve HackerNews stories that meet a minimum point threshold, sorted by publication date. Filter content by score and browse results with pagination controls.

Instructions

Get stories with a minimum number of points, sorted by date

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
hitsPerPageNoNumber of results per page (default: 20)
minPointsNoMinimum number of points (default: 100)
pageNoPage number for pagination (default: 0)

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
hitsYes
pageYes
nbHitsYes
nbPagesYes
hitsPerPageYes

Implementation Reference

  • The handler function for the 'get-top-stories' tool. It constructs a query for stories with at least the specified minimum points using the HackerNews Algolia API's search_by_date endpoint, fetches the data, and returns both text and structured content.
    async ({ minPoints = 100, page, hitsPerPage }) => {
      const params = new URLSearchParams();
      params.append('tags', 'story');
      params.append('numericFilters', `points>=${minPoints}`);
      if (page !== undefined) params.append('page', page.toString());
      if (hitsPerPage !== undefined) params.append('hitsPerPage', hitsPerPage.toString());
      
      const endpoint = `/search_by_date?${params.toString()}`;
      const result = await fetchHN(endpoint);
      
      return {
        content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
        structuredContent: result
      };
    }
  • The input and output schema definitions for the 'get-top-stories' tool, using Zod for validation. Input includes optional minPoints (default 100), page, and hitsPerPage. Output matches the HN API search response structure.
    {
      title: 'Get Top Stories by Points',
      description: 'Get stories with a minimum number of points, sorted by date',
      inputSchema: {
        minPoints: z.number().optional().default(100).describe('Minimum number of points (default: 100)'),
        page: z.number().optional().describe('Page number for pagination (default: 0)'),
        hitsPerPage: z.number().optional().describe('Number of results per page (default: 20)')
      },
      outputSchema: {
        hits: z.array(z.any()),
        nbHits: z.number(),
        nbPages: z.number(),
        page: z.number(),
        hitsPerPage: z.number()
      }
    },
  • src/index.ts:515-548 (registration)
    The registration of the 'get-top-stories' tool on the MCP server, including name, metadata/schema, and handler function.
    server.registerTool(
      'get-top-stories',
      {
        title: 'Get Top Stories by Points',
        description: 'Get stories with a minimum number of points, sorted by date',
        inputSchema: {
          minPoints: z.number().optional().default(100).describe('Minimum number of points (default: 100)'),
          page: z.number().optional().describe('Page number for pagination (default: 0)'),
          hitsPerPage: z.number().optional().describe('Number of results per page (default: 20)')
        },
        outputSchema: {
          hits: z.array(z.any()),
          nbHits: z.number(),
          nbPages: z.number(),
          page: z.number(),
          hitsPerPage: z.number()
        }
      },
      async ({ minPoints = 100, page, hitsPerPage }) => {
        const params = new URLSearchParams();
        params.append('tags', 'story');
        params.append('numericFilters', `points>=${minPoints}`);
        if (page !== undefined) params.append('page', page.toString());
        if (hitsPerPage !== undefined) params.append('hitsPerPage', hitsPerPage.toString());
        
        const endpoint = `/search_by_date?${params.toString()}`;
        const result = await fetchHN(endpoint);
        
        return {
          content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
          structuredContent: result
        };
      }
    );
  • Shared helper function used by all HackerNews tools, including 'get-top-stories', to make API calls to the HN Algolia API and handle errors.
    async function fetchHN(endpoint: string): Promise<any> {
      const response = await fetch(`${HN_API_BASE}${endpoint}`);
      if (!response.ok) {
        throw new Error(`HN API error: ${response.status} ${response.statusText}`);
      }
      return await response.json();
    }
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 mentions sorting by date and points filtering, but doesn't describe pagination behavior, rate limits, authentication needs, or what happens with invalid parameters. For a tool with 3 parameters and no annotations, this leaves significant gaps in understanding its operational 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 wasted words. It's appropriately sized for this type of filtering tool and front-loads the key 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?

Given the tool has an output schema (which handles return values) and 100% schema description coverage, the description is minimally adequate. However, for a tool with 3 parameters and no annotations, it should provide more behavioral context about how the tool actually operates beyond just stating the filtering criteria.

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%, so all parameters are documented in the schema. The description adds minimal value beyond the schema by implying that 'minPoints' is the primary filter and results are date-sorted, but doesn't provide additional context about parameter interactions or constraints.

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') and resource ('stories') with specific filtering criteria ('with a minimum number of points, sorted by date'). It distinguishes from siblings like 'get-latest-stories' by emphasizing the points-based filtering rather than recency, but doesn't explicitly name alternatives for point-based queries.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage when stories need to be filtered by points and sorted by date, but doesn't explicitly state when to use this tool versus alternatives like 'get-front-page' or 'search-posts'. No guidance on prerequisites or exclusions is provided.

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/wei/hn-mcp-server-vibe'

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