Skip to main content
Glama
wei

HackerNews MCP Server

by wei

get-user

Retrieve HackerNews user profiles to check karma scores, read bios, verify account creation dates, and confirm user existence before accessing their content.

Instructions

Retrieve public profile information for a HackerNews user.

Returns user profile including karma, bio, and account creation date. Use this to:

  • Check user reputation (karma score)

  • Read user bio and about information

  • See when account was created

  • Verify user existence before searching their content

Features:

  • Username (case-sensitive)

  • Karma score (total upvotes received)

  • About/bio text (may contain HTML)

  • Account creation date (Unix timestamp)

Examples:

  • Get famous user: { "username": "pg" }

  • Check moderator: { "username": "dang" }

  • Verify author: { "username": "tptacek" }

Username validation:

  • Alphanumeric characters and underscores only

  • Case-sensitive

  • Must exist on HackerNews

Returns error if user doesn't exist or username format is invalid.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
usernameYesHackerNews username (alphanumeric + underscores, e.g., 'pg')

Implementation Reference

  • The getUserHandler function that executes the tool: validates input with Zod schema, fetches user profile via HNAPIClient, checks existence, validates output, handles errors, and returns MCP CallToolResult.
    export async function getUserHandler(input: unknown): Promise<CallToolResult> {
    	try {
    		// Validate input
    		const validatedParams = GetUserInputSchema.parse(input);
    
    		// Create API client
    		const client = new HNAPIClient();
    
    		// Call users API to get profile
    		const result = await client.getUser(validatedParams.username);
    
    		// Check if user exists
    		const notFoundError = checkItemExists(result, "User", validatedParams.username);
    		if (notFoundError) {
    			return notFoundError;
    		}
    
    		// Validate output
    		const validatedResult = GetUserOutputSchema.parse(result);
    
    		return createSuccessResult(validatedResult);
    	} catch (error) {
    		return handleAPIError(error, "get-user");
    	}
    }
  • Zod schema for validating the input parameter 'username' of the get-user tool.
    export const GetUserInputSchema = z.object({
    	username: z
    		.string()
    		.min(1, "username must not be empty")
    		.regex(/^[a-zA-Z0-9_]+$/, "username must be alphanumeric with underscores only")
    		.describe("HackerNews username"),
    });
  • Zod schema for validating the output user profile data returned by the HackerNews API.
    export const GetUserOutputSchema = z.object({
    	username: z.string(),
    	karma: z.number().int().nonnegative(),
    	about: z.string().nullable().optional(),
    	created: z.number().int().positive().optional(),
    });
  • The getUserTool metadata object defining the tool's name, detailed description, and input schema for MCP server registration.
    export const getUserTool = {
    	name: "get-user",
    	description: `Retrieve public profile information for a HackerNews user.
    
    Returns user profile including karma, bio, and account creation date. Use this to:
    - Check user reputation (karma score)
    - Read user bio and about information
    - See when account was created
    - Verify user existence before searching their content
    
    Features:
    - Username (case-sensitive)
    - Karma score (total upvotes received)
    - About/bio text (may contain HTML)
    - Account creation date (Unix timestamp)
    
    Examples:
    - Get famous user: { "username": "pg" }
    - Check moderator: { "username": "dang" }
    - Verify author: { "username": "tptacek" }
    
    Username validation:
    - Alphanumeric characters and underscores only
    - Case-sensitive
    - Must exist on HackerNews
    
    Returns error if user doesn't exist or username format is invalid.`,
    	inputSchema: {
    		type: "object",
    		properties: {
    			username: {
    				type: "string",
    				description: "HackerNews username (alphanumeric + underscores, e.g., 'pg')",
    			},
    		},
    		required: ["username"],
    	},
    };
  • src/index.ts:45-55 (registration)
    Registration of the get-user tool in the MCP server's listTools handler, including getUserTool in the returned tools array.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
    	return {
    		tools: [
    			searchPostsToolMetadata,
    			getFrontPageTool,
    			getLatestPostsTool,
    			getItemTool,
    			getUserTool,
    		],
    	};
    });
  • src/index.ts:78-80 (registration)
    Dispatch registration in the MCP server's callTool handler switch statement, routing 'get-user' calls to getUserHandler.
    case "get-user":
    	return await getUserHandler(args);
Behavior4/5

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

With no annotations provided, the description carries full burden and does well by disclosing key behavioral traits: case-sensitivity, username validation rules (alphanumeric+underscores), existence requirement, and error conditions. It also mentions that bio may contain HTML. However, it doesn't cover rate limits or authentication needs.

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

Conciseness4/5

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

The description is well-structured with clear sections (purpose, use cases, features, examples, validation, error handling) and every sentence adds value. It could be slightly more concise by combining some bullet points, but overall it's efficiently organized and front-loaded with the core purpose.

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-only tool with no output schema, the description provides comprehensive context: purpose, usage guidelines, parameter details, examples, validation rules, and error conditions. The main gap is lack of output format details (structure of returned profile), but otherwise it's quite complete.

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?

Schema description coverage is 100%, so the baseline is 3. The description adds some value by providing username validation details (alphanumeric+underscores, case-sensitive, must exist) and examples, but doesn't significantly enhance the parameter understanding beyond what the schema already documents.

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 public profile information') and resource ('for a HackerNews user'), distinguishing it from sibling tools like get-item or get-latest-posts which handle posts/items rather than user profiles. It provides concrete details about what information is retrieved (karma, bio, creation date).

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

Usage Guidelines5/5

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

The description explicitly lists four specific use cases (check reputation, read bio, see creation date, verify existence before searching content), providing clear guidance on when to use this tool. It also distinguishes from siblings by focusing on user profiles rather than posts/items, though it doesn't explicitly name alternatives.

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

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