Hacker News Mcpサーバー
概要
hn-serverとは?
hn-serverは、ユーザー### pskill9がGitHubに作成した公開リポジトリです。これは、コンピュータサイエンスと起業家精神に焦点を当てた人気のソーシャルニュースウェブサイトであるHacker Newsのサーバー実装として機能します。このプロジェクトにより、ユーザーはサーバーサイドアプリケーションを通じてHacker Newsと対話でき、ニュース記事の取得、ストーリーの投稿、コメントなどの機能をHacker News APIに従って利用できます。
hn-serverの特徴
- 公開アクセス:リポジトリは一般に公開されており、誰でもプロジェクトを閲覧、フォーク、または貢献することができます。
- MITライセンス:プロジェクトはMITライセンスの下でライセンスされており、ユーザーはソフトウェアを使用、コピー、変更、配布することができます。
- アクティブなコミュニティ:リポジトリは35のスターと8のフォークを獲得しており、関心とコミュニティの関与が高まっています。
- 簡単な統合:サーバーはさまざまなアプリケーションと簡単に統合でき、Hacker Newsデータを利用したい開発者にシームレスな体験を提供します。
- ドキュメント:サーバーを効果的にセットアップし使用する方法を理解するための包括的なドキュメントが利用可能です。
hn-serverの使い方
-
リポジトリをクローンする:まず、次のコマンドを使用してhn-serverリポジトリをローカルマシンにクローンします。
git clone https://github.com/pskill9/hn-server.git
-
依存関係をインストールする:プロジェクトディレクトリに移動し、必要な依存関係をインストールします。これは通常、プロジェクトのセットアップに応じてnpmやyarnなどのパッケージマネージャを使用して行います。
-
サーバーを実行する:依存関係をインストールした後、ドキュメントに指定されたコマンド(通常は
npm start
のようなもの)を使用してサーバーを実行できます。 -
APIと対話する:サーバーが実行されている間、Hacker News APIエンドポイントと対話してニュース記事を取得したり、ストーリーを投稿したりできます。
-
貢献する:プロジェクトに貢献したい場合は、リポジトリをフォークし、変更を加え、プルリクエストを提出してください。
よくある質問
hn-serverで使用されている技術は何ですか?
hn-serverは通常、JavaScriptとNode.jsを使用して構築されており、サーバーサイドの操作を促進するためにさまざまなライブラリやフレームワークを活用しています。
hn-serverプロジェクトに貢献できますか?
はい!貢献は歓迎です。リポジトリをフォークし、変更を加え、レビューのためにプルリクエストを提出できます。
hn-serverをローカルで実行する方法はありますか?
もちろんです!リポジトリをクローンし、ドキュメントのセットアップ手順に従ってローカルマシンで実行できます。
MITライセンスの目的は何ですか?
MITライセンスは、ユーザーがソフトウェアを自由に使用、変更、配布できることを許可し、オープンソースのコラボレーションと革新を促進します。
問題やバグを報告するにはどうすればよいですか?
「Issues」タブに移動し、遭遇している問題の詳細を含む新しい問題を提出することで、問題を報告できます。
詳細
Hacker News MCP Server
A Model Context Protocol (MCP) server that provides tools for fetching stories from Hacker News. This server parses the HTML content from news.ycombinator.com and provides structured data for different types of stories (top, new, ask, show, jobs).
<a href="https://glama.ai/mcp/servers/oge85xl22f"><img width="380" height="200" src="https://glama.ai/mcp/servers/oge85xl22f/badge" alt="Hacker News MCP server" /></a>
Features
- Fetch different types of stories (top, new, ask, show, jobs)
- Get structured data including titles, URLs, points, authors, timestamps, and comment counts
- Configurable limit on number of stories returned
- Clean error handling and validation
Installation
- Clone the repository:
git clone https://github.com/pskill9/hn-server
cd hn-server
- Install dependencies:
npm install
- Build the server:
npm run build
- Add to your MCP settings configuration file (location depends on your system):
For VSCode Claude extension:
{
"mcpServers": {
"hacker-news": {
"command": "node",
"args": ["/path/to/hn-server/build/index.js"]
}
}
}
Usage
The server provides a tool called get_stories
that can be used to fetch stories from Hacker News.
Tool: get_stories
Parameters:
type
(string): Type of stories to fetch- Options: 'top', 'new', 'ask', 'show', 'jobs'
- Default: 'top'
limit
(number): Number of stories to return- Range: 1-30
- Default: 10
Example usage:
use_mcp_tool with:
server_name: "hacker-news"
tool_name: "get_stories"
arguments: {
"type": "top",
"limit": 5
}
Sample output:
[
{
"title": "Example Story Title",
"url": "https://example.com/story",
"points": 100,
"author": "username",
"time": "2024-12-28T00:03:05",
"commentCount": 50,
"rank": 1
},
// ... more stories
]
Integrating with Claude
To use this MCP server with Claude, you'll need to:
- Have the Claude desktop app or VSCode Claude extension installed
- Configure the MCP server in your settings
- Use Claude's natural language interface to interact with Hacker News
Configuration
For the Claude desktop app, add the server configuration to:
// ~/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"]
}
}
}
For the VSCode Claude extension, add to:
// VSCode Settings JSON
{
"mcpServers": {
"hacker-news": {
"command": "node",
"args": ["/path/to/hn-server/build/index.js"]
}
}
}
Example Interactions
Once configured, you can interact with Claude using natural language to fetch Hacker News stories. Examples:
- "Show me the top 5 stories from Hacker News"
- "What are the latest Ask HN posts?"
- "Get me the top Show HN submissions from today"
Claude will automatically use the appropriate parameters to fetch the stories you want.
Story Object Structure
Each story object contains:
title
(string): The story titleurl
(string, optional): URL of the story (may be internal HN URL for text posts)points
(number): Number of upvotesauthor
(string): Username of the postertime
(string): Timestamp of when the story was postedcommentCount
(number): Number of commentsrank
(number): Position in the list
Development
The server is built using:
- TypeScript
- Model Context Protocol SDK
- Axios for HTTP requests
- Cheerio for HTML parsing
To modify the server:
- Make changes to
src/index.ts
- Rebuild:
npm run build
Error Handling
The server includes robust error handling for:
- Invalid story types
- Network failures
- HTML parsing errors
- Invalid parameter values
Errors are returned with appropriate error codes and descriptive messages.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
MIT License - feel free to use this in your own projects.
サーバー設定
{
"mcpServers": {
"hn-server": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"ghcr.io/metorial/mcp-container--pskill9--hn-server--hn-server",
"node ./build/index.js"
],
"env": {}
}
}
}