Skip to main content
Glama

get_trending_tokens_by_source

Retrieve top traded tokens from specified platforms like Telegram, Web, or Mobile within the last 12 hours. Returns a formatted table with rank, token name, mint address, trading volume, and total trades. Ideal for tracking trending memecoins and Solana-based tokens.

Instructions

Retrieve top traded tokens on specified source platform in the last 12 hours.

Args:
    source (str): The platform to query tokens from. Must be one of: 'Telegram', 'Web', 'Mobile'.
        Defaults to 'Telegram'.
    limit (int): Maximum number of tokens to return. Defaults to 100.

Returns:
    str: A formatted table of trending tokens including rank, token name, mint address,
        trading volume, and total trades, or an error message if the query fails.

Raises:
    ValueError: If an invalid source value is provided.
    httpx.HTTPStatusError: If the Dune API request fails.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNo
sourceNoTelegram

Implementation Reference

  • main.py:56-95 (handler)
    The handler function decorated with @mcp.tool() that implements the get_trending_tokens_by_source tool. It fetches data from Dune API queries based on the source (Telegram, Web, Mobile), processes the rows into a table format using helpers, and returns a markdown table or error message.
    def get_trending_tokens_by_source(source: str = "Telegram", limit: int = 100) -> str:
        """Retrieve top traded tokens on specified source platform in the last 12 hours.
    
        Args:
            source (str): The platform to query tokens from. Must be one of: 'Telegram', 'Web', 'Mobile'.
                Defaults to 'Telegram'.
            limit (int): Maximum number of tokens to return. Defaults to 100.
    
        Returns:
            str: A formatted table of trending tokens including rank, token name, mint address,
                trading volume, and total trades, or an error message if the query fails.
    
        Raises:
            ValueError: If an invalid source value is provided.
            httpx.HTTPStatusError: If the Dune API request fails.
        """
        query_ids = {
            "Telegram": 4830187,
            "Web": 4830192,
            "Mobile": 4930328,
        }    
        try:
            query_id = query_ids.get(source)
            if query_id is None:
                raise ValueError("Invalid source value. Allowed: Telegram | Web | Mobile")
            data = get_latest_result(query_id, limit=limit)
            rows = [
                [ 
                    row["rank"], 
                    strip_a_tag(row["token_link"]), 
                    row["token_mint_address"], 
                    f'${row["total_volume_usd"]:.2f}', 
                    row["total_trades"] 
                ]
                for row in data
            ]
            headers = ["Rank", "Token", "Mint Address", "Volume(12h)", "Total Trades"]    
            return f"# Top {limit} Trending Tokens on {source} - Last 12 Hours\n\n" + tabulate(rows, headers=headers)
        except Exception as e:
            return str(e)
  • main.py:23-46 (helper)
    Helper function to retrieve the latest execution results from a specified Dune Analytics query ID, used by the tool to fetch raw data.
    def get_latest_result(query_id: int, limit: int = 1000):
        """
        Fetch the latest results from a Dune Analytics query.
    
        Args:
            query_id (int): The ID of the Dune query to fetch results from.
            limit (int, optional): Maximum number of rows to return. Defaults to 1000.
    
        Returns:
            list: A list of dictionaries containing the query results, or an empty list if the request fails.
    
        Raises:
            httpx.HTTPStatusError: If the API request fails due to a client or server error.
        """
        url = f"{BASE_URL}/query/{query_id}/results"
        params = {"limit": limit}
        with httpx.Client() as client:
            response = client.get(url, params=params, headers=HEADERS, timeout=300)
            response.raise_for_status()
            data = response.json()
            
        result_data = data.get("result", {}).get("rows", [])
        return result_data
  • main.py:47-50 (helper)
    Helper utility to extract text content from HTML anchor tags, used to clean token names in the tool's output.
    def strip_a_tag(html):
        match = re.search(r'>(.*?)</a>', html)
        return match.group(1) if match else html
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 the tool's behavior: time-bound query (last 12 hours), default values, error conditions (ValueError for invalid source, HTTPStatusError for API failure), and return format (formatted table or error message). It doesn't mention rate limits or authentication requirements, but covers core operational behavior well.

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 efficiently structured with a clear purpose statement followed by well-organized sections (Args, Returns, Raises). Every sentence adds value: the opening establishes scope, parameter sections provide essential details, and error documentation helps anticipate failures. No wasted words.

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 2-parameter tool with no annotations and no output schema, the description provides complete context. It covers purpose, parameters with semantics and constraints, return format, error conditions, and temporal scope. The agent has all necessary information to invoke this tool correctly without needing additional structured data.

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 comprehensive parameter documentation. It explains both parameters (source and limit), specifies allowed values for source ('Telegram', 'Web', 'Mobile'), indicates defaults, and describes their purpose in the context of the query.

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

Purpose5/5

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

The description clearly states the specific action ('Retrieve top traded tokens'), resource ('on specified source platform'), and temporal scope ('in the last 12 hours'). It explicitly distinguishes this tool from sibling tools by focusing on source platforms rather than other criteria like KOL trading volume or specific exchanges like PumpSwap/Raydium.

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

Usage Guidelines4/5

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

The description provides clear context about when to use this tool (querying trending tokens by source platform with 12-hour recency). However, it doesn't explicitly state when NOT to use it or name specific alternatives among the sibling tools, though the distinction is implied through the different query criteria.

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

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/kukapay/memecoin-radar-mcp'

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