Skip to main content
Glama
jaipandya

product-hunt-mcp

by jaipandya

search_topics

Find topics on Product Hunt by name, filter by user following, and sort results with pagination support.

Instructions

    Search for topics by name or filter by user following, with optional sorting and pagination.

    Parameters:
    - query (str, optional): Search term to find topics by name.
    - followed_by_user_id (str, optional): Only topics followed by this user ID.
    - order (str, optional): Sorting order. Valid values: FOLLOWERS_COUNT (default), NAME, NEWEST.
    - count (int, optional): Number of topics to return (default: 10, max: 20).
    - after (str, optional): Pagination cursor for next page.

    Returns:
    - success (bool)
    - data (dict): If successful, contains:
        - topics (list): List of topic objects (id, name, etc.)
        - pagination (dict): { end_cursor, has_next_page }
    - error (dict, optional)
    - rate_limits (dict)

    Notes:
    - If no topics match, `topics` will be an empty list.
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryNo
followed_by_user_idNo
orderNoFOLLOWERS_COUNT
countNo
afterNo

Implementation Reference

  • The core handler function for the 'search_topics' tool. It validates input, logs the call, constructs GraphQL variables, executes the TOPICS_QUERY, and formats the response with topics list and pagination.
    @mcp.tool()
    @require_token
    @handle_errors
    @validate_with_schema(TOPICS_SCHEMA)
    def search_topics(
        query: str = None,
        followed_by_user_id: str = None,
        order: str = "FOLLOWERS_COUNT",
        count: int = 10,
        after: str = None,
    ) -> Dict[str, Any]:
        """
        Search for topics by name or filter by user following, with optional sorting and pagination.
    
        Parameters:
        - query (str, optional): Search term to find topics by name.
        - followed_by_user_id (str, optional): Only topics followed by this user ID.
        - order (str, optional): Sorting order. Valid values: FOLLOWERS_COUNT (default), NAME, NEWEST.
        - count (int, optional): Number of topics to return (default: 10, max: 20).
        - after (str, optional): Pagination cursor for next page.
    
        Returns:
        - success (bool)
        - data (dict): If successful, contains:
            - topics (list): List of topic objects (id, name, etc.)
            - pagination (dict): { end_cursor, has_next_page }
        - error (dict, optional)
        - rate_limits (dict)
    
        Notes:
        - If no topics match, `topics` will be an empty list.
        """
        params = {
            k: v
            for k, v in {
                "query": query,
                "followed_by_user_id": followed_by_user_id,
                "order": order,
                "count": count,
                "after": after,
            }.items()
            if v is not None
        }
        logger.info("topics.search_topics called", extra=params)
    
        # Apply pagination defaults
        variables = apply_pagination_defaults(count, after)
    
        # Add order parameter
        variables["order"] = order
    
        # Add optional filters
        if query:
            variables["query"] = query
        if followed_by_user_id:
            variables["followedByUserId"] = followed_by_user_id
    
        result, rate_limits, error = execute_graphql_query(TOPICS_QUERY, variables)
    
        if error:
            return format_response(False, error=error, rate_limits=rate_limits)
    
        # Extract topics
        topics_data = result["data"]["topics"]
    
        return format_response(
            True,
            data={
                "topics": topics_data["edges"],
                "pagination": extract_pagination(topics_data["pageInfo"]),
            },
            rate_limits=rate_limits,
        )
  • Validation schema used for input parameters of the search_topics tool, defining types and constraints for query, followed_by_user_id, order, count, and after.
    TOPICS_SCHEMA = {
        "query": {"type": str},
        "followed_by_user_id": {"type": str},
        "order": {"type": str, "valid_values": ["FOLLOWERS_COUNT", "NEWEST", "NAME"]},
        "count": {"type": int, "min_value": 1, "max_value": 20},
        "after": {"type": str},
    }
  • Invocation of register_topic_tools(mcp) in the main CLI entry point, which defines and registers the search_topics tool among others.
    register_topic_tools(mcp)
  • The registration function that contains the definition of the search_topics tool with @mcp.tool() decorator.
    def register_topic_tools(mcp):
        """Register topic-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 the full burden of behavioral disclosure. It effectively describes key behaviors: the tool supports search and filtering with sorting and pagination, specifies default values (e.g., order default, count default and max), notes that empty results return an empty list, and mentions rate limits in returns. This covers operational aspects well, though it could add more on permissions or error handling.

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?

The description is well-structured with clear sections for purpose, parameters, returns, and notes. It's appropriately sized, with each sentence adding value (e.g., explaining defaults, empty results). Minor verbosity in listing all parameters could be streamlined, but overall it's efficient and front-loaded with the core purpose.

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

Completeness4/5

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

Given the tool's moderate complexity (5 parameters, no annotations, no output schema), the description is quite complete. It covers purpose, all parameters with semantics, return structure, and behavioral notes like empty results and rate limits. It lacks output schema, but describes returns in detail, making it nearly comprehensive for agent use.

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?

The schema description coverage is 0%, so the description must compensate fully. It provides detailed parameter semantics: each parameter is listed with types, optional status, valid values for 'order', defaults, and constraints (e.g., count max). This adds significant meaning beyond the bare schema, fully documenting all 5 parameters with practical usage details.

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 searches for topics by name or filters by user following, with optional sorting and pagination. It specifies the verb 'search' and resource 'topics', making the purpose evident. However, it doesn't explicitly differentiate from sibling tools like 'get_topic', which might retrieve a single topic by ID, leaving some ambiguity in sibling differentiation.

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

Usage Guidelines3/5

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

The description implies usage for searching or filtering topics, but provides no explicit guidance on when to use this tool versus alternatives like 'get_topic' or 'get_posts'. It mentions parameters like 'followed_by_user_id' and 'query', which suggest contexts for filtering, but lacks clear when-to-use or when-not-to-use statements compared to siblings.

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