A clean, minimal MCP wrapper around the Hacker News API β built to showcase the Modular Contract Protocol (MCP) structure, typed contracts, and LLM-compatible interface.
π’ Deployed at: https://mcp-news-server.onrender.com
This project demonstrates how to transform an existing REST API into an MCP-compliant server. It wraps the Hacker News API using modular components:
- Contracts defined with
zod
andzod-openapi
for typed and documented inputs/outputs - Resolvers for business logic
- Handlers for HTTP routing
- OpenAPI integration for LLM function calling
My goal with this wrapper is to learn and demonstrate the full MCP process, and prepare APIs for the MCP marketplace β where tools and agents can discover and use them programmatically.
Traditional REST APIs:
- β No contracts
- β Inconsistent formats
- β Not LLM friendly
MCP APIs:
- β Contract-driven (with Zod)
- β Composable and self-descriptive
- β LLM-ready (via OpenAPI and function schemas)
- Node.js + Express
- TypeScript
- Zod +
zod-openapi
- Axios
- Deployed on Render
src/
βββ contracts/ # Zod + OpenAPI metadata
βββ resolvers/ # Business logic
βββ handlers/ # Express routes
βββ utils/ # Hacker News client
βββ docs/openapi.ts # OpenAPI spec generator (zod-openapi)
βββ setup/zod-openapi-init.ts # Shared zod setup with OpenAPI support
βββ server.ts # Main entry point
Returns a list of top Hacker News story IDs.
curl https://mcp-news-server.onrender.com/api/listTopStories
[38643, 38642, 38641]
Returns full story data for a given story ID.
curl https://mcp-news-server.onrender.com/api/getStory/8863
{
"id": 8863,
"title": "My YC app: Dropbox - Throw away your USB drive",
"url": "http://www.getdropbox.com/u/2/screencast.html",
"score": 111,
"by": "dhouston",
"time": 1175714200,
"type": "story"
}
Each MCP endpoint is:
- Strictly typed
- Schema-bound with Zod
- Self-documenting via OpenAPI
This makes it ideal for:
- LLM agents (OpenAI, Claude)
- LangChain tools
- ai-agent-flow pipelines
{
"name": "getStory",
"description": "Retrieve story details by ID from Hacker News",
"parameters": {
"type": "object",
"properties": {
"id": {
"type": "string",
"description": "The numeric ID of the Hacker News story"
}
},
"required": ["id"]
}
}
β‘οΈ Point to:
GET https://mcp-news-server.onrender.com/api/getStory/:id
curl https://mcp-news-server.onrender.com/openapi.json
This endpoint can be used in:
- Swagger UI
- API clients (Postman, Insomnia)
- LLM frameworks for function discovery
git clone https://github.com/rajeshdh/mcp-news-server
cd mcp-news-server
npm install
npm run dev
- A summarizer tool for top HN stories
- A GPT agent that fetches and ranks HN stories
- A fact-checking or news validation agent
- Your own open MCP marketplace entry!
MIT