Skip to main content
Glama
jaipandya

product-hunt-mcp

by jaipandya

get_post_details

Retrieve detailed Product Hunt post information including votes, makers, topics, media, and paginated comments by providing a post ID or slug.

Instructions

    Retrieve detailed information about a specific Product Hunt post by ID or slug.

    Parameters:
    - id (str, optional): The post's unique ID.
    - slug (str, optional): The post's slug (e.g., "product-hunt-api").
    - comments_count (int, optional): Number of comments to return (default: 10, max: 20).
    - comments_after (str, optional): Pagination cursor for fetching the next page of comments.

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

    Returns:
    - success (bool): Whether the request was successful.
    - data (dict): If successful, contains:
        - id, name, description, tagline, votes, makers, topics, media, and
        - comments (paginated): { edges: [...], pageInfo: { endCursor, hasNextPage } }
    - error (dict, optional): If unsuccessful, contains error code and message.
    - rate_limits (dict): API rate limit information.

    Notes:
    - If neither `id` nor `slug` is provided, an error is returned.
    - If the post is not found, an error is returned.
    - The dedicated `get_post_comments` tool is deprecated; use this tool for paginated comments.
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idNo
slugNo
comments_countNo
comments_afterNo

Implementation Reference

  • The main handler function for the 'get_post_details' tool. It fetches detailed post information using a GraphQL query (POST_QUERY), handles pagination for comments, and formats the response.
    def get_post_details(
        id: str = None, slug: str = None, comments_count: int = 10, comments_after: str = None
    ) -> Dict[str, Any]:
        """
        Retrieve detailed information about a specific Product Hunt post by ID or slug.
    
        Parameters:
        - id (str, optional): The post's unique ID.
        - slug (str, optional): The post's slug (e.g., "product-hunt-api").
        - comments_count (int, optional): Number of comments to return (default: 10, max: 20).
        - comments_after (str, optional): Pagination cursor for fetching the next page of comments.
    
        At least one of `id` or `slug` must be provided.
    
        Returns:
        - success (bool): Whether the request was successful.
        - data (dict): If successful, contains:
            - id, name, description, tagline, votes, makers, topics, media, and
            - comments (paginated): { edges: [...], pageInfo: { endCursor, hasNextPage } }
        - error (dict, optional): If unsuccessful, contains error code and message.
        - rate_limits (dict): API rate limit information.
    
        Notes:
        - If neither `id` nor `slug` is provided, an error is returned.
        - If the post is not found, an error is returned.
        - The dedicated `get_post_comments` tool is deprecated; use this tool for paginated comments.
        """
        params = {
            k: v
            for k, v in {
                "id": id,
                "slug": slug,
                "comments_count": comments_count,
                "comments_after": comments_after,
            }.items()
            if v is not None
        }
        logger.info("posts.get_post_details called", extra=params)
    
        variables = {}
        add_id_or_slug(variables, id, slug)
        # Add pagination for comments if requested
        if comments_count is not None:
            variables["commentsCount"] = min(comments_count, 20)
        if comments_after:
            variables["commentsAfter"] = comments_after
    
        # Use the utility function to execute the query and check if post exists
        id_or_slug = id or slug
        post_data, rate_limits, error = execute_and_check_query(
            POST_QUERY, variables, "post", id_or_slug
        )
    
        if error:
            return format_response(False, error=error, rate_limits=rate_limits)
    
        return format_response(True, data=post_data, rate_limits=rate_limits)
  • POST_SCHEMA validation dictionary used by the tool. Requires either 'id' or 'slug' (strings), with other parameters implicitly optional.
    POST_SCHEMA = {"requires_one_of": [["id", "slug"]], "id": {"type": str}, "slug": {"type": str}}
  • Invocation of register_post_tools(mcp) in the main CLI entrypoint, which defines and registers the get_post_details tool.
    register_post_tools(mcp)
  • @mcp.tool() decorator immediately above the handler, which registers the function as an MCP tool during register_post_tools execution.
    @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