Skip to main content
Glama

get_crypto_market_data

Retrieve comprehensive cryptocurrency market data including price, volume, and market cap for trading analysis and portfolio management.

Instructions

Gets comprehensive market data for a cryptocurrency. Args: coin_id: CoinGecko ID (e.g., 'bitcoin', 'ethereum') Returns: Formatted string with market data

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
coin_idYes

Implementation Reference

  • The core handler function for the 'get_crypto_market_data' tool. It takes a coin_id (e.g., 'bitcoin'), queries the CoinGecko API for detailed market data, and returns a formatted multi-line string with current price, market cap, volume, percentage changes (24h/7d/30d), and all-time high/low information.
    def get_crypto_market_data(coin_id: str) -> str: """ Gets comprehensive market data for a cryptocurrency. Args: coin_id: CoinGecko ID (e.g., 'bitcoin', 'ethereum') Returns: Formatted string with market data """ try: data = cg.get_coin_by_id( id=coin_id, localization=False, tickers=False, market_data=True, community_data=False, developer_data=False ) market = data.get("market_data", {}) return f""" Crypto Market Data: {data.get('name', coin_id).upper()} Symbol: {data.get('symbol', 'N/A').upper()} -------------------------------- Current Price: ${market.get('current_price', {}).get('usd', 0):,.2f} Market Cap: ${market.get('market_cap', {}).get('usd', 0):,.0f} 24h Volume: ${market.get('total_volume', {}).get('usd', 0):,.0f} -------------------------------- 24h Change: {market.get('price_change_percentage_24h', 0):.2f}% 7d Change: {market.get('price_change_percentage_7d', 0):.2f}% 30d Change: {market.get('price_change_percentage_30d', 0):.2f}% -------------------------------- All-Time High: ${market.get('ath', {}).get('usd', 0):,.2f} ATH Date: {market.get('ath_date', {}).get('usd', 'N/A')[:10]} All-Time Low: ${market.get('atl', {}).get('usd', 0):,.2f} ATL Date: {market.get('atl_date', {}).get('usd', 'N/A')[:10]} """ except Exception as e: logger.error(f"CoinGecko error for {coin_id}: {e}") return f"Error fetching market data for {coin_id}: {str(e)}"
  • server.py:415-418 (registration)
    Registers the get_crypto_market_data tool (along with related crypto tools) as an MCP tool in the 'Cryptocurrency' category using the register_tools helper function.
    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_crypto_market_data function into the server.py module for registration as an MCP tool.
    from tools.crypto_data import get_crypto_price, get_crypto_market_data, get_trending_crypto, search_crypto
  • Global CoinGeckoAPI client initialization used by get_crypto_market_data and other crypto tools.
    # Initialize CoinGecko client cg = CoinGeckoAPI()

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/N-lia/MonteWalk'

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