Building an MCP server: Complete Hacker News integration

June 8, 2025 (1mo ago)

When I started experimenting with the Model Context Protocol (MCP), I was fascinated by its potential to bridge AI tools with external data sources. As a regular Hacker News reader, I thought: what if Claude could fetch and analyze HN posts in real-time?

That's how mcp-hacker-news was born, a TypeScript-based MCP server that connects the official Hacker News API directly to AI tools like Claude and Cursor.

Getting it running

Setting up the server is straightforward. For Claude Desktop, add this to your configuration (claude_desktop_config.json):

{
  "mcpServers": {
    "mcp-hacker-news": {
      "command": "npx",
      "args": ["-y", "mcp-hacker-news"]
    }
  }
}

For Cursor, add it to your MCP settings, or for any other MCP-compatible client, follow their specific configuration format.

And that's it! Your AI tool can now access live Hacker News data.

Demo of Claude using MCP Hacker News server

Development setup

For contributors or those wanting to run from source:

git clone https://github.com/paablolc/mcp-hacker-news.git
cd mcp-hacker-news
pnpm install
pnpm build

Testing with the MCP Inspector:

pnpm inspector
# or from source:
npx @modelcontextprotocol/inspector node dist/index.js
MCP Inspector interface showing Hacker News server tools

Requirements

⚠️

Node.js version 18 or higher is required. Check your version with node --version and upgrade if needed.

Resources

The server exposes three core resources that map to Hacker News endpoints:

  • hackernews://top → Top stories (/v0/topstories)
  • hackernews://new → Newest stories (/v0/newstories)
  • hackernews://best → Best algorithmic stories (/v0/beststories)

These match the main list endpoints officially provided by the Hacker News API.

Tools

Beyond the fixed resources, the server provides tools for advanced queries:

  • getTopStories / getBestStories / getNewStories → Fetch stories with customizable limits
  • getAskHNStories / getShowHNStories / getJobStories → Fetch specific story types
  • getItem → Retrieve specific items (stories, comments, etc.)
  • getUser → Fetch user profiles by username
  • getComments / getMaxItemId / getUpdates → Additional utilities

Understanding MCP by building it

I built this to understand how MCP works in practice. The concept is simple: write one server that connects any API to any AI tool that supports MCP.

The same pattern works for any API you care about, one MCP server bridges all your favorite AI tools to the data they need.


Try it yourself

🚀