Skip to main content
Glama
hn-mcp
by lokih1028

hn-mcp

Hacker News as a knowledge base for AI agents. An MCP server that gives Claude Code (or any MCP client) about 4.8 million HN stories since 2006 in a local DuckDB index, plus live access to comment threads and this week's stories.

把 Hacker News 二十年的帖子变成 AI Agent 的知识库:本地 DuckDB 索引(约 480 万条 story)

  • 实时评论树和最新帖子。适合技术选型调研、趋势分析、内容选题。

Tools

Tool

What it does

Source

search_stories

Title search (whole words, "phrases", prefix*), filter by period, score, domain

local index

topic_trend

Mentions of up to 8 terms per year/month, normalized per 1,000 stories

local index

domain_report

A site's HN track record: volume by year, score stats, best stories

local index

on_this_day

Top stories posted on this calendar day in every year

local index

run_sql

One sandboxed, read-only DuckDB SELECT over the stories table

local index

get_thread

A story's comment tree in HN ranking order, as plain text

live (Algolia + HN API)

search_recent

Stories from the last N days

live (Algolia)

index_status

What the local index covers

local index

Example prompts once it is installed:

  • "Before I adopt Bun, what has HN said about it since 2022? Summarize the top 3 threads."

  • "Chart rust vs go vs zig on HN per year."

  • "How does substack.com perform on HN compared to medium.com?"

  • "What were the top HN stories on this day 10 and 15 years ago?"

Related MCP server: HackerNews MCP Server

Install

Requires uv.

git clone https://github.com/lokih1028/hn-mcp && cd hn-mcp
uv sync
uv run hn-mcp sync            # builds the story index (~400 MB) in ~/.hn-mcp/stories/

On a first run sync downloads the prebuilt index from the latest GitHub release (hn-index.zip). Without one (or with --no-snapshot) it builds the index itself: it reads only the story columns from the open-index/hacker-news Parquet archive (12 GB in full), one file per month, in about 20 minutes.

Either way it then tops up from the Algolia HN API, one file per day in stories/live/, up to today. Keep it fresh with a daily

uv run hn-mcp sync --live-only    # re-fetches missing days and the last 3 days

from cron or Task Scheduler. Set HN_MCP_DATA to keep the index somewhere else.

Register with Claude Code:

claude mcp add hn -s user -- uv --directory /path/to/hn-mcp run hn-mcp

Or in any MCP client config:

{
  "mcpServers": {
    "hn": {
      "command": "uv",
      "args": ["--directory", "/path/to/hn-mcp", "run", "hn-mcp"],
      "env": { "HN_MCP_DATA": "/path/to/data" }
    }
  }
}

Notes

  • Deleted and dead (flagged/spam) stories are left out of the index.

  • The archive stopped updating on 2026-08-23, and from 2025-12 on it holds each story's score as of posting time (average ~2 points instead of ~19). Stories from 2025-12-01 on therefore come from Algolia with current scores; the archive covers everything older.

  • index_status shows where the local index ends; search_recent covers anything newer.

  • run_sql runs on a DuckDB connection that can only read the index folder: no other file access, no extensions, one SELECT statement per call.

  • Comments are not stored locally; get_thread fetches them live, so it needs network.

Development

uv run pytest
uv run hn-mcp pack hn-index.zip   # snapshot of the local index, to attach to a release

License and data

Code: MIT. Data: the open-index/hacker-news dataset is published under ODC-BY; content belongs to its Hacker News authors. Attribute the dataset if you republish derived data.

Available Tools

8 tools
domain_reportB

Track record of a website on HN: volume per year, score stats, best stories.

Subdomains are included (e.g. 'github.com' also counts 'gist.github.com').
Useful to judge a source, blog, product or competitor.

Inputs: domain (required), top.

get_threadA

Fetch a story and its comment tree live from HN, in HN's ranking order.

Each comment has its depth (0 = top level), author, direct reply count and
plain text cut to max_chars. Use it to summarize a discussion or find the
strongest arguments on each side.

Inputs: story_id (required), max_chars, max_depth, max_comments.

index_statusB

What the local index covers: story count, first and last story time, data folder.

Inputs: no named parameters.

on_this_dayB

The top stories posted on this calendar day in every year of HN history.

date: 'MM-DD' (defaults to today, UTC). per_year: how many stories per year.
Handy for "10 years ago today" content.

Inputs: date, per_year, min_score. Returns: result

run_sqlA

Run one read-only DuckDB SELECT over the stories table for custom analysis.

Columns: id UINTEGER, author VARCHAR, time TIMESTAMP (UTC), title VARCHAR,
url VARCHAR, domain VARCHAR (no 'www.'), score INTEGER, comments INTEGER
(total descendants), text VARCHAR (HTML body of Ask/Show HN posts, else NULL).
Comments themselves are not in the index; use get_thread for those.

Inputs: sql (required), limit. Returns: result

search_recentB

Search stories from the last N days live (Algolia HN Search).

Use for anything newer than the local index (see index_status).

Inputs: query (required), days, sort, limit, +1 more. Returns: result

search_storiesA

Search archived HN stories by title words (all must match, case-insensitive).

query: space-separated whole words; quote phrases, e.g. 'rust "memory safety"';
  end a word with * for prefix match ('agent*'). Empty query lists top
  stories for the period.
since/until: 'YYYY', 'YYYY-MM' or 'YYYY-MM-DD' (inclusive).
include_text: also match the body of Ask/Show HN posts.

Inputs: sort, limit, query, since, +4 more. Returns: result

topic_trendB

How often each term appears in story titles over time (whole-word match, trailing * for prefix match).

Returns a per-term summary plus a compact table: one row per period with
the period's story total, then each term's matching-story count and that
count per 1,000 stories (comparable across periods).
Good for "rise and fall" charts, e.g. terms=["rust", "go", "zig"].

Inputs: terms (required), since, until, granularity.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A3.6/5.0

    Scored across 8 tools

    Disambiguation4/5

    Each tool targets a distinct use case: archived search, live search, term trends, domain stats, on-this-day, thread fetching, raw SQL, and index status. The only real overlap is search_stories vs search_recent (clarified by the 'newer than the local index' note) and run_sql, which can replicate almost any other tool's output but is framed as a custom-analysis escape hatch.

    Naming Consistency3/5

    All names are snake_case, but conventions are mixed: verb_noun (search_stories, run_sql, get_thread) alongside noun_noun or descriptive phrases (topic_trend, domain_report, index_status, on_this_day). Still readable and fairly predictable in intent.

    Tool Count5/5

    Eight tools is well-scoped for an HN analysis server, with each tool covering a genuinely different query shape (keyword, trend, domain, date, SQL, live thread, live search, index health). No filler tools.

    Completeness4/5

    The surface covers search, trends, sources, date-based browsing, threads, and raw SQL for custom work. The main gap is an author/user report analogous to domain_report (authors are only reachable via run_sql), plus comments aren't searchable in the index, though get_thread mitigates that.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      Enables browsing Hacker News, searching discussions, analyzing users, and tracking tech trends with zero setup required—no API keys or authentication needed.
      5
      33 npm
      6
      MIT
    • A
      license
      A
      quality
      Not graded
      maintenance
      Enables AI agents and developers to search, retrieve, and analyze HackerNews content including advanced post search, front page access, full comment trees, and user profile lookups through the Model Context Protocol.
      4
      MIT
    • 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