Skip to main content
Glama

get_crypto_price

Retrieve current cryptocurrency prices from CoinGecko for trading analysis and portfolio management within MonteWalk's quantitative finance toolkit.

Instructions

Gets the current price of a cryptocurrency. Args: coin_id: CoinGecko ID (e.g., 'bitcoin', 'ethereum', 'solana') vs_currency: Currency to compare against (default: 'usd') Returns: Dictionary with price information

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
coin_idYes
vs_currencyNousd

Implementation Reference

  • Main handler function for get_crypto_price tool. Fetches cryptocurrency price data from CoinGecko API, including price, market cap, 24h volume, and change.
    def get_crypto_price(coin_id: str, vs_currency: str = "usd") -> Dict[str, Any]: """ Gets the current price of a cryptocurrency. Args: coin_id: CoinGecko ID (e.g., 'bitcoin', 'ethereum', 'solana') vs_currency: Currency to compare against (default: 'usd') Returns: Dictionary with price information """ try: data = cg.get_price( ids=coin_id, vs_currencies=vs_currency, include_24hr_change=True, include_market_cap=True, include_24hr_vol=True ) if not data or coin_id not in data: return {"error": f"Coin '{coin_id}' not found"} coin_data = data[coin_id] return { "coin": coin_id, "price": coin_data.get(vs_currency, 0), "market_cap": coin_data.get(f"{vs_currency}_market_cap", 0), "24h_volume": coin_data.get(f"{vs_currency}_24h_vol", 0), "24h_change": coin_data.get(f"{vs_currency}_24h_change", 0), "currency": vs_currency.upper() } except Exception as e: logger.error(f"CoinGecko error for {coin_id}: {e}") return {"error": str(e)}
  • server.py:415-418 (registration)
    Registers the get_crypto_price tool (and related crypto tools) with the MCP server using the register_tools helper, which applies the @mcp.tool() decorator.
    register_tools( [get_crypto_price, get_crypto_market_data, get_trending_crypto, search_crypto], "Cryptocurrency" )
  • Global CoinGeckoAPI client initialization used by get_crypto_price and other crypto tools.
    # Initialize CoinGecko client cg = CoinGeckoAPI()
  • server.py:21-21 (registration)
    Import statement bringing get_crypto_price 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