Skip to main content
Glama
ccozad

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.

ParametersJSON Schema
NameRequiredDescriptionDefault
queryYesThe search phrase.
tagNoWhich item kind to search.story
time_rangeNoRestrict results by recency.all_time
sortNoRanking: relevance or newest-first.relevance
limitNoNumber of hits to return (1-50).

TDQS

A4.6/5.0
Behavior5/5

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

No annotations are present, so the description fully shoulders the behavioral disclosure. It details the return type ('JSON object with a hits array'), describes each hit's fields (id, title, url, points, author, num_comments, created_at, excerpt), and explains special cases such as comment hits where title/url/points are null and excerpt contains matched text. It also notes that an empty search returns {'hits': []} rather than an error. This comprehensive disclosure compensates well for the absent annotations.

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 concise and well-structured: a two-sentence intro, bullet points for parameters, and a final paragraph about response shape and edge cases. Every sentence contributes meaningful information; there is no redundancy or fluff. The structure is easy to parse for an AI agent.

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

Completeness4/5

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

Given the tool's complexity (5 parameters, no output schema), the description covers all necessary aspects: parameter details, return format, and edge-case behavior (empty search). Minor omission: it does not mention pagination or whether multiple pages can be retrieved. The limit parameter suggests a single page, but explicit clarification would improve completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, so the baseline is 3. The description adds value beyond the schema by providing a concrete example for 'query' (e.g., 'rust async runtime'), reiterating enums with defaults, and clarifying the limit range. While some content mirrors the schema, the examples and additional phrasing enhance understanding for an AI agent.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description begins with a clear verb+resource: 'Search Hacker News stories and comments via HN's Algolia API.' It further elaborates use cases like 'find HN discussion on a topic, surface Ask HN / Show HN posts, or pull the most recent items,' making the purpose unmistakable. No siblings exist to differentiate, but the description is fully specific.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit context on when to use the tool (e.g., 'find HN discussion on a topic, surface Ask HN / Show HN posts, or pull the most recent items'). It does not include exclusions or alternatives because no sibling tools exist, but the use cases are clearly stated. Slight room for improvement: could mention that this is read-only and does not mutating Hacker News.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. 1 tool updatev0.0.1
    • First observedsearch_hackernews

TDQS

A4.3/5.0
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

ActivityStale
ResponsivenessSyncing

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

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
    63
    7
    MIT
  • F
    license
    A
    quality
    C
    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

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/ccozad/hackernews-mcp'

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