Skip to main content
Glama
paabloLC

MCP Hacker News

by paabloLC

getJobStories

Retrieve job postings from Hacker News to find developer opportunities. Specify the number of listings to return for targeted job searches.

Instructions

Get job postings from Hacker News

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoNumber of jobs to return (default: 10, max: 30)

Implementation Reference

  • The execute handler function that implements the core logic of the getJobStories tool: fetches job IDs from HN /jobstories endpoint, retrieves and formats up to 30 job items, and returns formatted JSON response.
    execute: async (args: any) => {
      const limit = Math.min(args.limit || 10, 30);
      const jobIds = await fetchFromAPI<number[]>("/jobstories");
    
      if (!jobIds) {
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify({ error: "Failed to fetch job stories" }),
            },
          ],
        };
      }
    
      const jobs = await fetchMultipleItems(jobIds, limit);
      const formattedJobs = jobs.map((job) => ({
        id: job.id,
        title: job.title,
        url: job.url,
        score: job.score,
        author: job.by,
        time: job.time ? formatTime(job.time) : "unknown",
        hnUrl: `https://news.ycombinator.com/item?id=${job.id}`,
        text: job.text,
      }));
    
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(
              {
                message: `Latest ${limit} job postings`,
                jobs: formattedJobs,
              },
              null,
              2
            ),
          },
        ],
      };
    },
  • The inputSchema defining the parameters for the getJobStories tool, including the optional 'limit' parameter.
    inputSchema: {
      type: "object",
      properties: {
        limit: {
          type: "number",
          description: "Number of jobs to return (default: 10, max: 30)",
          default: 10,
        },
      },
    },
  • src/index.ts:52-65 (registration)
    Registration in the MCP server: handles 'tools/call' JSON-RPC method by looking up the tool by name from the imported tools array and executing its handler.
    if (json.method === "tools/call") {
      const tool = tools.find((tool) => tool.name === json.params.name);
      if (tool) {
        const toolResponse = await tool.execute(json.params.arguments);
        sendResponse(json.id, toolResponse);
      } else {
        sendResponse(json.id, {
          error: {
            code: -32602,
            message: `MCP error -32602: Tool ${json.params.name} not found`,
          },
        });
      }
    }
  • Helper function fetchFromAPI used in the handler to fetch the list of job story IDs from 'https://hacker-news.firebaseio.com/v0/jobstories.json' with caching.
    export async function fetchFromAPI<T>(endpoint: string): Promise<T | null> {
      const cacheKey = endpoint;
      const cached = getCached<T>(cacheKey);
      if (cached) return cached;
    
      try {
        const response = await fetch(
          `https://hacker-news.firebaseio.com/v0${endpoint}.json`
        );
        if (!response.ok) throw new Error(`HTTP ${response.status}`);
    
        const data = await response.json();
        setCache(cacheKey, data);
        return data;
      } catch (error) {
        console.error(`Error fetching ${endpoint}:`, error);
        return null;
      }
    }
  • Helper function fetchMultipleItems used to parallel-fetch and filter item details for the top job stories.
    export async function fetchMultipleItems(
      ids: number[],
      maxItems = 30
    ): Promise<HackerNewsItem[]> {
      const limitedIds = ids.slice(0, maxItems);
      const promises = limitedIds.map((id) =>
        fetchFromAPI<HackerNewsItem>(`/item/${id}`)
      );
      const results = await Promise.all(promises);
    
      return results.filter(
        (item): item is HackerNewsItem =>
          item !== null && !item.deleted && !item.dead
      );
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states what the tool does but doesn't describe how it behaves: no information on rate limits, authentication needs, error conditions, pagination, or what format the job postings are returned in. For a read operation with zero annotation coverage, this leaves significant gaps.

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 a single, clear sentence with zero wasted words. It's appropriately sized for a simple tool and front-loads the essential information ('Get job postings from Hacker News'). Every word earns its place.

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

Completeness2/5

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

Given the lack of annotations and output schema, the description is incomplete. It doesn't explain what the return value looks like (e.g., list of job objects, raw text), any dependencies on other tools, or behavioral constraints. For a tool that fetches data, more context about the output format and usage patterns would be helpful.

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?

Schema description coverage is 100%, with the single parameter 'limit' fully documented in the schema (type, description, default, max). The description adds no parameter information beyond what's already in the schema, so it meets the baseline of 3 where the schema does the heavy lifting.

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 action ('Get') and resource ('job postings from Hacker News'), making the purpose immediately understandable. It distinguishes from some siblings like 'getTopStories' or 'getUser' by specifying job postings, though it doesn't explicitly differentiate from 'getAskHNStories' or 'getShowHNStories' which are also story types.

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 siblings like 'getTopStories', 'getNewStories', and 'getAskHNStories', there's no indication whether this tool is for current job postings, historical data, or how it differs from other story-fetching tools. No exclusions or prerequisites are mentioned.

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/paabloLC/mcp-hacker-news'

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