@cyanheads/hn-mcp-server
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., "@@cyanheads/hn-mcp-serverShow me the top 10 Hacker News 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.
Public Hosted Server: https://hn.caseyjhand.com/mcp
Overview
Feeds, threads, and profiles from the Hacker News Firebase API and Algolia Search API. Browse ranked feeds, read full comment threads, look up user profiles, and search stories, comments, polls, and jobs by keyword or by type, author, parent story, date, or score. Runs as a stdio process, a local Streamable HTTP server, or the public hosted endpoint above.
Tools
Tool | Description |
| Fetch stories from an HN feed (top, new, best, ask, show, jobs), with title, URL, score, author, and comment count |
| Get an item and its comment tree as a threaded discussion, with depth and comment-count controls and a cursor to page through long threads |
| Fetch a user profile with karma, about, and optionally a page of resolved submissions |
| Search stories, comments, polls, and jobs via Algolia by keyword, by filters alone, or both — type, author, parent story, date range, and minimum points |
Related MCP server: @isteam/hackernews-mcp
Capability reference
hn_get_stories tool
Six feed types:
top,new,best,ask,show,jobs;count(1–100, default 30) andoffsetfor paginationReturns id, type, title, url, domain, score, author, timestamp, comment count, and body text — each field omitted (not null) when HN doesn't provide it
Enrichment reports
total,offset, andhasMore; while more stories remain,truncatedis set andnoticenames the nextoffset, and anoticeexplains empty pages (empty feed, offset past end, or every item on the page deleted/flagged). The last page carries no truncationItems whose fetch failed after retries are listed in
failedIdswith anoticenaming the retry; a page where every item failed returns the classified upstream error instead of an empty list
hn_get_thread tool
itemIdplusdepth(0–10, default 3; 0 returns the item with no comments) andmaxComments(1–200, default 50) capping one response across all levels, alongside a fixed 64,000-byte text budget that cuts only between commentsBreadth-first traversal ranked like HN — top-ranked top-level comments resolve first, replies fill in only after the level above is exhausted
Resumable: a response stopped by
maxComments, the byte budget, or an upstream rate limit returnsnextCursor; passing it back ascursorwith the sameitemIdcontinues at the next unseen comment. The cursor carries the unvisited comments themselves, so re-ranked replies cannot shift it, and the server keeps no session state. A cursor passed with a differentitemIdfails withinvalid_cursorThe root carries its relationships and state:
parentfor a comment,pollfor a poll option,partsand resolvedoptions(text and votes, at every depth) for a poll, anddeleted/deadmarkers. Thecontent[]heading names the type — a title,Comment by <author>,Poll option by <author> on poll <id>— and marks a deleted or dead rootFlat comment list carries
depth/parentIdfor tree reconstruction, pluschildCountand anisOpflag when the comment author matches the root item's authortruncatedandtruncationReason(count,size,rate_limited, ordepthwhen replies lie below the depth limit) are set only while comments remain unread — never on a terminal page, including a thread that loads in full at exactly the cap.noticereports deleted/dead comments omitted during traversal and the next step: the cursor, or a largerdepthor a comment id asitemIdComments and poll options whose fetch failed after retries are listed in
failedIds, andnoticenames them with the retry; failed comments ride innextCursor, so paging on retries them rather than skipping them. The root item is still returned, and a failure is never passed off as amaxComments/depthlimit
hn_get_user tool
usernameis case-sensitive and trimmed;includeSubmissions(default false) resolves recent submissions, withsubmissionCount(1–50, default 10) andsubmissionOffsetpaging through a long historyProfile includes karma, creation date, and about text (HTML stripped); submissions filter out dead/deleted items
A comment submission carries its
parentand a poll-option submission itspoll, so either links back to what it answeredEnrichment echoes
submissionOffsetand the offset to send next, or a notice when the requested offset is past the end of the historySubmissions whose fetch failed after retries are listed in
failedIdswith anoticenaming the retry; a window where every submission failed returns the classified upstream error
hn_search_content tool
Free-text
queryplustags(story/comment/poll/job/ask_hn/show_hn/front_page),author,storyId,dateRange, andminPointsfilters;sortby relevance or date;count(1–50, default 30) andpagefor paginationqueryis optional when a filter is set — list Ask HN, Show HN, polls, or jobs on their own, or pass a story'sstoryIdwithtags: "comment"to search within one thread. No query and no filter fails withmissing_query_or_filterdateRangebounds take ISO 8601 (YYYY,YYYY-MM,YYYY-MM-DD, or a date-time with optional offset), read as UTC and both exclusive; an empty or out-of-order range fails withinvalid_date_rangeminPointsapplies to stories and polls — comments and jobs carry no points, so pairing it withtags: "comment"or"job"fails withmin_points_unscored_typeview: "compact"drops the two body-text fields (text,highlights.text), which otherwise repeat a long comment twice per hit — pass a hit id tohn_get_threadto read the bodyHighlight metadata (
highlights.title,highlights.text,matchedWords) shows which terms matched and whereEnrichment reports
totalHits,page, and the actual reachabletotalPages— not derived fromtotalHits, since broad queries report far more hits than Algolia will serve. While more pages remain,truncatedis set andnoticenames the nextpage; a page past the end gets a notice naming the last valid page (orpage: 0past Algolia's 1,000-hit ceiling)
Features
Built on @cyanheads/mcp-ts-core: stdio and Streamable HTTP transports, pluggable auth (none / jwt / oauth), swappable storage (in-memory, filesystem, Supabase, Cloudflare KV/R2/D1), structured logging with optional OpenTelemetry tracing.
HN-specific:
Two upstream APIs: HN's Firebase API for feeds, items, and users; Algolia's HN Search API for full-text search
Concurrent batch fetching with configurable parallelism for item resolution (
HN_CONCURRENCY_LIMIT)HTML bodies stripped to plain text — entities decoded once, code blocks kept verbatim, each link rendered once as its full URL — while titles, which are not HTML though some carry entities, are entity-decoded and never tag-stripped
Server-level
instructionsforwarded to LLM clients oninitialize— item types, ID reuse across tools, case-sensitive usernames, field sparsityNo API keys required — both upstream APIs are public
Agent-friendly output:
Graceful partial failure — an item whose fetch fails after retries is reported by ID in
failedIds, apart from deleted, dead, or nonexistent items, rather than silently shrinking the result;hn_get_threadalso counts the deleted and dead comments it drops, and a rate-limited item stops the batch instead of sending every remaining item through its own retry ladderDiscriminated output contracts — typed error reasons (
item_not_found,upstream_rate_limited,upstream_html, …) with per-reason recovery text (a rate limit passes on the upstream'sRetry-AfterasretryAfter), and adepth/parentIdpair on every comment so callers reconstruct the tree without guessing nestingPagination provenance — every paged listing echoes the offset it used (
offset,submissionOffset,page) plus the exact next-offset value innotice, andhn_get_threadreturns a self-containednextCursor, so an agent can resume without recomputing stateResponse shaping — HTML stripping, URL normalization, and domain extraction remove upstream markup noise;
hn_search_content'sview: "compact"drops the two body-text fields that otherwise duplicate a hit's full textFenced upstream text — in
content[], every line of a body is block-quoted and titles are escaped only where they could break the surrounding Markdown, so a comment cannot pass for a server-authored line
Getting started
Public Hosted Instance
A public instance is available at https://hn.caseyjhand.com/mcp — no installation required. Point any MCP client at it via Streamable HTTP:
{
"mcpServers": {
"hn-mcp-server": {
"type": "streamable-http",
"url": "https://hn.caseyjhand.com/mcp"
}
}
}Self-Hosted / Local
Add to your MCP client configuration file:
{
"mcpServers": {
"hn-mcp-server": {
"type": "stdio",
"command": "bunx",
"args": ["@cyanheads/hn-mcp-server@latest"],
"env": {
"MCP_TRANSPORT_TYPE": "stdio",
"MCP_LOG_LEVEL": "info"
}
}
}
}Or with npx (no Bun required):
{
"mcpServers": {
"hn-mcp-server": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@cyanheads/hn-mcp-server"],
"env": {
"MCP_TRANSPORT_TYPE": "stdio",
"MCP_LOG_LEVEL": "info"
}
}
}
}Or with Docker:
{
"mcpServers": {
"hn-mcp-server": {
"type": "stdio",
"command": "docker",
"args": [
"run", "-i", "--rm",
"-e", "MCP_TRANSPORT_TYPE=stdio",
"ghcr.io/cyanheads/hn-mcp-server:latest"
]
}
}
}Prerequisites
Bun v1.4.0 or higher (or Node.js >= 24)
Installation
git clone https://github.com/cyanheads/hn-mcp-server.git
cd hn-mcp-server
bun installConfiguration
All configuration is via environment variables. No API keys required — HN APIs are public.
Variable | Description | Default |
| Max concurrent HTTP requests for batch item fetches (integer, 1–50). |
|
| Transport: |
|
| HTTP server port. |
|
| HTTP server host. |
|
| HTTP session handling: |
|
| Log level: |
|
| Directory for log files (Node.js only). |
|
See .env.example for the full list of optional overrides.
Running the server
Local development
Dev mode (auto-reload):
MCP_TRANSPORT_TYPE=stdio bun --watch src/index.ts # stdio MCP_TRANSPORT_TYPE=http bun --watch src/index.ts # HTTPBuild and run:
bun run rebuild bun run start:stdio # or start:httpRun checks and tests:
bun run devcheck # Lint, format, typecheck, security bun run test # Vitest test suite
Docker
docker build -t hn-mcp-server .
docker run --rm -p 3010:3010 hn-mcp-serverThe Dockerfile defaults to HTTP transport, stateless session mode, and logs to /var/log/hn-mcp-server. OpenTelemetry peer dependencies are installed by default — build with --build-arg OTEL_ENABLED=false to omit them.
Project structure
Directory | Purpose |
|
|
| Server-specific environment variable parsing and validation with Zod. |
| Tool definitions ( |
| HN Firebase + Algolia API client and domain types. |
| Unit and integration tests mirroring |
Development guide
See CLAUDE.md for development guidelines and architectural rules. The short version:
Handlers throw, framework catches — no
try/catchin tool logicUse
ctx.logfor request-scoped loggingAll tools are read-only — no auth scopes required
Wrap external API calls: validate raw → normalize to domain type → return output schema; never fabricate missing fields
Contributing
Issues are welcome. Run checks before submitting:
bun run devcheck
bun run testLicense
Apache-2.0 — see LICENSE for details.
This server cannot be deployed
Maintenance
Related MCP Connectors
Hacker News MCP — search and retrieve stories from Hacker News
Dive into the latest and greatest from the tech world with our Hacker News MCP server.
Deterministic Hacker News developer sentiment, themes & feature requests via MCP. No API key.
Related MCP Servers
- AlicenseAqualityFmaintenanceA Model Context Protocol (MCP) server that provides tools for searching and fetching information from Hacker News.476MIT
- AlicenseAqualityCmaintenanceMCP server for Hacker News that enables AI agents to search stories, read comments, and track tech trends via the public Hacker News API and Algolia HN Search.108 npm4MIT
- AlicenseAqualityCmaintenanceMCP 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.65MIT
- AlicenseAqualityFmaintenanceA read-only MCP server that enables browsing stories, reading comments, searching posts, and viewing user profiles on Hacker News.622 npm1MIT