Hacker News MCP server

Fetches and parses Hacker News stories using Cheerio, enabling tech news aggregation and trend analysis.
Back to servers
Provider
pskill9
Release date
Dec 28, 2024
Language
TypeScript
Stats
25 stars

This MCP server provides a convenient way to fetch and interact with Hacker News stories from different categories, giving you structured data that can be used within Claude or other AI assistants that support the Model Context Protocol.

Installation

To get started with the Hacker News MCP server:

  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. Configure the MCP server in your settings file:

For VSCode Claude extension:

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

Usage

Tool: get_stories

The server provides a single tool called get_stories that fetches stories from Hacker News.

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

Configuration

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

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

For the VSCode Claude extension, add to your VSCode Settings JSON:

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

Using Natural Language Queries

Once configured, you can interact with Claude using natural language:

  • "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"

Story Data Structure

Each story object contains:

  • title (string): The story title
  • url (string, optional): URL of the story
  • points (number): Number of upvotes
  • author (string): Username of the poster
  • time (string): Timestamp of posting
  • commentCount (number): Number of comments
  • rank (number): Position in the list

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later