Hacker News MCP 服务器是一个实用的工具,它能从 Hacker News 获取各类故事。通过解析 news.ycombinator.com 的 HTML 内容,服务器可为热门、最新、提问、展示、工作等不同类型的故事提供结构化数据,满足多样的信息获取需求。
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(字符串):要获取的故事类型,可选值为 'top'、'new'、'ask'、'show'、'jobs',默认值为 'top'。limit(数字):要返回的故事数量,范围是 1 - 30,默认值为 10。示例代码如下:
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 集成,您需要完成以下步骤:
{
"mcpServers": {
"hacker-news": {
"command": "node",
"args": ["/path/to/hn-server/build/index.js"]
}
}
}
该服务器具备稳健的错误处理机制,可处理以下异常情况:
错误会以适当的错误代码和描述消息返回,方便您进行排查和处理。
欢迎大家积极贡献代码!如果您有改进建议或新功能想法,请随时提交 Pull Request。
本项目采用 MIT License,您可以在自己的项目中自由使用。