Hacker新闻阅读器MCP服务器

一个用于获取Hacker News讨论和文章内容的MCP服务器,优化了LLM消费的紧凑、高效的令牌格式化输出。

  • by Malayke
  • Python
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 Malayke/hackernews-mcp

使用说明

黑客新闻阅读器MCP服务器

A. 模型上下文协议 (MCP)服务器,用于获取黑客新闻讨论和文章内容。针对LLM消费进行了优化,具有紧凑、令牌高效的格式。

特性

✅ 获取完整的黑客新闻讨论线程
✅ 以markdown格式删除链接文章内容
✅ LLM优化输出(紧凑嵌套回复)
✅ 接受HN URL和项目ID
✅ 处理边缘案例(文本帖子、Ask HN、删除评论)
✅ 由Firecrawl提供支持,可实现强大的文章提取

安装

使用GitHub上的uvx(推荐)

uvx --from git+https://github.com/Malayke/hackernews-mcp.git hackernews-mcp

使用uv pip

uv pip install git+https://github.com/Malayke/hackernews-mcp.git

使用pip

pip install git+https://github.com/Malayke/hackernews-mcp.git

用法

作为MCP服务器

添加到您的MCP设置配置中(例如,在Claude Desktop或其他MCP客户端中):

{
  "mcpServers": {
    "hackernews-mcp": {
      "command": "uvx",
      "args": [
        "--from",
        "git+https://github.com/Malayke/hackernews-mcp.git",
        "hackernews-mcp"
      ],
      "env": {
        "FIRECRAWL_API_KEY": "your_api_key_here"
      }
    }
  }
}

或者,如果你已经用pip/uv pip安装了它:

{
  "mcpServers": {
    "hackernews-mcp": {
      "command": "hackernews-mcp",
      "env": {
        "FIRECRAWL_API_KEY": "your_api_key_here"
      }
    }
  }
}

环境变量

必修的:

  • FIRECRAWL_API_KEY -你的 火爬 API密钥

创建一个 .env 文件:

FIRECRAWL_API_KEY=your_api_key_here

可用工具

get_hn_content

获取黑客新闻评论和链接的文章内容。

输入:

  • hn_url:HN URL或项目ID
    • 完整URL: https://news.ycombinator.com/item?id=46130187
    • 只是ID: 46130187

输出: 降价与以下内容相结合:

  1. 文章内容 -降价格式的废品
  2. HN讨论 -带有元数据的格式化评论线程

例子:

{
  "hn_url": "https://news.ycombinator.com/item?id=46130187"
}

输出格式

该工具返回LLM优化的内容:

# ARTICLE CONTENT

[Article markdown content here...]

---

# HACKER NEWS DISCUSSION

STORY: Article Title
URL: https://example.com/article
AUTHOR: username | POINTS: 123 | TIME: 2 hours ago
TOTAL_COMMENTS: 45

COMMENT #1
COMMENT [author @ time] ID: 123456
Comment text here...
  REPLY [author2 @ time] ID: 123457
  Reply text here...
    REPLY [author3 @ time] ID: 123458
    Nested reply text...

COMMENT #2
...

发展

本地设置

# Clone the repository
git clone https://github.com/Malayke/hackernews-mcp.git
cd hackernews-mcp

# Install dependencies with uv
uv sync

# Set up environment
echo "FIRECRAWL_API_KEY=your_api_key_here" > .env

# Run the server
uv run server.py

测试

# Test the MCP server
uv run python test_mcp_server.py

在开发模式中使用

对于具有实时变化的本地开发:

{
  "mcpServers": {
    "hackernews-mcp": {
      "command": "uv",
      "args": [
        "run",
        "--directory",
        "/path/to/hackernews-mcp",
        "python",
        "server.py"
      ],
      "env": {
        "FIRECRAWL_API_KEY": "your_api_key_here"
      }
    }
  }
}

需求

  • Python 3.11+
  • Firecrawl API密钥(用于文章抓取)

依赖项

  • mcp -模型上下文协议SDK
  • requests -HTTP请求
  • beautifulsoup4 -HTML解析
  • firecrawl-py -文章内容提取
  • python-dotenv -环境变量管理

许可证

MIT许可证-请参阅 许可证 文件以获取详细信息。

贡献

欢迎投稿!请随时提交拉取请求。

链接

支持

有关问题、疑问或贡献,请访问 GitHub 仓库.