Skip to main content
Glama
devabdultech

Hacker News MCP Server

getUser

Retrieve Hacker News user profiles by ID to access karma, about sections, and submission history.

Instructions

Get a user profile by ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesThe ID of the user

Implementation Reference

  • Main handler for the 'getUser' tool: validates input using UserRequestSchema, fetches user data via hnApi.getUser, formats it with formatUser, constructs response text with user profile details.
    case "getUser": {
      const validatedArgs = validateInput(UserRequestSchema, args);
      const { id } = validatedArgs;
    
      const user = await hnApi.getUser(id);
    
      if (!user) {
        throw new McpError(
          ErrorCode.InvalidParams,
          `User with ID ${id} not found`
        );
      }
    
      const formattedUser = formatUser(user);
      const text =
        `User Profile:\n` +
        `Username: ${formattedUser.id}\n` +
        `Karma: ${formattedUser.karma}\n` +
        `Created: ${new Date(formattedUser.created * 1000).toISOString()}\n` +
        (formattedUser.about ? `\nAbout:\n${formattedUser.about}\n` : "");
    
      return {
        content: [{ type: "text", text: text.trim() }],
      };
    }
  • src/index.ts:150-160 (registration)
    Registers the 'getUser' tool in the ListTools response, specifying name, description, and input schema.
    {
      name: "getUser",
      description: "Get a user profile by ID",
      inputSchema: {
        type: "object",
        properties: {
          id: { type: "string", description: "The ID of the user" },
        },
        required: ["id"],
      },
    },
  • Zod schema for validating the input parameters of the 'getUser' tool (user ID as string).
    export const UserRequestSchema = z.object({
      id: z.string(),
    });
  • HackerNewsAPI method that fetches user profile data from the official HN Firebase API endpoint.
    async getUser(id: string): Promise<any> {
      const response = await fetch(`${API_BASE_URL}/user/${id}.json`);
      return response.json();
    }
  • Helper function to format raw user data from HN API into a structured User interface.
    export function formatUser(user: any): User {
      return {
        id: user.id,
        created: user.created,
        karma: user.karma,
        about: user.about,
        submitted: user.submitted,
      };
    }
Behavior2/5

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

With no annotations provided, the description carries full burden but only states the basic operation without disclosing behavioral traits. It doesn't mention authentication needs, rate limits, error handling, or what happens if the ID is invalid, which are critical for a tool that fetches user data.

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 a single, clear sentence with zero wasted words, making it easy to parse and front-loaded with essential information. It efficiently conveys the core purpose without unnecessary elaboration.

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

Completeness2/5

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

Given the lack of annotations and output schema, the description is incomplete for a tool that retrieves user data. It doesn't explain what a 'user profile' includes, potential return values, or error scenarios, leaving significant gaps in understanding how to use the tool effectively.

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

Parameters3/5

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

The schema description coverage is 100%, with the parameter 'id' fully documented in the schema. The description adds no additional meaning beyond the schema, such as ID format or examples, so it meets the baseline for high schema coverage.

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

Purpose4/5

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

The description clearly states the action ('Get') and resource ('user profile by ID'), making the purpose immediately understandable. It doesn't differentiate from sibling tools like 'getUserSubmissions' or 'search', which could retrieve user-related data differently, so it doesn't reach the highest score.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives like 'getUserSubmissions' or 'search' for user-related queries. It lacks context about prerequisites or exclusions, leaving usage decisions ambiguous.

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

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