Skip to main content
Glama

get-front-page

Retrieve current HackerNews front page stories with pagination controls to browse trending tech news and discussions.

Instructions

Get all stories currently on the HackerNews front page

Input Schema

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

Implementation Reference

  • Handler function that fetches the current HackerNews front page stories using the HN API with 'tags=front_page', supports pagination.
    async ({ page, hitsPerPage }) => { const params = new URLSearchParams(); params.append('tags', 'front_page'); if (page !== undefined) params.append('page', page.toString()); if (hitsPerPage !== undefined) params.append('hitsPerPage', hitsPerPage.toString()); const endpoint = `/search?${params.toString()}`; const result = await fetchHN(endpoint); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], structuredContent: result }; }
  • Input and output schemas for the 'get-front-page' tool, defining optional pagination parameters and expected search result structure.
    { title: 'Get HackerNews Front Page', description: 'Get all stories currently on the HackerNews front page', 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:104-135 (registration)
    Registration of the 'get-front-page' tool using server.registerTool, including schema and handler.
    server.registerTool( 'get-front-page', { title: 'Get HackerNews Front Page', description: 'Get all stories currently on the HackerNews front page', 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', 'front_page'); if (page !== undefined) params.append('page', page.toString()); if (hitsPerPage !== undefined) params.append('hitsPerPage', hitsPerPage.toString()); const endpoint = `/search?${params.toString()}`; const result = await fetchHN(endpoint); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], structuredContent: result }; } );
  • Shared helper function to make API calls to HackerNews Algolia API, used by the get-front-page handler.
    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(); }

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