Skip to main content
Glama
Talhelf
by Talhelf

trending_searches

Find trending and related search terms for adult entertainment keywords to analyze market patterns and discover emerging topics.

Instructions

Find trending and related searches for a keyword.

Args:
    base_keyword: Main keyword to find related searches for
                 Example: "pornhub", "onlyfans", or any performer name
    timeframe: Time period (default: past 12 months)
    region: Region code (default: US)

Returns:
    List of related and rising search terms.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
base_keywordYes
timeframeNotoday 12-m
regionNoUS

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Main handler function for the trending_searches tool. Decorated with @mcp.tool(), it takes a base_keyword, timeframe, and region as parameters, fetches Google Trends data, and returns formatted trending and related searches for the keyword.
    @mcp.tool()
    async def trending_searches(
        base_keyword: str,
        timeframe: str = "today 12-m",
        region: str = "US"
    ) -> str:
        """
        Find trending and related searches for a keyword.
        
        Args:
            base_keyword: Main keyword to find related searches for
                         Example: "pornhub", "onlyfans", or any performer name
            timeframe: Time period (default: past 12 months)
            region: Region code (default: US)
        
        Returns:
            List of related and rising search terms.
        """
        
        data = get_trends_data([base_keyword], timeframe, region)
        
        if "error" in data:
            return f"❌ Error: {data['error']}"
        
        result = [
            f"🔥 Trending Searches Related to '{base_keyword}'",
            f"Region: {region if region else 'Worldwide'}",
            f"Period: {timeframe}",
            "=" * 60,
            "",
            format_related_queries(data),
            "",
            f"Data fetched: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}"
        ]
        
        return "\n".join(result)
  • Helper function get_trends_data that fetches Google Trends data for given keywords. Implements caching mechanism to avoid excessive API calls and returns interest over time, interest by region, and related queries data.
    def get_trends_data(keywords: list[str], timeframe: str = 'today 12-m', geo: str = 'US') -> dict:
        """
        Fetch Google Trends data for given keywords.
        
        Args:
            keywords: List of search terms to compare (max 5)
            timeframe: Time period (e.g., 'today 12-m', 'today 5-y', '2020-01-01 2024-12-31')
            geo: Geographic region (e.g., 'US', 'GB', '' for worldwide)
        
        Returns:
            Dictionary with trends data
        """
        if not pytrends:
            return {"error": "Google Trends API not available"}
        
        # Check cache
        cache_key = f"{','.join(keywords)}_{timeframe}_{geo}"
        if cache_key in TRENDS_CACHE:
            cached = TRENDS_CACHE[cache_key]
            age = (datetime.now() - datetime.fromisoformat(cached['fetched_at'])).seconds
            if age < 3600:  # Cache for 1 hour
                print(f"Using cached data (age: {age}s)", file=sys.stderr)
                return cached
        
        try:
            print(f"Fetching Google Trends: {keywords}, {timeframe}, {geo}", file=sys.stderr)
            
            # Build payload
            pytrends.build_payload(keywords, cat=0, timeframe=timeframe, geo=geo, gprop='')
            
            # Get interest over time
            interest_over_time_df = pytrends.interest_over_time()
            
            # Get interest by region
            try:
                interest_by_region_df = pytrends.interest_by_region(resolution='REGION', inc_low_vol=True, inc_geo_code=False)
            except Exception as e:
                print(f"Could not fetch regional data: {e}", file=sys.stderr)
                interest_by_region_df = pd.DataFrame()
            
            # Get related queries
            try:
                related_queries = pytrends.related_queries()
            except Exception as e:
                print(f"Could not fetch related queries: {e}", file=sys.stderr)
                related_queries = {}
            
            result = {
                "keywords": keywords,
                "timeframe": timeframe,
                "geo": geo,
                "interest_over_time": interest_over_time_df.to_dict() if not interest_over_time_df.empty else {},
                "interest_by_region": interest_by_region_df.to_dict() if not interest_by_region_df.empty else {},
                "related_queries": related_queries,
                "fetched_at": datetime.now().isoformat()
            }
            
            # Cache the result
            TRENDS_CACHE[cache_key] = result
  • Helper function format_related_queries that formats the related queries data from Google Trends API into a readable string format with top queries and rising queries sections.
    def format_related_queries(data: dict) -> str:
        """Format related queries data."""
        if "error" in data or not data.get("related_queries"):
            return ""
        
        lines = [
            "",
            "🔍 Related & Trending Queries",
            "=" * 60,
            ""
        ]
        
        related = data['related_queries']
        for keyword in data['keywords']:
            if keyword in related:
                lines.append(f"Related to '{keyword}':")
                
                # Top related queries
                if 'top' in related[keyword] and related[keyword]['top'] is not None:
                    top_df = related[keyword]['top']
                    if not top_df.empty:
                        lines.append("  Top:")
                        for idx, row in top_df.head(5).iterrows():
                            lines.append(f"    • {row['query']} ({row['value']})")
                
                # Rising queries
                if 'rising' in related[keyword] and related[keyword]['rising'] is not None:
                    rising_df = related[keyword]['rising']
                    if not rising_df.empty:
                        lines.append("  Rising:")
                        for idx, row in rising_df.head(5).iterrows():
                            growth = row['value']
                            if growth == 'Breakout':
                                lines.append(f"    • {row['query']} (🔥 Breakout)")
                            else:
                                lines.append(f"    • {row['query']} (+{growth}%)")
                
                lines.append("")
        
        return "\n".join(lines)
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions the tool 'finds' data, implying a read-only operation, but doesn't specify aspects like rate limits, authentication needs, data sources, or error handling. For a tool with zero annotation coverage, this is a significant gap in transparency.

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

Conciseness5/5

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

The description is well-structured and front-loaded, starting with a clear purpose sentence. It efficiently lists args and returns in bullet-like sections without unnecessary details. Every sentence adds value, making it appropriately sized and easy to parse.

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

Completeness3/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 (3 parameters, no annotations, but with an output schema), the description is somewhat complete. It covers the purpose and parameters but lacks behavioral details and usage guidelines. The output schema exists, so the description doesn't need to explain return values, but overall gaps in transparency and guidelines reduce completeness.

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

Parameters4/5

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

The description adds meaningful context beyond the input schema, which has 0% description coverage. It explains 'base_keyword' with examples ('pornhub', 'onlyfans'), clarifies 'timeframe' as a time period with a default, and defines 'region' as a region code with a default. This compensates well for the schema's lack of descriptions, though it doesn't detail format constraints (e.g., region code standards).

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: 'Find trending and related searches for a keyword.' It specifies the verb ('find') and resource ('trending and related searches'), making the function evident. However, it doesn't explicitly differentiate from sibling tools like 'search_trends' or 'historical_analysis,' which might offer overlapping functionality, preventing a perfect score.

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. It mentions parameters like 'base_keyword' with examples but doesn't clarify scenarios where this tool is preferred over siblings such as 'analyze_category_trends' or 'compare_performers.' This lack of context leaves usage ambiguous.

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/Talhelf/ph-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server