HackerNews MCP Server

HackerNews MCP Server

Provides programmatic access to Hacker News content via the HN Algolia API. It enables AI assistants to search stories, retrieve comments, access user profiles, and explore the front page in real-time.

Category
Visit Server

README

Hackernews_mcp

CI npm version License: MIT TypeScript Node.js MCP

HackerNews MCP Server

A Model Context Protocol (MCP) server that provides programmatic access to Hacker News content via the HN Algolia API. This server enables AI assistants like Claude to search stories, retrieve comments, access user profiles, and explore the HN front page in real-time.

Features

  • โœ… 9 MCP Tools for comprehensive HN access
  • ๐Ÿ” Search: Stories by relevance or date, comments with filters
  • ๐Ÿ“ฐ Browse: Front page, latest stories, Ask HN, Show HN posts
  • ๐Ÿ‘ค Details: Retrieve specific stories with nested comments and user profiles
  • โšก Rate Limiting: Respects HN API limits (10,000 req/hr)
  • ๐Ÿ›ก๏ธ Type-Safe: Full TypeScript with strict mode
  • ๐Ÿ“Š Observable: Structured JSON logging with correlation IDs
  • ๐Ÿงช Tested: Unit, integration, and contract tests

Installation

NPM (when published)

npm install -g hn-mcp-server

From Source

git clone https://github.com/YOUR_USERNAME/hn-mcp-server.git
cd hn-mcp-server
npm install
npm run build
npm link

Quick Start (VS Code)

The fastest way to get started is with VS Code and GitHub Copilot:

  1. Clone and build:

    git clone <your-repo-url>
    cd hn-mcp-server
    npm install
    npm run build
    
  2. Open in VS Code:

    code .
    
  3. Reload VS Code (Ctrl+Shift+P โ†’ "Developer: Reload Window")

  4. Follow the complete setup checklist: docs/VSCODE_CHECKLIST.md

  5. Open Copilot Chat and try:

    @workspace What MCP tools are available?
    

    or

    Show me the top stories from Hacker News
    

๐Ÿ“– Step-by-step setup guide: docs/VSCODE_CHECKLIST.md

๐Ÿ“– For detailed VS Code setup instructions, see docs/VSCODE_SETUP.md

โš ๏ธ Tools not appearing? See docs/TROUBLESHOOTING_VSCODE.md

๐Ÿ’ก Tip: MCP support in VS Code is experimental. For the best experience, use Claude Desktop (see configuration below).

Configuration

VS Code with GitHub Copilot

The easiest way to use this server is directly in VS Code with GitHub Copilot:

  1. Build the server:

    npm run build
    
  2. Configuration is already set up in .vscode/mcp.json:

    {
      "hackernews": {
        "command": "node",
        "args": ["${workspaceFolder}/dist/index.js"],
        "env": {
          "DEBUG": "0"
        }
      }
    }
    
  3. Reload VS Code or restart the Copilot extension

  4. Test it by asking Copilot:

    • "Show me the top stories from Hacker News"
    • "Search HN for stories about AI"
    • "Get the user profile for 'pg'"

Claude Desktop

Add to your Claude Desktop configuration:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
Linux: ~/.config/claude/claude_desktop_config.json

{
  "mcpServers": {
    "hackernews": {
      "command": "hn-mcp-server"
    }
  }
}

Or if installed from source:

{
  "mcpServers": {
    "hackernews": {
      "command": "node",
      "args": ["/path/to/hn-mcp-server/dist/index.js"]
    }
  }
}

Restart Claude Desktop to activate the server.

Available Tools

1. search_stories

Search HN stories by relevance with advanced filtering.

{
  query: "artificial intelligence",    // Search term
  tags: "story,front_page",           // Filter by tags
  numericFilters: "points>=100",      // Minimum points
  page: 0,                            // Pagination
  hitsPerPage: 20                     // Results per page
}

2. search_by_date

Search stories/comments sorted by date (most recent first).

