Skip to main content
Glama
wei
by wei

Get HackerNews Item by ID

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

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYes
urlNo
textNo
titleNo
authorNo
pointsNo
childrenNo
parent_idNo
created_atYes

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();
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden. While it implies a read operation, it doesn't disclose important behavioral traits like rate limits, authentication requirements, error handling, or what happens with invalid IDs. The description is minimal and lacks 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 extremely concise - a single sentence that communicates the core purpose without any wasted words. It's front-loaded with the essential information and doesn't include unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has an output schema (which handles return values) and high schema coverage, the description is minimally adequate. However, for a tool with no annotations and many sibling alternatives, it should provide more context about when and how to use it effectively.

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?

With 100% schema description coverage, the input schema already fully documents the single 'id' parameter. The description adds marginal value by clarifying that IDs retrieve 'items (story, comment, poll, etc.)', but doesn't provide additional semantic context beyond what the schema provides.

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 verb ('Get') and resource ('HackerNews item') with specificity about retrieving by ID. It distinguishes from some siblings like 'get-front-page' or 'get-top-stories' by focusing on individual items, but doesn't explicitly differentiate from all similar tools like 'get-user' which also retrieves by ID.

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. With many sibling tools available (like 'get-story-comments', 'search-posts', etc.), there's no indication of when this specific ID-based retrieval is preferred over other methods.

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