Skip to main content
Glama
jaipandya

product-hunt-mcp

by jaipandya

get_collections

Retrieve Product Hunt collections with filters for featured content, specific users, included posts, or sorting by followers or date.

Instructions

Retrieve a list of collections with optional filters. Parameters: - featured (bool, optional): Only return featured collections if True. - user_id (str, optional): Filter to collections created by this user ID. - post_id (str, optional): Filter to collections that include this post ID. - order (str, optional): Sorting order. Valid values: FOLLOWERS_COUNT (default), NEWEST. - count (int, optional): Number of collections to return (default: 10, max: 20). - after (str, optional): Pagination cursor for next page. Returns: - success (bool) - data (dict): If successful, contains: - collections (list): List of collection objects (id, name, etc.) - pagination (dict): { end_cursor, has_next_page } - error (dict, optional) - rate_limits (dict) Notes: - If no collections match, `collections` will be an empty list.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
featuredNo
user_idNo
post_idNo
orderNoFOLLOWERS_COUNT
countNo
afterNo

Implementation Reference

  • The handler function decorated with @mcp.tool(), handling input validation, authentication, error handling, GraphQL query execution for retrieving collections with filters and pagination, and response formatting.
    @mcp.tool() @require_token @handle_errors @validate_with_schema(COLLECTIONS_SCHEMA) def get_collections( featured: bool = None, user_id: str = None, post_id: str = None, order: str = "FOLLOWERS_COUNT", count: int = 10, after: str = None, ) -> Dict[str, Any]: """ Retrieve a list of collections with optional filters. Parameters: - featured (bool, optional): Only return featured collections if True. - user_id (str, optional): Filter to collections created by this user ID. - post_id (str, optional): Filter to collections that include this post ID. - order (str, optional): Sorting order. Valid values: FOLLOWERS_COUNT (default), NEWEST. - count (int, optional): Number of collections to return (default: 10, max: 20). - after (str, optional): Pagination cursor for next page. Returns: - success (bool) - data (dict): If successful, contains: - collections (list): List of collection objects (id, name, etc.) - pagination (dict): { end_cursor, has_next_page } - error (dict, optional) - rate_limits (dict) Notes: - If no collections match, `collections` will be an empty list. """ params = { k: v for k, v in { "featured": featured, "user_id": user_id, "post_id": post_id, "order": order, "count": count, "after": after, }.items() if v is not None } logger.info("collections.get_collections called", extra=params) # Apply pagination defaults variables = apply_pagination_defaults(count, after) # Add order parameter variables["order"] = order # Add optional filters if featured is not None: variables["featured"] = featured if user_id: variables["userId"] = user_id if post_id: variables["postId"] = post_id result, rate_limits, error = execute_graphql_query(COLLECTIONS_QUERY, variables) if error: return format_response(False, error=error, rate_limits=rate_limits) # Extract collections collections_data = result["data"]["collections"] return format_response( True, data={ "collections": collections_data["edges"], "pagination": extract_pagination(collections_data["pageInfo"]), }, rate_limits=rate_limits, )
  • JSON schema defining validation rules for the input parameters of the get_collections tool.
    COLLECTIONS_SCHEMA = { "featured": {"type": bool}, "user_id": {"type": str}, "post_id": {"type": str}, "order": {"type": str, "valid_values": ["FOLLOWERS_COUNT", "NEWEST", "FEATURED_AT"]}, "count": {"type": int, "min_value": 1, "max_value": 20}, "after": {"type": str}, }
  • Entry point registration: calls register_collection_tools to register the collections tools (including get_collections) with the MCP server instance.
    register_collection_tools(mcp)
  • Defines and registers the collection tools (get_collection and get_collections) using @mcp.tool() decorators when called with an MCP instance.
    def register_collection_tools(mcp): """Register collection-related tools with the MCP server.""" @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