Skip to main content
Glama
wei

HackerNews MCP Server

by wei

get-front-page

Retrieve trending posts from the HackerNews front page with pagination support to browse popular stories efficiently.

Instructions

Retrieve posts currently on the HackerNews front page.

Returns stories sorted by HackerNews ranking algorithm. The front page typically contains the most popular and trending stories.

Supports:

  • Pagination to view beyond the first page

  • Customizable results per page (default: 30)

  • All posts are tagged with 'front_page'

Examples:

  • Get first page: { }

  • Get with custom page size: { "hitsPerPage": 50 }

  • Get second page: { "page": 1 }

Returns the same structure as search results with hits, pagination info, and metadata.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pageNoPage number (0-indexed, default: 0)
hitsPerPageNoResults per page (1-1000, default: 30)

Implementation Reference

  • The primary handler function that executes the 'get-front-page' tool: validates input parameters, queries the HackerNews search API filtered by 'front_page' tag, validates the response, and returns a formatted MCP tool result or handles errors.
    export async function getFrontPageHandler(input: unknown): Promise<CallToolResult> {
    	try {
    		// Validate input
    		const validatedParams = GetFrontPageInputSchema.parse(input);
    
    		// Create API client
    		const client = new HNAPIClient();
    
    		// Call search API with front_page tag
    		const result = await client.search({
    			query: "",
    			tags: ["front_page"],
    			page: validatedParams.page,
    			hitsPerPage: validatedParams.hitsPerPage,
    		});
    
    		// Validate output
    		const validatedResult = GetFrontPageOutputSchema.parse(result);
    
    		return createSuccessResult(validatedResult);
    	} catch (error) {
    		return handleAPIError(error, "get-front-page");
    	}
    }
  • Zod schema for validating the input parameters to the 'get-front-page' tool (page and hitsPerPage).
    export const GetFrontPageInputSchema = z.object({
    	page: z.number().int().nonnegative().default(0).describe("Page number (0-indexed)"),
    	hitsPerPage: z.number().int().min(1).max(1000).default(30).describe("Results per page (1-1000)"),
    });
  • Zod schema for validating the output/response from the HackerNews API for the 'get-front-page' tool.
    export const GetFrontPageOutputSchema = z.object({
    	hits: z.array(z.any()),
    	nbHits: z.number().int().nonnegative(),
    	page: z.number().int().nonnegative(),
    	nbPages: z.number().int().positive(),
    	hitsPerPage: z.number().int().positive(),
    	processingTimeMS: z.number().nonnegative(),
    	query: z.string(),
    	params: z.string().min(1),
    });
  • src/index.ts:69-70 (registration)
    Registration of the 'get-front-page' tool handler in the MCP server's CallToolRequestHandler switch statement, dispatching calls to getFrontPageHandler.
    case "get-front-page":
    	return await getFrontPageHandler(args);
  • src/index.ts:47-53 (registration)
    Registration of the 'get-front-page' tool metadata (getFrontPageTool) in the MCP server's ListToolsRequestHandler tools list.
    tools: [
    	searchPostsToolMetadata,
    	getFrontPageTool,
    	getLatestPostsTool,
    	getItemTool,
    	getUserTool,
    ],
Behavior4/5

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

With no annotations provided, the description carries the full burden and does well by disclosing key behavioral traits: it describes the sorting algorithm (HackerNews ranking), typical content (most popular/trending stories), pagination support, default and customizable results per page, and return structure. It lacks details on rate limits or error handling, but covers essential operational aspects.

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 appropriately sized and front-loaded, starting with the core purpose, followed by supporting details, examples, and return information. Every sentence adds value without redundancy, making it efficient and easy to scan for key information.

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, no annotations, no output schema, and rich schema coverage, the description is largely complete. It covers purpose, behavior, parameters, and return structure, but could benefit from more explicit guidance on when to use alternatives or error handling details to be fully comprehensive.

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 baseline is 3. The description adds minimal value beyond the schema by mentioning pagination and customizable results per page in general terms, but does not provide additional syntax, format, or usage nuances for the parameters beyond what the schema already documents.

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 posts') and resource ('currently on the HackerNews front page'), distinguishing it from siblings like 'get-latest-posts' and 'search-posts' by specifying front-page content with HackerNews ranking algorithm sorting. It explicitly mentions that all posts are tagged with 'front_page', further differentiating its scope.

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 get front-page posts sorted by popularity/trending), but it does not explicitly state when not to use it or name alternatives among sibling tools. It implies usage for paginated retrieval of front-page content without direct comparison to other tools.

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'

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