Skip to main content
Glama

MCP Hacker News

by paabloLC

getUpdates

Retrieve recent updates, including posts, comments, and user profiles, from Hacker News via a standardized MCP server endpoint for real-time data interaction.

Instructions

Get recently updated items and profiles

Input Schema

NameRequiredDescriptionDefault

No arguments

Input Schema (JSON Schema)

{ "properties": {}, "type": "object" }

Implementation Reference

  • The execute handler for the 'getUpdates' tool. Fetches recent updates from Hacker News API using fetchFromAPI('/updates'), handles errors, limits to top 10 items and profiles, and returns formatted JSON response.
    execute: async (args: any) => { const updates = await fetchFromAPI<HackerNewsUpdates>("/updates"); if (!updates) { return { content: [ { type: "text", text: JSON.stringify({ error: "Failed to fetch updates" }), }, ], }; } return { content: [ { type: "text", text: JSON.stringify( { message: "Recent updates", recentlyUpdatedItems: updates.items.slice(0, 10), recentlyUpdatedProfiles: updates.profiles.slice(0, 10), }, null, 2 ), }, ], }; },
  • Input schema for 'getUpdates' tool, which requires no input parameters.
    inputSchema: { type: "object", properties: {} },
  • src/tools.ts:552-587 (registration)
    Registration of the 'getUpdates' tool in the tools export array, including name, description, schema, and handler.
    { name: "getUpdates", description: "Get recently updated items and profiles", inputSchema: { type: "object", properties: {} }, execute: async (args: any) => { const updates = await fetchFromAPI<HackerNewsUpdates>("/updates"); if (!updates) { return { content: [ { type: "text", text: JSON.stringify({ error: "Failed to fetch updates" }), }, ], }; } return { content: [ { type: "text", text: JSON.stringify( { message: "Recent updates", recentlyUpdatedItems: updates.items.slice(0, 10), recentlyUpdatedProfiles: updates.profiles.slice(0, 10), }, null, 2 ), }, ], }; }, },
  • TypeScript interface defining the structure of updates data used in the getUpdates handler.
    export interface HackerNewsUpdates { items: number[]; profiles: string[]; }
  • Helper function fetchFromAPI used by the getUpdates handler to fetch data from '/updates' endpoint.
    export async function fetchFromAPI<T>(endpoint: string): Promise<T | null> { const cacheKey = endpoint; const cached = getCached<T>(cacheKey); if (cached) return cached; try { const response = await fetch( `https://hacker-news.firebaseio.com/v0${endpoint}.json` ); if (!response.ok) throw new Error(`HTTP ${response.status}`); const data = await response.json(); setCache(cacheKey, data); return data; } catch (error) { console.error(`Error fetching ${endpoint}:`, error); return null; } }

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/paabloLC/mcp-hacker-news'

If you have feedback or need assistance with the MCP directory API, please join our Discord server