Skip to main content
Glama
wei
by wei

Get HackerNews Polls

get-polls

Retrieve recent polls from HackerNews to analyze community opinions and discussions. Supports pagination for browsing through multiple pages of poll results.

Instructions

Get latest polls posted to HackerNews

Input Schema

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

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
hitsYes
pageYes
nbHitsYes
nbPagesYes
hitsPerPageYes

Implementation Reference

  • Handler function that fetches the latest HackerNews polls using the Algolia API, filtered by the 'poll' tag, with optional pagination parameters.
    async ({ page, hitsPerPage }) => {
      const params = new URLSearchParams();
      params.append('tags', 'poll');
      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
      };
    }
  • Input and output schema definitions for the 'get-polls' tool using Zod validation.
    {
      title: 'Get HackerNews Polls',
      description: 'Get latest polls posted to HackerNews',
      inputSchema: {
        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:442-472 (registration)
    Registration of the 'get-polls' tool on the MCP server using server.registerTool.
      'get-polls',
      {
        title: 'Get HackerNews Polls',
        description: 'Get latest polls posted to HackerNews',
        inputSchema: {
          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 ({ page, hitsPerPage }) => {
        const params = new URLSearchParams();
        params.append('tags', 'poll');
        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 'get-polls' (and other tools) to make API calls to the HackerNews Algolia API.
    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();
    }
  • Base URL constant for HackerNews Algolia API used in fetchHN helper.
    // HackerNews API base URL
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 'latest polls' but doesn't specify sorting order, rate limits, authentication needs, or what 'latest' means (e.g., time window). For a read operation with zero annotation coverage, this leaves significant gaps in understanding how the tool behaves.

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 and front-loaded, making it easy to parse quickly.

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

Completeness4/5

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

Given the tool's low complexity (a simple read operation), 100% schema coverage, and the presence of an output schema (which handles return values), the description is reasonably complete. However, the lack of behavioral details (e.g., sorting, rate limits) and usage guidelines relative to siblings slightly reduces completeness.

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 the input schema fully documents both parameters (hitsPerPage and page) with descriptions and defaults. The description doesn't add any parameter-specific information beyond what's in the schema, meeting 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') and resource ('latest polls posted to HackerNews'), making the purpose immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'get-top-stories' or 'get-latest-stories' in terms of content type, though 'polls' is a specific HackerNews feature.

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 'get-top-stories' or 'search-posts', nor does it mention any prerequisites or constraints. It simply states what the tool does without contextual usage information.

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