Skip to main content
Glama
hackernews-mcp

hackernews-mcp

by ccozad

Hacker News MCP

An MCP server that lets Claude (or any MCP client) search and read Hacker News, backed by HN's free Algolia search API. Ask in plain language; Claude calls the tools.

Claude answering “search HN for Rust async” with a ranked list of Hacker News results

You:    What's the discussion on Rust async runtimes been like this past month?
Claude: → search_hackernews(query="rust async runtime", time_range="past_month")
        Here are the threads HN has been talking about… [summary of real stories]

You:    Dive into the comments on the top one.
Claude: → get_hackernews_thread(item_id="…", max_comments=30)
        The top commenters are split on… [summary of the thread]

The two tools compose — a follow-up like “pull comments on the first item” feeds the story id straight from the search into get_hackernews_thread:

Claude summarizing the comment thread for the top story

See examples/ for full transcripts, and docs/claude-desktop.md to wire it into Claude Desktop in about five minutes.

What's in this repo

Two MCP tools:

  • search_hackernews — search stories and comments by query, with filters for tag (story / comment / ask_hn / show_hn / all), time range, sort (relevance or date), and result limit.

  • get_hackernews_thread — fetch a story's comment tree by id, flattened depth-first and bounded by max_comments / max_depth to keep the response within an honest token budget (with a truncated flag when it was trimmed).

Tech stack: Python 3.11+, the official MCP Python SDK, httpx, and — for development — pytest, ruff, and pyright.

Related MCP server: HackerNews MCP Server

Install

Uses uv:

git clone https://github.com/ccozad/hackernews-mcp.git
cd hackernews-mcp
uv sync

Run the stdio server directly with uv run hackernews-mcp (it speaks the MCP protocol on stdout, so you normally let a client launch it rather than running it by hand).

Use it with Claude Desktop

Add this to your claude_desktop_config.json (full guide, config-file locations, and troubleshooting in docs/claude-desktop.md):

{
  "mcpServers": {
    "hackernews": {
      "command": "uv",
      "args": ["--directory", "/absolute/path/to/hackernews-mcp", "run", "hackernews-mcp"]
    }
  }
}

Restart Claude Desktop, then ask it to "search HN for Rust async" and confirm a tool call happens. The first time Claude uses a tool, Claude Desktop asks you to approve it:

Claude Desktop prompting to allow the “Search hackernews” tool

Architecture

As shown in the diagram at the top, Claude Desktop is the MCP client: on startup it spawns this server as a subprocess and talks to it over stdio. The server exposes two tools and forwards their work to HN's Algolia API over HTTPS.

Exchange sequence

A typical two-tool session — search surfaces a story, then a follow-up dives into its comments:

sequenceDiagram
    actor User
    participant Desktop as Claude Desktop
    participant Server as hackernews-mcp
    participant Algolia as HN Algolia API

    Note over Desktop,Server: On launch, Desktop spawns the server<br/>and negotiates initialize + tools/list over stdio

    User->>Desktop: "search HN for Rust async"
    Desktop->>Server: tools/call search_hackernews(query="rust async")
    Server->>Algolia: GET /search?query=rust+async&tags=story
    Algolia-->>Server: matching hits (JSON)
    Server-->>Desktop: hits array
    Desktop-->>User: ranked list of stories

    User->>Desktop: "pull comments on the first item"
    Desktop->>Server: tools/call get_hackernews_thread(item_id="…")
    Server->>Algolia: GET /items/{item_id}
    Algolia-->>Server: full nested thread (JSON)
    Note over Server: flatten depth-first, then bound<br/>by max_comments / max_depth
    Server-->>Desktop: root, comments, truncated
    Desktop-->>User: thread summary

How it works

Both tools are thin wrappers over HN's Algolia API. search_hackernews maps its arguments to Algolia's /search (or /search_by_date) endpoint — tag filters, a numericFilters time window, and hitsPerPage. get_hackernews_thread pulls the full nested thread from /items/{id} and trims it client-side. Input is validated before any network call; upstream errors, timeouts, and empty results all have defined behavior. See the tool docstrings in src/hackernews_mcp/ for the full contract.

Development

uv sync --extra dev      # install dev tools
uv run pytest            # run the test suite (network-mocked)
uv run ruff check .      # lint
uv run ruff format --check .
uv run pyright           # type-check

All four checks run in CI on every pull request across Python 3.11 and 3.12. The suite mocks Algolia and never hits the network; a gated live smoke test runs only when HACKERNEWS_MCP_LIVE_TEST=1 is set.

License

MIT

Available Tools

1 tool
search_hackernewsA

Search Hacker News stories and comments via HN's Algolia API.

Use this to find HN discussion on a topic, surface Ask HN / Show HN posts, or pull the most recent items in a time window. Returns a JSON object with a hits array.

Parameters:

  • query (str, required): the search phrase, e.g. "rust async runtime".

  • tag (str): which item kind to search. One of "story" (default), "comment", "ask_hn", "show_hn", or "all".

  • time_range (str): restrict by recency. One of "past_24h", "past_week", "past_month", or "all_time" (default).

  • sort (str): "relevance" (default) ranks by Algolia relevance; "date" returns newest first.

  • limit (int): number of hits to return, 1-50 (default 10).

Each hit has: id, title, url, points, author, num_comments, created_at (ISO8601), and excerpt (a highlighted snippet when Algolia provides one). For comment hits, title/url/points are usually null and the matched text appears in excerpt. An empty search returns {"hits": []} rather than an error.

Inputs: query (required), tag, time_range, sort, +1 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.3/5.0

    Scored across 1 tool

    Disambiguation5/5

    Only one tool exists, so there is no possibility of confusion between tools. The search_hackernews tool has a clear, distinct purpose.

    Naming Consistency5/5

    With a single tool, naming consistency is not an issue. The name 'search_hackernews' follows a clear verb_noun pattern.

    Tool Count2/5

    For a server named hackernews-mcp, a single search tool is too few. Users would expect additional tools for fetching stories, comments, user info, and posting, making the scope feel incomplete.

    Completeness2/5

    The server lacks basic operations for Hacker News interaction, such as getting a story by ID, fetching top stories, or user information. Only search is supported, leaving significant gaps.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      Enables AI assistants to access HackerNews content through structured search, front page retrieval, latest posts monitoring, detailed item fetching with comment trees, and user profile viewing via the Algolia API.
      5
      60 npm
      7
      MIT
    • F
      license
      A
      quality
      D
      maintenance
      Enables AI assistants to read and search Hacker News for top stories, comments, user profiles, and job listings using the Firebase and Algolia APIs. It facilitates natural language research into community discussions and technological trends across the HN platform.
      8
      -
    • A
      license
      A
      quality
      C
      maintenance
      Provides AI agents with access to Hacker News data including top stories, story details, comment threads, and full-text search for content research and trend monitoring.
      5
      MIT