Skip to main content
Glama

get_crypto_market_data

Retrieve comprehensive cryptocurrency market data by providing a CoinGecko ID to access current prices, trading volumes, and market capitalization for informed trading decisions.

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 implementing get_crypto_market_data. Fetches detailed market data (price, market cap, volume, changes, ATH/ATL) from CoinGecko API for a given coin_id and formats it into a readable string.
    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)
    Registration of the cryptocurrency tools, including get_crypto_market_data, via the register_tools helper which applies @mcp.tool() decorator to enable them in the MCP server.
    register_tools( [get_crypto_price, get_crypto_market_data, get_trending_crypto, search_crypto], "Cryptocurrency" )
  • server.py:21-21 (registration)
    Import statement bringing get_crypto_market_data into the MCP server module for registration.
    from tools.crypto_data import get_crypto_price, get_crypto_market_data, get_trending_crypto, search_crypto

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