Skip to main content
Glama
erithwik

mcp-hn

by erithwik

get_user_info

Retrieve Hacker News user profiles and submitted stories to analyze activity and contributions on the platform.

Instructions

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

Input Schema

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

Implementation Reference

  • The core handler function implementing the get_user_info tool. Fetches user profile from HN API and appends their recent stories using a helper function.
    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
  • JSON Schema defining the input parameters for the get_user_info tool: required 'user_name' (string) and optional 'num_stories' (integer).
    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"],
        },
    ),
  • Dispatch logic in the MCP server's call_tool handler that extracts arguments, calls the get_user_info function, and returns the JSON-formatted result as text content.
    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)]
  • Helper function called by get_user_info to retrieve and format the user's submitted stories.
    def _get_user_stories(user_name: str, num_stories: int = DEFAULT_NUM_STORIES) -> List[Dict]:
        """
        Fetches stories submitted by a specific user.
    
        Args:
            user_name: Username whose stories to fetch
            num_stories: Number of stories to return (default: 10)
    
        Returns:
            List[Dict]: List of story dictionaries authored by the user
    
        Raises:
            requests.exceptions.RequestException: If the API request fails
        """
        url = f"{BASE_API_URL}/search?tags=author_{user_name},story&hitsPerPage={num_stories}"
        response = requests.get(url)
        response.raise_for_status()
        return [_format_story_details(story) for story in response.json()["hits"]]
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool retrieves user info and stories, implying a read-only operation, but doesn't cover aspects like rate limits, authentication needs, error handling, or response format. For a tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

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, efficient sentence that front-loads the core purpose without unnecessary details. It's appropriately sized for a simple tool, with zero waste or redundancy.

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 with two parameters. It doesn't explain what 'user info' includes beyond stories, how results are structured, or any behavioral constraints. For a read operation with no structured output, more context is needed to guide the agent 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 clear descriptions for both parameters ('user_name' and 'num_stories'). The description adds minimal value beyond the schema, as it doesn't provide additional context like parameter interactions or examples. With high schema coverage, the baseline score of 3 is appropriate.

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 tool's purpose: 'Get user info from Hacker News, including the stories they've submitted.' It specifies the verb ('Get'), resource ('user info'), and scope ('from Hacker News'), but doesn't explicitly differentiate from sibling tools like 'get_stories' or 'get_story_info' beyond mentioning user-specific data.

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. It doesn't mention sibling tools like 'get_stories' or 'search_stories', nor does it specify prerequisites, exclusions, or contexts for usage. The agent must infer usage from the purpose alone.

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

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