{
  query: "TypeScript",
  tags: "story",
  numericFilters: "created_at_i>1640000000",  // Unix timestamp
  page: 0,
  hitsPerPage: 20
}

3. search_comments

Search comments with optional story/author filtering.

{
  query: "React hooks",
  tags: "author_pg",              // Filter by author
  sortByDate: false,              // Sort by relevance
  page: 0,
  hitsPerPage: 20
}

4. get_front_page

Retrieve current HN front page stories.

{
  page: 0,
  hitsPerPage: 30
}

5. get_latest_stories

Get most recently submitted stories.

{
  page: 0,
  hitsPerPage: 20
}

6. get_ask_hn

Retrieve Ask HN posts (community questions).

{
  page: 0,
  hitsPerPage: 20
}

7. get_show_hn

Retrieve Show HN posts (project showcases).

{
  page: 0,
  hitsPerPage: 20
}

8. get_story

Get a specific story by ID with full nested comment tree.

{
  id: 8863  // Famous "How to Start a Startup" post
}

9. get_user

Retrieve user profile by username.

{
  username: "pg"  // Paul Graham
}

Example Usage in Claude

Search for AI stories:

Show me the top stories about AI from Hacker News

Get front page:

What's currently on the Hacker News front page?

Find user information:

Tell me about the HN user 'pg'

Advanced search:

Find recent stories about TypeScript with at least 50 points

Development

Prerequisites

  • Node.js 20 LTS or higher
  • npm or yarn

Setup

git clone https://github.com/YOUR_USERNAME/hn-mcp-server.git
cd hn-mcp-server
npm install

Commands

npm run build        # Compile TypeScript
npm run dev          # Watch mode
npm test             # Run all tests
npm run test:watch   # Test watch mode
npm run lint         # Lint code
npm run format       # Format code
npm run check        # Lint + type check
npm run ci           # Full CI workflow

Project Structure

src/
โ”œโ”€โ”€ index.ts           # Main entry point
โ”œโ”€โ”€ server.ts          # MCP server initialization
โ”œโ”€โ”€ tools/             # MCP tool implementations (one per file)
โ”‚   โ”œโ”€โ”€ search-stories.ts
โ”‚   โ”œโ”€โ”€ get-story.ts
โ”‚   โ””โ”€โ”€ ...
โ”œโ”€โ”€ lib/               # Shared utilities
โ”‚   โ”œโ”€โ”€ hn-client.ts   # HN API client
โ”‚   โ”œโ”€โ”€ rate-limiter.ts
โ”‚   โ”œโ”€โ”€ logger.ts
โ”‚   โ”œโ”€โ”€ errors.ts
โ”‚   โ””โ”€โ”€ validators.ts
โ””โ”€โ”€ types/             # TypeScript type definitions
    โ”œโ”€โ”€ hn-api.ts
    โ””โ”€โ”€ mcp.ts

Rate Limiting

The HN Algolia API has a limit of 10,000 requests per hour per IP address. This server:

  • Tracks request count automatically
  • Warns at 90% (9,000 requests)
  • Throws error at 95% (9,500 requests)
  • Resets counter every hour

Logging

Structured JSON logging with correlation IDs:

# Enable debug logging
DEBUG=1 hn-mcp-server

# View logs in Claude Desktop
# macOS: ~/Library/Logs/Claude/mcp*.log
# Windows: %APPDATA%\Claude\logs\mcp*.log
# Linux: ~/.config/claude/logs/mcp*.log

Error Handling

All errors return MCP-formatted responses with:

  • Clear error messages
  • Error codes (RATE_LIMIT_EXCEEDED, ITEM_NOT_FOUND, etc.)
  • Context for debugging
  • Suggested user actions

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes following the constitution principles
  4. Run quality gates (npm run ci)
  5. Commit (git commit -m 'Add amazing feature')
  6. Push (git push origin feature/amazing-feature)
  7. Open a Pull Request

License

MIT License - see LICENSE file for details.

Links

Support


Built with โค๏ธ following MCP best practices and constitution principles

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured