Skip to main content
Glama
Hacker News MCP

Hacker News MCP

by pskill9

Hacker News MCP Server

A Model Context Protocol (MCP) server that provides tools for fetching stories from Hacker News. This server parses the HTML content from news.ycombinator.com and provides structured data for different types of stories (top, new, ask, show, jobs).

Features

  • Fetch different types of stories (top, new, ask, show, jobs)

  • Get structured data including titles, URLs, points, authors, timestamps, and comment counts

  • Configurable limit on number of stories returned

  • Clean error handling and validation

Related MCP server: necl-hn-mcp

Installation

  1. Clone the repository:

git clone https://github.com/pskill9/hn-server
cd hn-server
  1. Install dependencies:

npm install
  1. Build the server:

npm run build
  1. Add to your MCP settings configuration file (location depends on your system):

For VSCode Claude extension:

{
  "mcpServers": {
    "hacker-news": {
      "command": "node",
      "args": ["/path/to/hn-server/build/index.js"]
    }
  }
}

Usage

The server provides a tool called get_stories that can be used to fetch stories from Hacker News.

Tool: get_stories

Parameters:

  • type (string): Type of stories to fetch

    • Options: 'top', 'new', 'ask', 'show', 'jobs'

    • Default: 'top'

  • limit (number): Number of stories to return

    • Range: 1-30

    • Default: 10

Example usage:

use_mcp_tool with:
server_name: "hacker-news"
tool_name: "get_stories"
arguments: {
  "type": "top",
  "limit": 5
}

Sample output:

[
  {
    "title": "Example Story Title",
    "url": "https://example.com/story",
    "points": 100,
    "author": "username",
    "time": "2024-12-28T00:03:05",
    "commentCount": 50,
    "rank": 1
  },
  // ... more stories
]

Integrating with Claude

To use this MCP server with Claude, you'll need to:

  1. Have the Claude desktop app or VSCode Claude extension installed

  2. Configure the MCP server in your settings

  3. Use Claude's natural language interface to interact with Hacker News

Configuration

For the Claude desktop app, add the server configuration to:

// ~/Library/Application Support/Claude/claude_desktop_config.json (macOS)
// %APPDATA%\Claude\claude_desktop_config.json (Windows)
{
  "mcpServers": {
    "hacker-news": {
      "command": "node",
      "args": ["/path/to/hn-server/build/index.js"]
    }
  }
}

For the VSCode Claude extension, add to:

// VSCode Settings JSON
{
  "mcpServers": {
    "hacker-news": {
      "command": "node",
      "args": ["/path/to/hn-server/build/index.js"]
    }
  }
}

Example Interactions

Once configured, you can interact with Claude using natural language to fetch Hacker News stories. Examples:

  • "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 you want.

Claude using the Hacker News MCP server

Story Object Structure

Each story object contains:

  • title (string): The story title

  • url (string, optional): URL of the story (may be internal HN URL for text posts)

  • points (number): Number of upvotes

  • author (string): Username of the poster

  • time (string): Timestamp of when the story was posted

  • commentCount (number): Number of comments

  • rank (number): Position in the list

Development

The server is built using:

  • TypeScript

  • Model Context Protocol SDK

  • Axios for HTTP requests

  • Cheerio for HTML parsing

To modify the server:

  1. Make changes to src/index.ts

  2. Rebuild:

npm run build

Error Handling

The server includes robust error handling for:

  • Invalid story types

  • Network failures

  • HTML parsing errors

  • Invalid parameter values

Errors are returned with appropriate error codes and descriptive messages.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License - feel free to use this in your own projects.

Available Tools

1 tool
get_storiesC

Get stories from Hacker News

Inputs: limit, type.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3/5.0

    Scored across 1 tool

    Disambiguation5/5

    With only one tool, there is no possibility of ambiguity or overlap between tools. The single tool 'get_stories' has a clearly distinct and singular purpose.

    Naming Consistency5/5

    The naming is trivially consistent as there is only one tool. The tool name 'get_stories' follows a clear verb_noun pattern, which would be consistent if more tools were added.

    Tool Count2/5

    A single tool is too few for a server named 'Hacker News MCP', which implies broader functionality. While 'get_stories' is a core operation, the server lacks tools for other common actions like getting comments, user profiles, or posting, making it feel thin and incomplete.

    Completeness1/5

    The tool surface is severely incomplete for a Hacker News API. It only provides 'get_stories', missing essential operations such as retrieving comments, user details, search functionality, or any write operations, which are typical for such a domain.

    Maintenance

    ActivityInactive
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables AI assistants to access Hacker News content through 9 comprehensive tools for fetching stories, comments, user profiles, and job postings. Supports flexible output formats, pagination, and various story categories (top, new, best, Ask HN, Show HN).
      -
    • A
      license
      A
      quality
      C
      maintenance
      Provides AI agents with access to Hacker News data including top stories, story details, comment threads, and full-text search for content research and trend monitoring.
      5
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables searching and retrieving top stories and individual items from Hacker News, with access to scores, comments, authors, and timestamps.
      144 npm
      MIT