get_post_details
Retrieve detailed Product Hunt post data including ID, name, description, tagline, votes, makers, topics, media, and paginated comments by specifying 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
| Name | Required | Description | Default |
|---|---|---|---|
| comments_after | No | ||
| comments_count | No | ||
| id | No | ||
| slug | No |
Implementation Reference
- The handler function that executes the get_post_details tool logic: fetches post details and comments via GraphQL query using POST_QUERY, handles pagination, errors, and formats 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)
- Input validation schema for get_post_details: requires one of id or slug, both strings.POST_SCHEMA = {"requires_one_of": [["id", "slug"]], "id": {"type": str}, "slug": {"type": str}}
- src/product_hunt_mcp/cli.py:35-35 (registration)Registers the post tools (including get_post_details) by calling register_post_tools(mcp) on the FastMCP server instance.register_post_tools(mcp)
- src/product_hunt_mcp/tools/posts.py:27-27 (registration)@mcp.tool() decorator registers the get_post_details function as an MCP tool within the register_post_tools function.@mcp.tool()