hn_get_stories
Hn Get Stories
Fetch stories from an HN feed (top, new, best, ask, show, jobs), with title, URL, score, author, and comment count for each story.
feed必填countoffset
io.github.cyanheads由 GitHub 帳號 cyanheads 發布v0.6.0更新於 Oct 29, 2026
Browse Hacker News feeds, threads, and user profiles with full-text search.
唯讀的 Hacker News 存取:瀏覽排行榜、閱讀留言串、查看使用者資料,並全文搜尋貼文、留言、投票與徵才資訊。
Web executable,透過 Streamable HTTP。 遠端服務在工作區中設定後即可從網頁執行環境執行。
把這段提示詞貼上到 Claude Code、Codex、Cursor 等代理程式,或 SourceWeft 對話中。代理程式會讀取該伺服器的安裝指南,先向你展示發布者、端點和登入方式,經你同意後再把它新增到你的客戶端。金鑰不會寫進任何命令。
閱讀 https://sourceweft.com/mcp/io.github.cyanheads%2Fhn-mcp-server/install.md,並按其中說明把這個 MCP 伺服器接入我的客戶端。修改任何設定之前,先告訴我它的發布者、端點和登入方式,等我確認。不要把 API 金鑰寫進命令或我會提交的檔案;問我金鑰應從哪裡取得。把它新增到你客戶端的 mcpServers 設定中。
{
"mcpServers": {
"hn": {
"type": "http",
"url": "https://hn.caseyjhand.com/mcp"
}
}
}Browse Hacker News feeds, threads, and user profiles with full-text search via MCP. STDIO or Streamable HTTP.
Public Hosted Server: https://hn.caseyjhand.com/mcp
Hacker News feeds, threads, and profiles. Browse ranked feeds, read full comment threads, look up users, and search stories, comments, polls, and jobs by keyword, author, date, or score.
hn_get_stories tooltop, new, best, ask, show, jobs; count (default 30) and offset for pagination. One call serves at most 100 stories; a count up to 1,000 is served at 100, with a notice naming the next offsettotal, offset, and hasMore; while more stories remain, truncated is set and notice names the next offset, and a notice explains empty pages (empty feed, offset past end, or every item on the page deleted/flagged). The last page carries no truncationfailedIds with a notice naming the retry; a page where every item failed returns the classified upstream error instead of an empty listhn_get_thread toolitemId plus depth (default 3; 0 returns the item with no comments) and maxComments (default 50) capping one response across all levels, alongside a fixed 64,000-byte budget on each response surface (all content[] text, nextCursor included, and the structuredContent JSON) that cuts only between comments and always returns a page's first comment whole. One call resolves at most 10 levels and 200 comments; a depth up to 100 is served at 10 and a maxComments up to 1,000 at 200, with a notice naming the comment to pass as itemId or the nextCursor that reaches the restmaxComments, the byte budget, an upstream rate limit, or the call's 50-second time budget returns nextCursor; passing it back as cursor with the same itemId continues 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 the tool did not issue, an altered one, or one passed with a different itemId fails with invalid_cursorparent and storyId (the story or poll the discussion belongs to) for a comment, poll for a poll option, parts and resolved options (text and votes, at every depth) for a poll, and deleted/dead markers. The content[] heading names the type — a title, Comment by <author>, Poll option by <author> on poll <id> — and marks a deleted or dead rootdepth/parentId for tree reconstruction, plus childCount and an isOp flag when the comment author submitted the thread's story — on a comment root, the story at storyId, never the comment's own author. Dead and deleted comments are left out, but their live replies are still returned at their true depth, with parentId naming the omitted commenttruncated and truncationReason (count, size, rate_limited, time, or depth when 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. notice reports deleted/dead comments omitted during traversal and the next step: the cursor, or a larger depth or a comment id as itemId, naming by ID any omitted comment whose replies the depth limit cutfailedIds, and notice names them with the retry; failed comments ride in nextCursor, so paging on retries them rather than skipping them. The root item is still returned, and a failure is never passed off as a maxComments/depth limithn_get_user toolusername is case-sensitive and trimmed; includeSubmissions (default false) resolves recent submissions, with submissionCount (default 10) and submissionOffset paging through a long history. One call resolves at most 50 submissions; a submissionCount up to 1,000 is served at 50, with a notice naming the next submissionOffsetparent and a poll-option submission its poll, so either links back to what it answeredsubmissionOffset and the offset to send next, or a notice when the requested offset is past the end of the historyfailedIds with a notice naming the retry (and the budget, when it cut them); a window where every submission failed returns the classified upstream error — Timeout when the budget cut them alltextTruncated and pointing to hn_get_thread for the whole texthn_search_content toolquery — typo-tolerant, with the last term also matching as a prefix; wrap a term in double quotes to match it exactly and put - before one to exclude it — plus tags (story/comment/poll/job/ask_hn/show_hn/front_page), author (the exact, case-sensitive username), storyId, dateRange, and minPoints filters; sort by relevance or date; count (default 30) and page for pagination. One call serves at most 50 hits; a count up to 1,000 is served as the page of 50 starting at the requested page's first hit, with a notice naming the count: 50 page to pass next; a non-zero page whose first hit begins no page of 50 fails with count_page_unaligned, naming a count and page that start there and, when that count is under 25, the page of 50 that holds that hittags: "front_page" is the front page right now (about 30 stories), never past front pages; for an earlier window, use tags: "story" with dateRange and minPointsquery is optional when a filter is set — list Ask HN, Show HN, polls, or jobs on their own, or pass a story's storyId with tags: "comment" to search within one thread. No query and no filter fails with missing_query_or_filterquery: the leading http://, https://, or www. is dropped before searching, so submissions under either scheme, with or without www., all match. The output query and the notice show what was searcheddateRange bounds 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 with invalid_date_rangeminPoints applies to stories and polls — comments and jobs carry no points, so pairing it with tags: "comment" or "job" fails with min_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 to hn_get_thread to read the body. In full, a page over 64,000 bytes per response surface drops highlights.text from every hit (highlightsTextOmitted), then cuts the longest bodies to one shared length (textTruncated, with an hn_get_thread pointer) — every hit staystype (story, comment, poll, pollopt, job) when Algolia records one. Untagged searches also return poll options, which carry only an id, author, vote count, and date — hn_get_thread reads an option's text and poll. A poll hit has no storyId; its own id is the discussion roottext, though keywords don't search themhighlights.title, highlights.text, matchedWords) shows which terms matched and where; highlights.text is the matched body in full with <em> markerscriteria — each filter set (author trimmed, dateRange as the exclusive UTC bounds applied, to the second), plus sort, count, and view with defaults filled — so a saved result says what it answerstotalHits, page, and the actual reachable totalPages — not derived from totalHits, since broad queries report far more hits than Algolia will serve. totalHitsExact: false marks totalHits as an estimate, and reachableHits: 1000 marks a search that matches more than Algolia's 1,000-hit ceiling; the last page of such a search gets a notice naming the ceiling and narrower dateRange windows to reach the rest. While more pages remain, truncated is set and notice names the next page; a page past the end gets a notice naming the last valid page (or page: 0 past the ceiling)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:
HN_CONCURRENCY_LIMIT)instructions forwarded to LLM clients on initialize — item types, ID reuse across tools, case-sensitive usernames, field sparsityAgent-friendly output:
failedIds, apart from deleted, dead, or nonexistent items, rather than silently shrinking the result; each hn_get_thread, hn_get_stories, and hn_get_user call runs under one 50-second time budget, so hung fetches cannot hold it past an MCP client's 60-second timeout; hn_get_thread also 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 ladderitem_not_found, upstream_rate_limited, upstream_html, …) with per-reason recovery text (a rate limit passes on the upstream's Retry-After as retryAfter), and a depth/parentId pair on every comment so callers reconstruct the tree without guessing nestingoffset, submissionOffset, page) plus the exact next-offset value in notice, hn_search_content also echoes the criteria it searched with, and hn_get_thread returns a self-contained nextCursor, so an agent can resume without recomputing statehn_search_content's view: "compact" drops the two body-text fields that otherwise duplicate a hit's full text, and a 64,000-byte budget on each response surface cuts the longest bodies of an over-budget pagecontent[], 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 lineA public instance is available at https://hn.caseyjhand.com/mcp — no installation required. Point any MCP client at it via Streamable HTTP:
Add to your MCP client configuration file:
Or with npx (no Bun required):
Or with Docker:
All configuration is via environment variables. No API keys required — HN APIs are public.
See .env.example for the full list of optional overrides.
Dev mode (auto-reload):
Build and run:
Run checks and tests:
The 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.
See CLAUDE.md for development guidelines and architectural rules. The short version:
try/catch in tool logicctx.log for request-scoped loggingIssues are welcome. Run checks before submitting:
Apache-2.0 — see LICENSE for details.
來源:README.md,提交 a02e940
Hn Get Stories
Fetch stories from an HN feed (top, new, best, ask, show, jobs), with title, URL, score, author, and comment count for each story.
feed必填countoffsetHn Get Thread
Get an item and its comment tree as a threaded discussion, with child comments resolved recursively. Use depth 0 for an item-only lookup. A long thread comes back in pages: pass the returned nextCursor as cursor to continue.
depthcursoritemId必填maxCommentsHn Get User
Get an HN user profile with karma, about, and optionally their most recent submissions resolved into full items.
username必填submissionCountsubmissionOffsetincludeSubmissionsHn Search Content
Search Hacker News stories, comments, polls, and jobs via Algolia — by keyword, by filters alone, or both. Filterable by content type, author, parent story, date range, and minimum points.
pagesorttagsviewcountqueryauthorstoryIddateRangeminPoints已滿足適用檢查項的 100%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
{ "mcpServers": { "hn-mcp-server": { "type": "streamable-http", "url": "https://hn.caseyjhand.com/mcp" } }}{ "mcpServers": { "hn-mcp-server": { "type": "stdio", "command": "bunx", "args": ["@cyanheads/hn-mcp-server@latest"], "env": { "MCP_TRANSPORT_TYPE": "stdio", "MCP_LOG_LEVEL": "info" } } }}{ "mcpServers": { "hn-mcp-server": { "type": "stdio", "command": "npx", "args": ["-y", "@cyanheads/hn-mcp-server"], "env": { "MCP_TRANSPORT_TYPE": "stdio", "MCP_LOG_LEVEL": "info" } } }}{ "mcpServers": { "hn-mcp-server": { "type": "stdio", "command": "docker", "args": [ "run", "-i", "--rm", "-e", "MCP_TRANSPORT_TYPE=stdio", "ghcr.io/cyanheads/hn-mcp-server:latest" ] } }}git clone https://github.com/cyanheads/hn-mcp-server.gitcd hn-mcp-serverbun installMCP_TRANSPORT_TYPE=stdio bun --watch src/index.ts # stdioMCP_TRANSPORT_TYPE=http bun --watch src/index.ts # HTTPbun run rebuildbun run start:stdio # or start:httpbun run devcheck # Lint, format, typecheck, securitybun run test # Vitest test suitedocker build -t hn-mcp-server .docker run --rm -p 3010:3010 hn-mcp-serverbun run devcheckbun run test