Skip to main content
Glama
hillaryTse
by hillaryTse

get_user

Retrieve HackerNews user profiles to access karma scores, account details, bio information, and activity metrics for analysis and verification.

Instructions

Retrieve HackerNews user profile information by username. Returns user metadata including karma score, account creation date, and about/bio text. Includes computed fields like account age in years and average karma per year to provide context about user activity and reputation.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
usernameYes

Implementation Reference

  • The core handler function for the 'get_user' tool. Validates input using GetUserInputSchema, fetches user data via apiClient.getUser, computes derived metrics (account age, karma per year, status), and returns a formatted response.
    export async function handleGetUser(args: unknown) { // Validate input const parseResult = GetUserInputSchema.safeParse(args); if (!parseResult.success) { throw new ValidationError("Invalid username", parseResult.error.errors); } const input: GetUserInput = parseResult.data; // Get user from API const user = await apiClient.getUser(input.username); // Calculate computed fields const accountAgeYears = calculateAccountAge(user.created_at_i); const karmaPerYear = calculateKarmaPerYear(user.karma, user.created_at_i); // Format response const response = { user: { username: user.username, karma: user.karma, about: user.about, created_at: user.created_at, created_at_i: user.created_at_i, }, computed: { accountAgeYears, karmaPerYear, accountStatus: user.karma > 10000 ? "highly active" : user.karma > 1000 ? "active" : "casual", }, remainingQuota: apiClient.getRemainingQuota(), }; return formatToolResponse(response); }
  • Tool registration in the MCP tools list, defining name, description, and input schema for 'get_user'.
    name: "get_user", description: "Retrieve HackerNews user profile information by username. Returns user metadata including karma score, account creation date, and about/bio text. Includes computed fields like account age in years and average karma per year to provide context about user activity and reputation.", inputSchema: zodToJsonSchema(GetUserInputSchema), },
  • Zod schema for validating the input to the get_user tool, enforcing username as a string between 1-15 characters.
    export const GetUserInputSchema = z.object({ username: z.string().min(1).max(15), });
  • src/index.ts:61-62 (registration)
    Dispatch routing in the main MCP server handler that maps 'get_user' tool calls to the handleGetUser function.
    case "get_user": return await handleGetUser(args);
  • TypeScript interface defining the expected input shape for the get_user tool.
    export interface GetUserInput { username: string; }

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/hillaryTse/hn-mcp-server'

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