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
| Name | Required | Description | Default |
|---|---|---|---|
| username | Yes |
Implementation Reference
- src/tools/get-user.ts:14-49 (handler)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); }
- src/tools/index.ts:45-49 (registration)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), },
- src/schemas/index.ts:117-119 (schema)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);
- src/types/index.ts:127-129 (schema)TypeScript interface defining the expected input shape for the get_user tool.export interface GetUserInput { username: string; }