Skip to main content
Glama
paabloLC

MCP Hacker News

by paabloLC

getMaxItemId

Retrieve the highest available item ID from Hacker News to determine the most recent content or track updates in the system.

Instructions

Get the current maximum item ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The execute handler function for the getMaxItemId tool. It calls fetchFromAPI on the /maxitem endpoint to retrieve the highest item ID from Hacker News and returns a formatted JSON response containing the maxItemId.
    execute: async (args: any) => { const maxId = await fetchFromAPI<number>("/maxitem"); return { content: [ { type: "text", text: JSON.stringify( { message: "Current maximum item ID", maxItemId: maxId, }, null, 2 ), }, ], }; },
  • The input schema for the getMaxItemId tool, defining an empty object as it requires no input parameters.
    inputSchema: { type: "object", properties: {} },
  • src/tools.ts:528-551 (registration)
    The full tool object definition for getMaxItemId, including name, description, schema, and handler, registered in the exported tools array used by the MCP server.
    { name: "getMaxItemId", description: "Get the current maximum item ID", inputSchema: { type: "object", properties: {} }, execute: async (args: any) => { const maxId = await fetchFromAPI<number>("/maxitem"); return { content: [ { type: "text", text: JSON.stringify( { message: "Current maximum item ID", maxItemId: maxId, }, null, 2 ), }, ], }; }, },
  • src/index.ts:52-64 (registration)
    MCP server implementation for handling 'tools/call' requests by finding the tool by name in the tools array and invoking its execute method.
    if (json.method === "tools/call") { const tool = tools.find((tool) => tool.name === json.params.name); if (tool) { const toolResponse = await tool.execute(json.params.arguments); sendResponse(json.id, toolResponse); } else { sendResponse(json.id, { error: { code: -32602, message: `MCP error -32602: Tool ${json.params.name} not found`, }, }); }

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