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
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools.ts:532-550 (handler)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 ), }, ], }; },
- src/tools.ts:531-531 (schema)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`, }, }); }