Skip to main content
Glama
jaipandya

product-hunt-mcp

by jaipandya

get_user

Retrieve user information from Product Hunt by ID or username, with options to fetch their posts for comprehensive profile analysis.

Instructions

    Retrieve user information by ID or username, with optional retrieval of their posts.

    Parameters:
    - id (str, optional): The user's unique ID.
    - username (str, optional): The user's username.
    - posts_type (str, optional): Type of posts to retrieve. Valid values: MADE (default), VOTED.
    - posts_count (int, optional): Number of posts to return (default: 10, max: 20).
    - posts_after (str, optional): Pagination cursor for next page of posts.

    At least one of `id` or `username` must be provided.

    Returns:
    - success (bool)
    - data (dict): If successful, contains user details and optionally their posts.
    - error (dict, optional)
    - rate_limits (dict)

    Notes:
    - Returns an error if neither `id` nor `username` is provided, or if the user is not found.
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idNo
usernameNo
posts_typeNo
posts_countNo
posts_afterNo

Implementation Reference

  • Core handler function for 'get_user' tool. Decorated for registration, auth, error handling, and schema validation. Fetches user by ID/username, optionally posts, via GraphQL.
    @mcp.tool()
    @require_token
    @handle_errors
    @validate_with_schema(USER_SCHEMA)
    def get_user(
        id: str = None,
        username: str = None,
        posts_type: str = None,
        posts_count: int = None,
        posts_after: str = None,
    ) -> Dict[str, Any]:
        """
        Retrieve user information by ID or username, with optional retrieval of their posts.
    
        Parameters:
        - id (str, optional): The user's unique ID.
        - username (str, optional): The user's username.
        - posts_type (str, optional): Type of posts to retrieve. Valid values: MADE (default), VOTED.
        - posts_count (int, optional): Number of posts to return (default: 10, max: 20).
        - posts_after (str, optional): Pagination cursor for next page of posts.
    
        At least one of `id` or `username` must be provided.
    
        Returns:
        - success (bool)
        - data (dict): If successful, contains user details and optionally their posts.
        - error (dict, optional)
        - rate_limits (dict)
    
        Notes:
        - Returns an error if neither `id` nor `username` is provided, or if the user is not found.
        """
        params = {
            k: v
            for k, v in {
                "id": id,
                "username": username,
                "posts_type": posts_type,
                "posts_count": posts_count,
                "posts_after": posts_after,
            }.items()
            if v is not None
        }
        logger.info("users.get_user called", extra=params)
    
        # Determine if posts are being requested
        requesting_posts = posts_type is not None or posts_count is not None
    
        # Apply sensible defaults if posts are being requested
        if requesting_posts:
            posts_type = posts_type or "MADE"
            posts_count = posts_count or 10
        else:
            posts_type = None
            posts_count = None
    
        # Set up common variables
        variables = {}
        if id:
            variables["id"] = id
        if username:
            variables["username"] = username
    
        # Normalize posts_type
        posts_type = posts_type.upper() if posts_type else None
    
        # Case 1: Basic user info (no posts requested)
        if not requesting_posts:
            result, rate_limits, error = execute_graphql_query(USER_QUERY, variables)
            if error:
                return format_response(False, error=error, rate_limits=rate_limits)
            if not check_data_exists(result["data"], "user"):
                id_or_username = id or username
                return format_response(
                    False,
                    error={
                        "code": "NOT_FOUND",
                        "message": f"User with ID/username '{id_or_username}' not found",
                    },
                    rate_limits=rate_limits,
                )
            return format_response(True, data=result["data"]["user"], rate_limits=rate_limits)
    
        # Case 2 & 3: Posts requested (made or voted)
        # Set up pagination
        pagination = apply_pagination_defaults(posts_count, posts_after)
        variables.update(pagination)
    
        # Choose query based on posts_type
        if posts_type == "MADE":
            query = USER_POSTS_QUERY
        elif posts_type == "VOTED":
            query = USER_VOTED_POSTS_QUERY
        else:
            return format_response(
                False,
                error={
                    "code": "INVALID_PARAMETER",
                    "message": f"Invalid posts_type: {posts_type}. Valid values are MADE, VOTED.",
                },
            )
    
        # Execute the appropriate query
        result, rate_limits, error = execute_graphql_query(query, variables)
        if error:
            return format_response(False, error=error, rate_limits=rate_limits)
        if not check_data_exists(result["data"], "user"):
            id_or_username = id or username
            return format_response(
                False,
                error={
                    "code": "NOT_FOUND",
                    "message": f"User with ID/username '{id_or_username}' not found",
                },
                rate_limits=rate_limits,
            )
        user_data = result["data"]["user"]
        # Format response based on the query type
        if posts_type == "MADE" and check_data_exists(user_data, "madePosts"):
            posts_data = user_data["madePosts"]
            response_data = {
                "id": user_data["id"],
                "posts": posts_data
            }
            return format_response(True, data=response_data, rate_limits=rate_limits)
        elif posts_type == "VOTED" and check_data_exists(user_data, "votedPosts"):
            posts_data = user_data["votedPosts"]
            response_data = {
                "id": user_data["id"],
                "posts": posts_data
            }
            return format_response(True, data=response_data, rate_limits=rate_limits)
        # If we get here, the posts field wasn't in the response, just return what we have
        return format_response(True, data=user_data, rate_limits=rate_limits)
  • Input validation schema for the get_user tool parameters.
    USER_SCHEMA = {
        "requires_one_of": [["id", "username"]],
        "id": {"type": str},
        "username": {"type": str},
        "posts_type": {"type": str, "valid_values": ["MADE", "VOTED"]},
        "posts_count": {"type": int, "min_value": 1, "max_value": 20},
        "posts_after": {"type": str},
    }
  • Registers the user tools, including get_user, with the MCP server instance in the main CLI entry point.
    register_user_tools(mcp)
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes key behaviors: it's a read operation (implied by 'retrieve'), includes error conditions (if no ID/username or user not found), mentions rate limits in the return structure, and details optional post retrieval with pagination. However, it lacks information on permissions or authentication needs, which could be relevant for a user retrieval tool.

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, parameters, returns, notes) and uses bullet points for readability. It is appropriately sized but could be slightly more concise by integrating some notes into the parameter descriptions. Every sentence adds value, such as clarifying requirements and errors.

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?

Given the complexity (5 parameters, no annotations, no output schema), the description is largely complete. It covers purpose, parameters, returns, and error cases. However, it lacks details on the structure of the returned data (e.g., what fields are in 'user details') and does not mention authentication or rate limit specifics, which are minor gaps for a tool with no output schema.

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

Parameters5/5

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

Schema description coverage is 0%, so the description must compensate fully. It does so by explaining all 5 parameters in detail: their purposes (e.g., 'Type of posts to retrieve'), data types, optional status, default values, constraints (e.g., 'max: 20'), and valid values for posts_type. This adds significant meaning beyond the bare schema.

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 tool's purpose: 'Retrieve user information by ID or username, with optional retrieval of their posts.' It specifies the verb 'retrieve' and the resource 'user information,' distinguishing it from sibling tools like get_collection or get_post_details that retrieve different resources.

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

Usage Guidelines4/5

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

The description provides clear context for usage: 'At least one of `id` or `username` must be provided.' It also implies when to use this tool (to get user data) but does not explicitly compare it to alternatives like get_viewer (which might get current user) or specify exclusions, so it falls short of a perfect score.

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/jaipandya/producthunt-mcp-server'

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