Skip to main content
Glama

get-item

Retrieve specific HackerNews items including stories, comments, and polls using their unique ID number to access detailed content information.

Instructions

Get a specific HackerNews item (story, comment, poll, etc.) by its ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesThe ID of the item to retrieve

Implementation Reference

  • Handler function that fetches the specific HackerNews item by its ID using the shared fetchHN helper and returns the JSON result as both text and structured content.
    async ({ id }) => { const endpoint = `/items/${id}`; const result = await fetchHN(endpoint); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], structuredContent: result }; }
  • Input schema requires a numeric 'id' for the item. Output schema defines fields like id, created_at, author, title, etc., for the retrieved item.
    { title: 'Get HackerNews Item by ID', description: 'Get a specific HackerNews item (story, comment, poll, etc.) by its ID', inputSchema: { id: z.number().describe('The ID of the item to retrieve') }, outputSchema: { id: z.number(), created_at: z.string(), author: z.string().optional(), title: z.string().optional(), url: z.string().optional(), text: z.string().optional(), points: z.number().optional(), parent_id: z.number().optional(), children: z.array(z.any()).optional() }
  • src/index.ts:274-303 (registration)
    Registers the 'get-item' tool using server.registerTool, providing the tool name, schema, and inline handler function.
    server.registerTool( 'get-item', { title: 'Get HackerNews Item by ID', description: 'Get a specific HackerNews item (story, comment, poll, etc.) by its ID', inputSchema: { id: z.number().describe('The ID of the item to retrieve') }, outputSchema: { id: z.number(), created_at: z.string(), author: z.string().optional(), title: z.string().optional(), url: z.string().optional(), text: z.string().optional(), points: z.number().optional(), parent_id: z.number().optional(), children: z.array(z.any()).optional() } }, async ({ id }) => { const endpoint = `/items/${id}`; 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 the HackerNews Algolia API, used by the get-item handler and other tools.
    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