hackernews-mcp

hackernews-mcp

Enables LLMs to search and read Hacker News posts and comments via the Algolia API.

Category
访问服务器

README

Hacker News MCP

<p align="center"> <img src="images/hackernews_mcp.png" alt="Architecture: you prompt Claude Desktop (the MCP client), which talks to the hackernews-mcp server over stdio; the server queries the HN Algolia Search API over HTTPS" width="640"> </p>

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.

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

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选