Skip to main content
Glama
wei
by wei

Search HackerNews Posts by Date

search-posts-by-date

Find HackerNews posts by searching with keywords, filtering by tags and numeric criteria, and viewing results sorted by date.

Instructions

Search HackerNews posts sorted by date (most recent first)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
hitsPerPageNoNumber of results per page (default: 20)
numericFiltersNoNumeric filters (e.g., "points>100", "created_at_i>1672531200")
pageNoPage number for pagination (default: 0)
queryNoSearch query text (optional)
tagsNoFilter tags (e.g., "story", "comment", "poll", "show_hn", "ask_hn", "front_page", "author_USERNAME", "story_ID")

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
hitsYes
pageYes
nbHitsYes
nbPagesYes
hitsPerPageYes

Implementation Reference

  • The handler function that implements the core logic of the 'search-posts-by-date' tool. It builds URL parameters from inputs and calls the fetchHN helper to query the HackerNews Algolia API's /search_by_date endpoint.
    async ({ query, tags, numericFilters, page, hitsPerPage }) => {
      const params = new URLSearchParams();
      if (query) params.append('query', query);
      if (tags) params.append('tags', tags);
      if (numericFilters) params.append('numericFilters', numericFilters);
      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 'search-posts-by-date' tool using Zod, including optional parameters for query, tags, numeric filters, pagination.
    {
      title: 'Search HackerNews Posts by Date',
      description: 'Search HackerNews posts sorted by date (most recent first)',
      inputSchema: {
        query: z.string().optional().describe('Search query text (optional)'),
        tags: z.string().optional().describe('Filter tags (e.g., "story", "comment", "poll", "show_hn", "ask_hn", "front_page", "author_USERNAME", "story_ID")'),
        numericFilters: z.string().optional().describe('Numeric filters (e.g., "points>100", "created_at_i>1672531200")'),
        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:65-101 (registration)
    The server.registerTool call that registers the 'search-posts-by-date' tool with the MCP server, including its schema and handler function.
    server.registerTool(
      'search-posts-by-date',
      {
        title: 'Search HackerNews Posts by Date',
        description: 'Search HackerNews posts sorted by date (most recent first)',
        inputSchema: {
          query: z.string().optional().describe('Search query text (optional)'),
          tags: z.string().optional().describe('Filter tags (e.g., "story", "comment", "poll", "show_hn", "ask_hn", "front_page", "author_USERNAME", "story_ID")'),
          numericFilters: z.string().optional().describe('Numeric filters (e.g., "points>100", "created_at_i>1672531200")'),
          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 ({ query, tags, numericFilters, page, hitsPerPage }) => {
        const params = new URLSearchParams();
        if (query) params.append('query', query);
        if (tags) params.append('tags', tags);
        if (numericFilters) params.append('numericFilters', numericFilters);
        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
        };
      }
    );
  • Supporting helper function fetchHN used by the tool handler to perform HTTP requests 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();
    }
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 only mentions sorting behavior ('most recent first') but doesn't describe pagination behavior, rate limits, authentication requirements, error conditions, or what the output contains. For a search tool with 5 parameters, this is insufficient behavioral context.

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 communicates the core functionality without any wasted words. It's appropriately sized for a search tool and front-loads the essential information. Every word earns its place.

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 that there's an output schema (which handles return values), 100% schema description coverage, and no annotations, the description is reasonably complete for its purpose. It could be more complete by explaining the relationship to sibling tools and providing more behavioral context, but the combination of good schema documentation and output schema reduces the burden on the description.

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 no additional parameter information beyond what's in the schema. The baseline of 3 is appropriate when the schema does all the parameter documentation work, though the description could have provided context about how parameters interact.

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 ('search') and resource ('HackerNews posts'), and specifies the sorting method ('by date, most recent first'). It distinguishes from some siblings like 'get-top-stories' by emphasizing search functionality, but doesn't explicitly differentiate from 'search-posts' or 'search-by-time-range' which appear to be closely related alternatives.

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 'search-posts' or 'search-by-time-range'. It mentions sorting by date but doesn't explain if this is the primary use case or how it differs from other search tools. No explicit when/when-not statements or alternative recommendations are 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