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()
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden and does well by disclosing: return structure including pagination, empty list behavior when no matches, rate limits, and default/max values for parameters. It doesn't mention authentication requirements or potential side effects, but provides substantial behavioral context beyond basic functionality.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Well-structured with clear sections (Parameters, Returns, Notes) and front-loaded purpose statement. Every sentence adds value, though the parameter documentation is quite detailed. Slightly verbose but efficiently organized with no redundant information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a read-only list tool with no output schema and 0% schema description coverage, the description provides excellent completeness: detailed parameter semantics, full return structure documentation, pagination behavior, edge case handling (empty results), and rate limit awareness. No significant gaps given the tool's complexity level.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage, the description fully compensates by providing detailed parameter documentation: purpose, data types, optional status, valid values for 'order', default values, and constraints like 'max: 20'. Each of the 6 parameters receives clear semantic explanation beyond what the bare schema provides.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose as 'Retrieve a list of collections with optional filters' - a specific verb ('retrieve') and resource ('collections'). It distinguishes from siblings like 'get_collection' (singular) by indicating it returns a list, but doesn't explicitly contrast with other list tools like 'get_posts'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. While it mentions optional filters, it doesn't explain when filtering is appropriate or how this differs from other collection-related tools. No explicit when/when-not statements or alternative tool references are included.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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