get_trending_crypto
Retrieve top trending cryptocurrencies from the last 24 hours to identify market movements and inform trading decisions.
Instructions
Gets the top trending cryptocurrencies in the last 24 hours.
Returns:
Formatted string with trending coins
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- tools/crypto_data.py:94-120 (handler)The core handler function that fetches trending cryptocurrencies from CoinGecko API, formats the top 10 into a ranked list, and returns as a formatted string. No input parameters required.def get_trending_crypto() -> str: """ Gets the top trending cryptocurrencies in the last 24 hours. Returns: Formatted string with trending coins """ try: data = cg.get_search_trending() coins = data.get('coins', []) if not coins: return "No trending coins data available" summary = ["=== TRENDING CRYPTOCURRENCIES (24h) ===\n"] for i, item in enumerate(coins[:10], 1): coin = item.get('item', {}) summary.append( f"{i}. {coin.get('name')} ({coin.get('symbol', 'N/A').upper()})" f" - Rank #{coin.get('market_cap_rank', 'N/A')}" ) return "\n".join(summary) except Exception as e: logger.error(f"CoinGecko error: {e}") return f"Error fetching trending coins: {str(e)}"
- server.py:415-418 (registration)Registers get_trending_crypto as an MCP tool using the register_tools helper, which applies @mcp.tool() decorator to it along with other crypto tools.register_tools( [get_crypto_price, get_crypto_market_data, get_trending_crypto, search_crypto], "Cryptocurrency" )
- server.py:21-21 (registration)Import statement that brings the get_trending_crypto function into the server module for registration.from tools.crypto_data import get_crypto_price, get_crypto_market_data, get_trending_crypto, search_crypto
- server.py:121-127 (helper)MCP resource that proxies calls to get_trending_crypto, providing trending crypto data via the 'crypto://trending' URI.@mcp.resource("crypto://trending") def get_crypto_resource() -> str: """ Returns the top trending cryptocurrencies. """ return get_trending_crypto()