Token导航 LogoToken导航TokenDH.com
Hn MCP Server logo
开发工具stdio官方级别未说明来源级核验

Hn MCP Server

MCP Server

hn-mcp-server

一个通过Model Context Protocol提供HackerNews内容搜索、检索和分析的服务,适用于AI代理和开发者。

工具数

4

提示词数

0

GitHub Stars

0

资源数

0
PowerShell开发工具JavaScriptClaude内容分析Claude DesktopClaude

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

hillaryTse

提供方

hillaryTse

最后核验

2026/5/17 20:19

运行时

Node.js

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

npx hn-mcp-server

详细介绍

HackerNews MCP服务器

![License: MIT](https://opensource.org/licenses/MIT) ](https://nodejs.org) ![TypeScript](https://www.typescriptlang.org/)

🚀 用于与HackerNews交互的模型上下文协议服务器

使AI代理和开发人员能够通过以下方式搜索、检索和分析HackerNews内容 模型上下文协议(MCP)此服务器提供用于高级搜索、首页检索、使用评论树的详细帖子访问和用户配置文件查找的工具。

______________________________________________________________________

✨ 特性

  • 🔍 高级搜索 -使用关键字搜索、过滤器(作者、日期、点、评论)和灵活排序查找帖子
  • 📰 首页访问 -使用分页检索当前HackerNews首页内容
  • 💬 完整评论树 -使用嵌套评论结构访问完整的讨论线程
  • 👤 用户档案 -查找用户信息,包括业力、账户年龄和个人信息
  • 速率限制 -符合HN API限制条件的自动速率限制(10000请求/小时)
  • 🛡️ 类型安全 -采用TypeScript严格模式和全面验证构建
  • 📚 证据充分的 -完整的API文档和使用示例
  • 经过彻底测试 -合同、集成和单元测试的测试覆盖率超过90%

______________________________________________________________________

📋 目录

______________________________________________________________________

📦 安装

先决条件

  • Node.js 22.0.0或更高
  • npm 10.0.0或更高

通过npm安装

npm install -g hn-mcp-server

从源代码安装

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

______________________________________________________________________

🚀 快速开始

使用克劳德桌面

添加到您的 claude_desktop_config.json:

{
  "mcpServers": {
    "hackernews": {
      "command": "npx",
      "args": ["-y", "hn-mcp-server"]
    }
  }
}

配置文件位置:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • 视窗: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

配置后,重新启动Claude Desktop。HackerNews工具将在您的对话中可用。

使用VS代码+GitHub副本

添加到您的VS代码 settings.json:

{
  "github.copilot.chat.mcp.servers": {
    "hackernews": {
      "command": "npx",
      "args": ["-y", "hn-mcp-server"]
    }
  }
}

试验装置

# Verify server starts
hn-mcp-server

# Or via npx
npx hn-mcp-server

服务器将启动并等待MCP客户端通过stdio连接。

______________________________________________________________________

💡 使用示例

示例1:搜索AI/ML帖子

自然语言 (克劳德语):

Search HackerNews for machine learning articles from the last month with more than 100 points

示例2:浏览首页

自然语言:

Show me what's currently on the HackerNews front page

示例3:阅读讨论

自然语言:

Get the full discussion for HackerNews post 39381647 including all comments

示例4:研究用户

自然语言:

Tell me about the HackerNews user 'pg'

示例5:高级过滤

自然语言:

Find Show HN posts by user 'todsacerdoti' from 2024 with at least 50 points

有关更多详细示例,请参阅 快速入门指南.

______________________________________________________________________

🛠️ 可用工具

search_posts

使用高级过滤选项搜索HackerNews帖子。

参数:

  • query (字符串,可选)-搜索关键字
  • tags (数组,可选)-内容类型筛选器: story, comment, poll, show_hn, ask_hn, front_page
  • author (字符串,可选)-按用户名筛选
  • storyId (数字,可选)-按故事ID过滤评论
  • minPoints, maxPoints (数字,可选)-积分阈值
  • minComments, maxComments (数量,可选)-评论计数阈值
  • dateAfter, dateBefore (字符串,可选)-日期范围过滤器(ISO 8601)
  • sortByDate (布尔值,可选)-按日期(true)或相关性(false,默认)排序
  • page (数字,可选)-页码(0索引,默认值:0)
  • hitsPerPage (数字,可选)-每页结果(1-100,默认值:20)

get_front_page

检索当前HackerNews头版帖子。

参数:

  • page (数字,可选)-页码(0索引,默认值:0)
  • hitsPerPage (数字,可选)-每页结果(1-30,默认值:30)

get_post

获取特定帖子的完整详细信息,包括评论树。

参数:

  • postId (字符串,必填)-HackerNews帖子ID

get_user

检索用户配置文件信息。

参数:

  • username (字符串,必填)-HackerNews用户名(1-15个字符)

______________________________________________________________________

⚙️ 配置

速率限制

服务器自动遵守HackerNews API的速率限制 每个IP地址每小时10000个请求.

  • 使用令牌桶算法跟踪请求
  • 在80%、90%、95%的使用率下记录警告
  • 超过速率限制时返回错误
  • 随着时间的推移自动重新填充令牌

错误处理

所有工具都返回结构化错误:

{
  "error": "Human-readable error message",
  "type": "validation_error | not_found | api_error | rate_limit | unknown",
  "details": { "additional": "context" }
}

______________________________________________________________________

👨‍💻 发展

设置

# Clone repository
git clone https://github.com/yourusername/hn-mcp-server.git
cd hn-mcp-server

# Install dependencies
npm install

# Build
npm run build

开发工作流程

# Watch mode (auto-rebuild on changes)
npm run dev

# Run tests
npm test

# Run tests in watch mode
npm run test:watch

# Run tests with coverage
npm run test:coverage

# Lint code
npm run lint

# Fix lint issues
npm run lint:fix

# Format code
npm run format

# Type check without building
npm run typecheck

测试

该项目遵循测试驱动开发(TDD),有三个测试层:

  • 合同测试:验证外部API响应架构
  • 集成测试:使用模拟API端到端测试工具工作流
  • 单元测试:单独测试单个功能

保险范围要求:行、函数、分支和语句的最小值为90%。

# Run all tests
npm test

# View coverage report
npm run test:coverage
open coverage/index.html  # macOS
start coverage/index.html # Windows

项目结构

src/
├── index.ts                # Main entry point, MCP server setup
├── types/                  # TypeScript type definitions
│   ├── hn-api.ts          # HackerNews API response types
│   └── mcp-tools.ts       # MCP tool schemas
├── tools/                  # MCP tool implementations
│   ├── search.ts          # search_posts tool
│   ├── front-page.ts      # get_front_page tool
│   ├── get-post.ts        # get_post tool
│   ├── get-user.ts        # get_user tool
│   └── index.ts           # Tool registry
├── services/               # Business logic
│   ├── hn-api-client.ts   # HackerNews API client
│   └── rate-limiter.ts    # Rate limiting
└── lib/                    # Utilities
    ├── validation.ts       # Input validation helpers
    └── error-handler.ts    # Error handling utilities

tests/
├── contract/               # API contract tests
├── integration/            # Tool integration tests
└── unit/                   # Unit tests

代码的风格

  • 语言:启用严格模式的TypeScript 5.x
  • 过梁:生物特征(无ESLint或Prettier)
  • 格式化:2空格缩进,100个字符线宽,双引号
  • 类型安全:没有 any 类型,导出函数的显式返回类型

______________________________________________________________________

🤝 贡献

欢迎投稿!请遵循以下指南:

  1. 分叉存储库
  2. 创建要素分支: git checkout -b feature/my-feature
  3. 遵循TDD:先写测试,然后实现
  4. 确保测试通过: npm test
  5. 确保棉绒通过: npm run lint
  6. 保持覆盖范围:保持在90%+
  7. 提交更改: git commit -m "Add my feature"
  8. 推送到分支: git push origin feature/my-feature
  9. 打开拉取请求

发展原则

该项目遵循严格的质量标准,记录在 .specify/memory/constitution.md:

  • 代码质量第一:TypeScript严格模式,否 any 类型
  • 测试驱动开发:实施前的测试
  • 文件优先:所有功能的完整文档
  • 最新稳定版本:最新的依赖关系
  • 重复使用而非再造:利用现有库

______________________________________________________________________

📚 文档

______________________________________________________________________

📝 许可证

此项目根据MIT许可证获得许可-请参阅 许可证 文件以获取详细信息。

______________________________________________________________________

🙏 致谢

______________________________________________________________________

🐛 支持

______________________________________________________________________

内置❤️ 使用TypeScript、MCP SDK和Biome

目录标签

目录标签

PowerShell开发工具JavaScriptClaude内容分析本地部署HackerNews数据检索API服务开发者工具

支持客户端

Claude DesktopClaude

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

none

运行时(runtime,运行环境)

Node.js

部署方式(deploymentType,部署类型)

remote-capable

来源包(packageName,安装包名)

hn-mcp-server

工具数量(toolCount,工具数)

4

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdiononeremote-capable

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP