Skip to main content
Glama

MCP Hacker News

by paabloLC

getUser

Retrieve detailed user profile information from Hacker News by specifying a username. This tool integrates with MCP Hacker News to fetch live data efficiently.

Instructions

Get user profile information

Input Schema

NameRequiredDescriptionDefault
usernameYesThe username to look up

Input Schema (JSON Schema)

{ "properties": { "username": { "description": "The username to look up", "type": "string" } }, "required": [ "username" ], "type": "object" }

Implementation Reference

  • The execute handler function for the getUser tool. Fetches user profile from HackerNews API using fetchFromAPI, formats the data including karma, created time (using formatTime helper), about text, and recent submissions, then returns a JSON-formatted text content response.
    execute: async (args: any) => { const user = await fetchFromAPI<HackerNewsUser>(`/user/${args.username}`); if (!user) { return { content: [ { type: "text", text: JSON.stringify({ error: "User not found" }) }, ], }; } const formattedUser = { id: user.id, karma: user.karma, created: user.created ? formatTime(user.created) : "unknown", about: user.about, submittedCount: user.submitted?.length || 0, recentSubmissions: user.submitted?.slice(0, 10) || [], }; return { content: [ { type: "text", text: JSON.stringify( { message: `User profile for ${args.username}`, user: formattedUser, }, null, 2 ), }, ], }; },
  • Input schema for getUser tool, defining an object with required 'username' string property.
    inputSchema: { type: "object", properties: { username: { type: "string", description: "The username to look up", }, }, required: ["username"], },
  • src/tools.ts:414-463 (registration)
    Registration of the getUser tool as an object in the exported tools array from tools.ts. This array is imported into index.ts and used to list tools and dispatch calls to the execute handler.
    { name: "getUser", description: "Get user profile information", inputSchema: { type: "object", properties: { username: { type: "string", description: "The username to look up", }, }, required: ["username"], }, execute: async (args: any) => { const user = await fetchFromAPI<HackerNewsUser>(`/user/${args.username}`); if (!user) { return { content: [ { type: "text", text: JSON.stringify({ error: "User not found" }) }, ], }; } const formattedUser = { id: user.id, karma: user.karma, created: user.created ? formatTime(user.created) : "unknown", about: user.about, submittedCount: user.submitted?.length || 0, recentSubmissions: user.submitted?.slice(0, 10) || [], }; return { content: [ { type: "text", text: JSON.stringify( { message: `User profile for ${args.username}`, user: formattedUser, }, null, 2 ), }, ], }; }, },

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