unofficial-HackerNews-MCP-CLI
This server exposes read-only HackerNews data as MCP tools.
get_stories – list top/new/best/ask/show/job stories with details and pagination.
get_item – fetch any single story, comment, job, poll, or poll option by ID.
get_comments – retrieve a threaded comment tree, bounded by depth and comments per level.
get_user – view a user's public profile (karma, about, created, submissions).
get_max_item_id – get the ID of the newest item, useful for walking all items.
get_updates – get recently changed items and profiles.
It also exposes stable resources at hn:// URIs and prompts for daily digests and thread summaries.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@unofficial-HackerNews-MCP-CLI show me the top 5 HackerNews stories"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
This project wraps the official HackerNews API behind one shared async client and exposes it two ways:
hn, a Typer CLI that renders Rich tables in the terminal.hn-mcp, a FastMCP server that exposes the same operations as MCP tools for Claude and other MCP clients.
The API is read-only, needs no authentication, and has no rate limit.
Let your coding agent install it
You do not have to run the install commands yourself. Give this instruction to the coding agent you already use:
Run curl -fsSL https://raw.githubusercontent.com/Riddhimaan-Senapati/unofficial-HackerNews-MCP-CLI/main/skills/install-hackernews/SKILL.md and follow the instructions in its output to install the HackerNews CLI.That command fetches the
install-hackernews
skill, which gives the agent each step.
If your agent supports the skills library, install the same skill with:
npx skills add Riddhimaan-Senapati/unofficial-HackerNews-MCP-CLIRelated MCP server: Hacker News MCP Server
Install
Requires Python 3.10+ and uv.
uv sync # create .venv and install the locked dependencies
uv run hn stories top # run the CLI in .venv
uv run hn-mcp # run the MCP server in .venvTo install the published commands outside the project, use an isolated uv tool environment:
uv tool install hackernews-mcp-cliUpgrade an existing tool installation with:
uv tool upgrade hackernews-mcp-cliThe examples below use the installed commands. From a clone, prefix hn and
hn-mcp commands with uv run.
CLI
hn stories top # front-page (top) stories
hn stories top --limit 10 # -n 10
hn stories top --offset 30 --limit 10 # skip the first 30 stories
hn stories new # newest stories
hn stories best # best recent stories
hn stories ask # latest Ask HN
hn stories show # latest Show HN
hn stories job # latest job postings
hn item 8863 # a single story, comment, job, or poll
hn comments 8863 # threaded comment tree (--depth, --limit, --offset)
hn user pg # a user's profile (case-sensitive name)
hn max-item # id of the most recently created item
hn updates # recently changed items and profiles
hn --version # print the installed versionEvery command takes --format (-f): table (the default), json,
markdown, or text. Use json for scripting; markdown and text strip
HTML. Use --json as a shortcut for --format json. If you pass both options,
--json takes precedence. For the story lists, --offset plus --limit must
stay within the category's cap, 500 stories for top, new, and best, or 200 for
ask, show, and job.
hn stories top -n 5 --json | jq -r '.[] | "\(.title) (\(.url // .hn_url))"'
hn user pg --json | jq .karmaRun hn --help for the full command list, or hn <command> --help for that
command's options and examples.
MCP server
The server uses FastMCP 4 and MCP SDK v2. It supports stdio and streamable HTTP transports.
Run over stdio, the default transport for MCP clients:
hn-mcpOr over HTTP:
hn-mcp --http --host 127.0.0.1 --port 8000Register it with an MCP client such as Claude Desktop or Claude Code:
{
"mcpServers": {
"hackernews": { "command": "hn-mcp" }
}
}Tools
Tool | Description |
| A list of stories; |
| A single story, comment, job, or poll |
| A batch of items by id, in order, with missing ids dropped |
| Threaded comment tree |
| A user's public profile |
| id of the most recently created item |
| Items and profiles that changed most recently |
Every tool that returns items, comments, or users takes strip_html to return
plain text instead of HTML.
Resources
The server also exposes read-only JSON at stable URIs: hn://stories/{category},
hn://item/{item_id}, and hn://user/{username}.
Prompts
daily_digest(category, limit)asks the agent to summarize the day's stories.thread_summary(item_id, max_depth)asks the agent to summarize a comment thread.
Skill
The repo ships two Agent Skills, published on skills.sh:
skills/hackernews/SKILL.mdteaches an agent how and when to use thehnCLI and thehn-mcpMCP server.skills/install-hackernews/SKILL.mdinstalls the package.
Install both with the skills CLI, or add the console scripts and let your agent load them from this directory:
npx skills add Riddhimaan-Senapati/unofficial-HackerNews-MCP-CLIThe root skills.sh.json groups the two skills on the
skills.sh repo page.
Project layout
src/hn/
client.py # shared async HackerNews API client (httpx)
models.py # Pydantic models + StoryCategory (endpoint, title, cap)
server.py # FastMCP server (hn-mcp)
cli.py # Typer CLI (hn)
skills/hackernews/SKILL.md
skills/install-hackernews/SKILL.md
tests/ # pytest + respx (mocked API)How it works
client.py owns every network call and bounds concurrency. server.py and
cli.py stay thin over it, so the CLI and the MCP tools behave identically.
StoryCategory in models.py is the single source of truth for the six story
lists: it holds a category's endpoint stem, display title, and cap. Add a
category or a model field there, not in each interface.
The client keeps a short in-process cache, about 60 seconds, for item, user, and
story responses. It mainly helps the long-lived MCP server; the CLI exits
between commands. max_item and updates are never cached.
Changing behavior also means updating the docs in the same change: README, CONTRIBUTING, RELEASING, the source skills, and AGENTS.md. Only the maintainer publishes a release, so follow RELEASING.md and push a tag only when asked.
Read AGENTS.md for the agent-facing rules, and CONTRIBUTING.md for the contribution workflow.
Development
uv run ruff check . # lint
uv run ruff format --check . # formatting
uv run pytest # test suite (API calls are mocked)CI runs lint, formatting, and the test suite on Python 3.10 through 3.13 via GitHub Actions. See CONTRIBUTING.md for the full workflow.
License
MIT. See LICENSE. This is an unofficial project and is not affiliated with Hacker News or Y Combinator.
Available Tools
7 toolsget_commentsGet commentsARead-onlyIdempotent
Get the threaded comment tree for an item.
Each comment includes a nested replies list bounded by max_depth and
max_per_level. Comment text is HTML unless strip_html is set.
Inputs: item_id (required), offset, max_depth, strip_html, +1 more. Returns: result
get_itemGet itemARead-onlyIdempotent
Get a single HackerNews item (story, comment, job, poll, or poll option).
Returns null if no item exists with that id.
Inputs: item_id (required), strip_html. Returns: result
get_itemsGet itemsARead-onlyIdempotent
Get many items in one call, preserving order and dropping missing ids.
Inputs: item_ids (required), strip_html. Returns: result
get_max_item_idGet max item idARead-onlyIdempotent
Get the id of the most recently created item, useful for walking all items.
Inputs: no named parameters. Returns: result
get_storiesGet storiesARead-onlyIdempotent
Get a list of HackerNews stories from a category, with full details.
'top', 'new' and 'best' draw from up to 500 stories; 'ask', 'show' and 'job' from up to 200. Each result includes title, url, score, author, comment count and the canonical HN discussion link.
Inputs: limit, offset, category, strip_html. Returns: result
get_updatesGet updatesARead-onlyIdempotent
Get the items and user profiles that changed most recently.
Inputs: no named parameters. Returns: The set of items and profiles that changed most recently.
get_userGet userARead-onlyIdempotent
Get a HackerNews user's public profile (karma, about, created, submissions).
Returns null if the user has no public activity or does not exist.
Inputs: username (required), strip_html. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 7 tools
Each tool targets a distinct resource or access mode: single item, batch items, category stories, threaded comments, user profile, latest ID, and recent updates. There is no meaningful overlap that would cause an agent to select the wrong tool.
All tool names follow the same get_* snake_case convention, with clear noun targets. Pluralization is used sensibly to distinguish batch endpoints from singular endpoints.
Seven tools is well-scoped for a read-only Hacker News API client covering items, stories, comments, users, and metadata. Each tool adds distinct value without bloat.
The set covers the core Hacker News API surface: fetching items individually or in bulk, story categories, comment threads, user profiles, latest item ID, and recent updates. No significant dead ends or missing read operations are apparent.
Maintenance
Related MCP Connectors
Dive into the latest and greatest from the tech world with our Hacker News MCP server.
Hacker News MCP — search and retrieve stories from Hacker News
A simple MCP server built with FastMCP and python
Related MCP Servers
- AlicenseAqualityDmaintenanceA Model Context Protocol (MCP) server that provides tools for searching and fetching information from Hacker News.476MIT
- AlicenseDqualityDmaintenanceAn MCP server that enables AI assistants to access real-time Hacker News data including top stories, story details, comments, and search functionality.13MIT
- AlicenseNot gradedqualityBmaintenanceMCP server for Hacker News providing tools to fetch stories, threads, users, and search content via Firebase and Algolia APIs.203 npm7Apache 2.0
- AlicenseAqualityBmaintenanceMCP server enabling AI agents to interact with Hacker News, including fetching full comment trees with depth control, searching stories and comments, and retrieving user profiles.610 PyPI5MIT