Hacker News MCP Server

Hacker News MCP Server

An MCP server that enables AI assistants to access real-time Hacker News data including top stories, story details, comments, and search functionality.

Category
访问服务器

Tools

get_top_hackernews_stories

README

📰 Hacker News MCP Server

CI License: MIT <!-- Coming soon --> <!-- [npm version](https://www.npmjs.com/package/ -->

A Model Context Protocol (MCP) server that provides tools to fetch and interact with Hacker News content. This server enables AI assistants to access real-time Hacker News data including top stories, story details, comments, and search functionality.

🚀 Features

🛠️ Available Tools

  • get_top_stories - Fetch the latest top stories from Hacker News

    • Configurable count (1-100 stories)
    • Optional text content inclusion
    • Returns story metadata including title, URL, score, author, and comment count
  • get_story_details - Get detailed information about a specific story

    • Fetch complete story metadata
    • Optional comment inclusion with threaded structure
    • Optional markdown content extraction from linked articles
  • get_story_comments - Retrieve popular comments for a story

    • Configurable minimum score filtering
    • Adjustable comment thread depth (1-10 levels)
    • Limit number of comments returned (1-100)
    • Formatted as readable text with thread structure
  • search_stories - Search recent stories by keywords

    • Search through story titles, content, and URLs
    • Configurable time range (1-168 hours)
    • Limit results (1-50 stories)

📋 Prerequisites

  • Node.js 18+
  • npm or yarn
  • An MCP-compatible client (like Claude Desktop)

🔧 Installation

1. Clone the repository

git clone https://github.com/yourusername/hackernews-mcp.git
cd hackernews-mcp

2. Install dependencies

npm install

3. Build the server

npm run build

🎯 Usage

With Claude Desktop

Add the server to your Claude Desktop configuration:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%/Claude/claude_desktop_config.json

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

With Other MCP Clients

The server communicates via stdio and can be used with any MCP-compatible client:

node build/index.js

🔍 Example Usage

Once connected, you can ask your AI assistant things like:

  • "What are the top stories on Hacker News today?"
  • "Get details about Hacker News story 12345678"
  • "Show me comments for that viral AI story"
  • "Search for recent stories about TypeScript"

🛠️ Development

Build the project

npm run build

Watch mode for development

npm run watch

Lint and format the code

npm run lint
npm run format

Run the MCP Inspector

For debugging and testing:

npm run inspector

This will start the MCP Inspector, providing a web interface to test the server's tools and inspect the communication.

📦 Code Quality & Contributing

  • Code Quality:
    This project enforces code quality and style using ESLint and Prettier. All code is checked in CI (GitHub Actions) and must pass linting and formatting before merging.
  • Type Safety:
    All tool handlers use explicit type guards for runtime argument validation and robust TypeScript types.
  • CI/CD:
    Every push and pull request runs the full build, lint, and (future) test suite via GitHub Actions.
  • How to Contribute:
    1. Fork the repository
    2. Create a feature branch (git checkout -b feature/amazing-feature)
    3. Commit your changes (git commit -m 'Add amazing feature')
    4. Run npm run lint and npm run format before pushing
    5. Push to the branch (git push origin feature/amazing-feature)
    6. Open a Pull Request

📚 API Reference

get_top_stories

{
  count?: number;        // Number of stories (1-100, default: 30)
  include_text?: boolean; // Include story text content (default: false)
}

get_story_details

{
  story_id: number;           // Required: HN story ID
  include_comments?: boolean; // Include comments (default: false)
  include_markdown?: boolean; // Extract article as markdown (default: false)
}

get_story_comments

{
  story_id: number;    // Required: HN story ID
  min_score?: number;  // Minimum comment score (default: 1)
  max_depth?: number;  // Max thread depth (1-10, default: 3)
  limit?: number;      // Max comments (1-100, default: 20)
}

search_stories

{
  query: string;              // Required: Search keywords
  limit?: number;             // Max results (1-50, default: 20)
  time_range_hours?: number;  // Hours to search back (1-168, default: 24)
}

🏗️ Architecture

The server is built with:

  • TypeScript for type safety and developer experience
  • @modelcontextprotocol/sdk for MCP protocol implementation
  • axios for HTTP requests to Hacker News API
  • jsdom and turndown for HTML to Markdown conversion
  • private-ip for security (blocks private IP access)

Key Components

  • src/index.ts - Main server implementation with tool handlers
  • src/fetcher.ts - Utility class for fetching and converting web content
  • build/ - Compiled JavaScript output (auto-generated)

🔒 Security

  • Blocks requests to private IP addresses to prevent local network access
  • Rate limiting through Hacker News API natural limits
  • Input validation for all tool parameters
  • Error handling and graceful degradation

📜 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments

📞 Support

If you encounter any issues or have questions:

  1. Check the Issues page
  2. Use the MCP Inspector for debugging: npm run inspector
  3. Create a new issue with detailed information about your problem

Made with ❤️ for the MCP community

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选