SuperAPI AI Directory

hn-server

Parse Hacker News pages into structured data for top, new, ask, show and job stories.

Open website

About this tool

Purpose

hn-server is a Hacker News MCP server that, as an implementation of the Model Context Protocol (MCP), provides tools for fetching stories from Hacker News. By parsing the HTML content of news.ycombinator.com, it converts pages into structured data, making it convenient for AI assistants or programs to process further.

Main Capabilities

  • Fetch multiple types of stories: top (headlines), new (latest), ask (Ask HN), show (Show HN), jobs (job postings).
  • Return structured data, with each story containing: title, URL (url, which may be an internal HN link for text posts), points, author, timestamp (time), comment count (commentCount), rank.
  • Configurable number of stories to return (limit).
  • Has clear error handling and parameter validation.

Usage

  1. Clone the repository:git clone https://github.com/pskill9/hn-server(The installation command is not fully provided in the materials; please refer to the repository instructions).
  2. Install dependencies and build the server (the specific commands are not provided in the materials).
  3. Add the server configuration to the MCP settings file (the location depends on the system). For the VSCode Claude extension, add it to the corresponding configuration; for the Claude desktop app, add it to its configuration file.
  4. After configuration is complete, you can interact through the natural language interface of MCP-supporting clients such as Claude.

The server provides the tool get_stories, with the following parameters:

  • type(string): the type of stories to fetch, options are 'top', 'new', 'ask', 'show', 'jobs', default 'top'.
  • limit(number): the number of stories to return, range 1-30, default 10.

Example interactions:

  • "Show me the top 5 stories from Hacker News"
  • "What are the latest Ask HN posts?"
  • "Get me the top Show HN submissions from today"

Claude will automatically use the appropriate parameters to fetch the stories the user wants.

Technical Implementation

The server is built on the following technologies:

  • Model Context Protocol SDK
  • Axios for HTTP requests
  • Cheerio for HTML parsing

If you need to modify the server, you can edit src/index.ts.

Use Cases

  • Integrate with the Claude desktop app or VSCode Claude extension to query Hacker News content through natural language.
  • Development or automation tasks that need to obtain Hacker News story data in structured form.

Limitations

  • Story types only support top, new, ask, show, jobs.
  • The number of stories returned per request is limited to 1-30.
  • The server includes error handling for invalid story types, network failures, HTML parsing errors, and invalid parameter values, and errors will include appropriate error codes and descriptive messages.
  • The project uses the MIT License.

(Note: The materials do not provide complete installation dependency and build commands; please refer to the repository instructions when actually using it.)