Skip to main content
Glama
hillaryTse

HackerNews MCP Server

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;
    }
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes what the tool returns (user metadata, karma score, creation date, bio text, computed fields) and the purpose of those fields ('to provide context about user activity and reputation'). However, it doesn't mention error conditions, rate limits, or authentication requirements.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is efficiently structured in two sentences: the first states the core purpose and parameter, the second details the return data and its value. Every element adds useful information without redundancy or unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a single-parameter read operation with no annotations or output schema, the description provides strong context about what data is returned and why. It covers the tool's purpose, parameter semantics, and return value meaning. The main gap is lack of explicit error handling or rate limit information.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema has 0% description coverage, so the description must compensate. It clearly explains the 'username' parameter's purpose ('by username') and implies constraints through context (HackerNews usernames). While it doesn't specify format details beyond the schema's min/max length, it provides meaningful semantic context for the single parameter.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Retrieve'), resource ('HackerNews user profile information'), and scope ('by username'). It distinguishes this tool from sibling tools like get_front_page, get_post, and search_posts by focusing on user profiles rather than posts or content.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context by specifying 'by username' and listing the returned data fields, but it doesn't explicitly state when to use this tool versus alternatives. No guidance is provided about prerequisites, limitations, or comparisons with sibling tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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

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