Skip to main content
Glama
jaipandya

product-hunt-mcp

by jaipandya

get_collections

Retrieve filtered and paginated collections from Product Hunt, specifying criteria like featured status, user ID, post ID, sorting order, and result count.

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
afterNo
countNo
featuredNo
orderNoFOLLOWERS_COUNT
post_idNo
user_idNo

Implementation Reference

  • Defines the get_collections tool handler function with decorators for MCP registration (@mcp.tool()), token requirement, error handling, and schema validation. Executes GraphQL query to fetch collections with filters and pagination, formats response.
    @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, )
  • COLLECTIONS_SCHEMA: Input validation schema defining optional parameters (featured, user_id, post_id, order, count, after) with types and constraints for 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}, }
  • Invokes register_collection_tools(mcp) in the main CLI entry point, which registers the get_collections tool via inline @mcp.tool() decorator.
    register_collection_tools(mcp)

Other Tools

Related 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