Skip to main content
Glama

get_user_info

Retrieve user details and submitted stories from Hacker News by specifying a username and optional story count.

Instructions

Get user info from Hacker News, including the stories they've submitted

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
num_storiesNoNumber of stories to get, defaults to 10
user_nameYesUsername of the user

Implementation Reference

  • Core implementation of get_user_info tool: fetches HN user profile data and their recent story submissions via API calls.
    def get_user_info(user_name: str, num_stories: int = DEFAULT_NUM_STORIES) -> Dict: """ Fetches information about a Hacker News user and their recent submissions. Args: user_name: Username to fetch information for num_stories: Number of user's stories to include (default: 10) Returns: Dict containing user information and recent stories: { "id": str, # Username "created_at": str, # Account creation timestamp "karma": int, # User's karma points "about": str, # User's about text (may be null) "stories": list # List of user's recent story dictionaries } Raises: requests.exceptions.RequestException: If the API request fails """ url = f"{BASE_API_URL}/users/{user_name}" response = requests.get(url) response.raise_for_status() response = response.json() response["stories"] = _get_user_stories(user_name, num_stories) return response
  • Registers the get_user_info tool with MCP server, including name, description, and input schema.
    types.Tool( name="get_user_info", description="Get user info from Hacker News, including the stories they've submitted", inputSchema={ "type": "object", "properties": { "user_name": { "type": "string", "description": "Username of the user", }, "num_stories": { "type": "integer", "description": f"Number of stories to get, defaults to {DEFAULT_NUM_STORIES}", }, }, "required": ["user_name"], }, ),
  • MCP server dispatch handler for get_user_info tool call, invokes hn.get_user_info and formats output as JSON.
    elif name == "get_user_info": user_name = arguments.get("user_name") num_stories = arguments.get("num_stories", DEFAULT_NUM_STORIES) output = json.dumps(hn.get_user_info(user_name, num_stories), indent=2) return [types.TextContent(type="text", text=output)]
  • JSON schema defining input parameters for get_user_info tool: required user_name (string), optional num_stories (integer).
    inputSchema={ "type": "object", "properties": { "user_name": { "type": "string", "description": "Username of the user", }, "num_stories": { "type": "integer", "description": f"Number of stories to get, defaults to {DEFAULT_NUM_STORIES}", }, }, "required": ["user_name"], },

Other Tools

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

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