Skip to main content
Glama

get-user

Retrieve detailed information about specific HackerNews users including their profile data, karma score, and account activity.

Instructions

Get information about a specific HackerNews user

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
usernameYesThe username to look up

Implementation Reference

  • The asynchronous handler function for the 'get-user' tool. It constructs the HN API endpoint for the given username, fetches the user data using the shared fetchHN helper, and returns both a textual JSON representation and the structured data.
    async ({ username }) => { const endpoint = `/users/${username}`; const result = await fetchHN(endpoint); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], structuredContent: result }; }
  • The tool configuration including title, description, inputSchema (username: string), and outputSchema (username, about, karma) using Zod validation for the 'get-user' tool.
    { title: 'Get HackerNews User Info', description: 'Get information about a specific HackerNews user', inputSchema: { username: z.string().describe('The username to look up') }, outputSchema: { username: z.string(), about: z.string().optional(), karma: z.number() } },
  • src/index.ts:306-329 (registration)
    The complete registration of the 'get-user' tool via server.registerTool, specifying the tool name, schema/configuration, and handler function.
    server.registerTool( 'get-user', { title: 'Get HackerNews User Info', description: 'Get information about a specific HackerNews user', inputSchema: { username: z.string().describe('The username to look up') }, outputSchema: { username: z.string(), about: z.string().optional(), karma: z.number() } }, async ({ username }) => { const endpoint = `/users/${username}`; const result = await fetchHN(endpoint); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], structuredContent: result }; } );
  • Shared helper function fetchHN used by all HN API tools, including 'get-user', to perform API requests to the HackerNews Algolia API and handle errors.
    async function fetchHN(endpoint: string): Promise<any> { const response = await fetch(`${HN_API_BASE}${endpoint}`); if (!response.ok) { throw new Error(`HN API error: ${response.status} ${response.statusText}`); } return await response.json(); }

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-vibe'

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