Skip to main content
Glama
hillaryTse

HackerNews MCP Server

by hillaryTse

get_front_page

Retrieve current HackerNews front page posts to access trending discussions and news. Supports pagination to browse through all featured items.

Instructions

Retrieve current HackerNews front page posts. Returns the posts currently featured on the HN front page, ordered by rank. Supports pagination to browse through all front page items. Front page typically contains 30 posts per page (matches the HN website).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pageNo
hitsPerPageNo

Implementation Reference

  • The core handler function for the get_front_page tool. Validates input using GetFrontPageInputSchema, queries the HackerNews API search endpoint with tags='(front_page)' to fetch front page items, formats the paginated response including quota info, and returns it via formatToolResponse.
    export async function handleGetFrontPage(args: unknown) {
      // Validate input
      const parseResult = GetFrontPageInputSchema.safeParse(args);
    
      if (!parseResult.success) {
        throw new ValidationError("Invalid front page parameters", parseResult.error.errors);
      }
    
      const input: GetFrontPageInput = parseResult.data;
    
      // Search with front_page tag
      const result = await apiClient.search({
        tags: "(front_page)",
        page: input.page,
        hitsPerPage: input.hitsPerPage,
      });
    
      // Format response
      const response = {
        results: result.hits,
        pagination: {
          totalResults: result.nbHits,
          currentPage: result.page,
          totalPages: result.nbPages,
          resultsPerPage: result.hitsPerPage,
        },
        processingTimeMS: result.processingTimeMS,
        remainingQuota: apiClient.getRemainingQuota(),
      };
    
      return formatToolResponse(response);
    }
  • Zod schema defining the input for get_front_page tool: optional page (default 0) and hitsPerPage (default 30, max 30). Includes inferred TypeScript type.
    /**
     * Schema for get_front_page tool input
     */
    export const GetFrontPageInputSchema = z.object({
      page: z.number().int().nonnegative().optional().default(0),
      hitsPerPage: z.number().int().min(1).max(30).optional().default(30),
    });
    
    export type GetFrontPageInput = z.infer<typeof GetFrontPageInputSchema>;
  • Registers the get_front_page tool in the MCP tools list, providing name, description, and input JSON schema derived from Zod schema.
    {
      name: "get_front_page",
      description:
        "Retrieve current HackerNews front page posts. Returns the posts currently featured on the HN front page, ordered by rank. Supports pagination to browse through all front page items. Front page typically contains 30 posts per page (matches the HN website).",
      inputSchema: zodToJsonSchema(GetFrontPageInputSchema),
    },
  • src/index.ts:55-57 (registration)
    In the main MCP server tool call handler, dispatches calls to 'get_front_page' to the specific handleGetFrontPage function.
    case "get_front_page":
      return await handleGetFrontPage(args);
  • TypeScript interface defining the input shape for get_front_page tool, matching the Zod schema.
    /**
     * Tool input for get_front_page
     */
    export interface GetFrontPageInput {
      page?: number;
      hitsPerPage?: number;
    }
Behavior4/5

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

With no annotations provided, the description carries full burden and does well by disclosing key behavioral traits: it's a read operation (implied by 'Retrieve'), supports pagination, specifies the typical page size ('30 posts per page'), and mentions ordering ('ordered by rank'). It doesn't cover rate limits, authentication needs, or error conditions, but provides substantial operational 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 perfectly front-loaded with the core purpose in the first sentence, followed by supporting details about ordering, pagination, and page size. Every sentence adds value with zero wasted words, making it highly efficient and easy to parse.

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 moderate complexity (2 parameters, no output schema, no annotations), the description provides good coverage of what the tool does, how it behaves, and parameter context. The main gap is the lack of output format details (what fields posts contain, structure of return data), which would be needed for full completeness since there's no output schema.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage for the 2 parameters, the description must compensate. It explains the pagination concept ('Supports pagination to browse through all front page items') and mentions the default page size ('Front page typically contains 30 posts per page'), which helps interpret the 'page' and 'hitsPerPage' parameters. However, it doesn't explicitly map these terms to the parameter names or explain the 'page' numbering starting at 0.

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 specific action ('Retrieve current HackerNews front page posts'), resource ('HN front page posts'), and distinguishes it from siblings by focusing on the front page rather than individual posts, users, or search results. It provides concrete details about what gets returned ('posts currently featured on the HN front page, ordered by rank').

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

Usage Guidelines4/5

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

The description provides clear context for when to use this tool ('to browse through all front page items') and implies usage through the mention of pagination. However, it doesn't explicitly state when NOT to use it or name alternatives like 'get_post' for individual posts or 'search_posts' for filtered searches, which would be needed for a perfect score.

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

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