Skip to main content
Glama
jaipandya

product-hunt-mcp

by jaipandya

get_topic

Retrieve detailed information about a specific Product Hunt topic using its ID or slug, including name, description, follower count, and related posts.

Instructions

    Retrieve detailed information about a specific topic by ID or slug.

    Parameters:
    - id (str, optional): The topic's unique ID.
    - slug (str, optional): The topic's slug (e.g., "artificial-intelligence").

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

    Returns:
    - success (bool)
    - data (dict): If successful, contains topic details:
        - id, name, description, follower_count, posts, etc.
    - error (dict, optional)
    - rate_limits (dict)

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idNo
slugNo

Implementation Reference

  • The handler function that executes the get_topic tool logic, decorated with @mcp.tool(), @require_token, @handle_errors, and @validate_with_schema. It fetches topic details using a GraphQL query.
    def get_topic(id: str = None, slug: str = None) -> Dict[str, Any]:
        """
        Retrieve detailed information about a specific topic by ID or slug.
    
        Parameters:
        - id (str, optional): The topic's unique ID.
        - slug (str, optional): The topic's slug (e.g., "artificial-intelligence").
    
        At least one of `id` or `slug` must be provided.
    
        Returns:
        - success (bool)
        - data (dict): If successful, contains topic details:
            - id, name, description, follower_count, posts, etc.
        - error (dict, optional)
        - rate_limits (dict)
    
        Notes:
        - Returns an error if neither `id` nor `slug` is provided, or if the topic is not found.
        """
        params = {k: v for k, v in {"id": id, "slug": slug}.items() if v is not None}
        logger.info("topics.get_topic called", extra=params)
    
        variables = {}
        add_id_or_slug(variables, id, slug)
    
        # Execute the query and check if topic exists
        id_or_slug = id or slug
        topic_data, rate_limits, error = execute_and_check_query(
            TOPIC_QUERY, variables, "topic", id_or_slug
        )
    
        if error:
            return format_response(False, error=error, rate_limits=rate_limits)
    
        return format_response(True, data=topic_data, rate_limits=rate_limits)
  • Input validation schema for the get_topic tool, requiring at least one of 'id' or 'slug' as string.
    TOPIC_SCHEMA = {"requires_one_of": [["id", "slug"]], "id": {"type": str}, "slug": {"type": str}}
  • Invocation of register_topic_tools(mcp) which registers the get_topic tool via @mcp.tool() decorator inside it.
    register_topic_tools(mcp)
  • The @mcp.tool() decorator that registers the get_topic function as an MCP tool.
    @mcp.tool()

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