这是一个提供从Hacker News获取故事工具的Model Context Protocol (MCP)服务器。该服务器解析news.ycombinator.com的HTML内容,并提供不同类型故事(顶级、最新、提问、展示、工作)的结构化数据。
<a href="https://glama.ai/mcp/servers/oge85xl22f"><img width="380" height="200" src="https://gips1.baidu.com/it/u=774834935,2091641471&fm=3081&app=3081&f=PNG?w=760&h=400" alt="Hacker News MCP 服务器" /></a>
git clone https://github.com/pskill9/hn-server
cd hn-server
npm install
npm run build
对于VSCode Claude扩展:
{
"mcpServers": {
"hacker-news": {
"command": "node",
"args": ["/path/to/hn-server/build/index.js"]
}
}
}
该服务器提供了一个名为get_stories的工具,可以用来从Hacker News获取故事。
参数:
type (字符串):要获取的故事类型
limit (数字):要返回的故事数量
示例用法:
use_mcp_tool with:
server_name: "hacker-news"
tool_name: "get_stories"
arguments: {
"type": "top",
"limit": 5
}
示例输出:
[
{
"title": "示例故事标题",
"url": "https://example.com/story",
"points": 100,
"author": "用户名",
"time": "2024-12-28T00:03:05",
"commentCount": 50,
"rank": 1
},
// ... 更多故事
]
要使用此MCP服务器与Claude集成,您需要:
对于Claude桌面应用,添加服务器配置到:
// ~/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"]
}
}
}
对于VSCode Claude扩展,添加到:
// VSCode 设置 JSON
{
"mcpServers": {
"hacker-news": {
"command": "node",
"args": ["/path/to/hn-server/build/index.js"]
}
}
}
配置完成后,您可以使用自然语言与Claude互动以获取Hacker News故事。示例:
Claude会自动使用适当的参数来获取您想要的故事。

每个故事对象包含:
title (字符串):故事标题url (字符串,可选):故事的URL(对于文本帖子可能是内部HN URL)points (数字):点赞数author (字符串):发帖用户的用户名time (字符串):故事发布的时间戳commentCount (数字):评论数量rank (数字):在列表中的位置服务器构建使用:
要修改服务器:
src/index.tsnpm run build
服务器包括对以下情况的健壮错误处理:
错误以适当的错误码和描述性消息返回。
欢迎贡献!请随时提交Pull Request。
MIT许可证 - 欢迎在您的项目中使用。 </中文翻译>