Skip to main content
Glama

price

Retrieve current cryptocurrency prices, 24-hour changes, trading volume, and market capitalization data for assets like BTC, ETH, SOL, and DOGE.

Instructions

Get current price, 24h change, volume, market cap for any cryptocurrency. Examples: BTC, ETH, SOL, DOGE.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolYesCrypto symbol (BTC, ETH, SOL, DOGE, etc.)

Implementation Reference

  • index.js:50-78 (handler)
    The getCryptoPrice function fetches live cryptocurrency price data from CoinGecko.
    async function getCryptoPrice(symbol) {
      const id = symbol.toLowerCase().replace('usdt', '').replace('usd', '');
      const idMap = {
        btc: 'bitcoin', eth: 'ethereum', sol: 'solana', doge: 'dogecoin',
        xrp: 'ripple', ada: 'cardano', avax: 'avalanche-2', dot: 'polkadot',
        matic: 'matic-network', link: 'chainlink', uni: 'uniswap', atom: 'cosmos',
        near: 'near', apt: 'aptos', sui: 'sui', arb: 'arbitrum',
        op: 'optimism', bnb: 'binancecoin', ltc: 'litecoin', bch: 'bitcoin-cash',
      };
      const coinId = idMap[id] || id;
    
      const data = await fetch(
        `https://api.coingecko.com/api/v3/coins/${coinId}?localization=false&tickers=false&community_data=false&developer_data=false`
      );
    
      return {
        symbol: symbol.toUpperCase(),
        name: data.name,
        price: data.market_data.current_price.usd,
        change_24h: data.market_data.price_change_percentage_24h,
        change_7d: data.market_data.price_change_percentage_7d,
        market_cap: data.market_data.market_cap.usd,
        volume_24h: data.market_data.total_volume.usd,
        high_24h: data.market_data.high_24h.usd,
        low_24h: data.market_data.low_24h.usd,
        ath: data.market_data.ath.usd,
        ath_change: data.market_data.ath_change_percentage.usd,
      };
    }
  • index.js:238-248 (registration)
    Definition of the 'price' tool within the MCP server's tool registry.
    {
      name: 'price',
      description: 'Get current price, 24h change, volume, market cap for any cryptocurrency. Examples: BTC, ETH, SOL, DOGE.',
      inputSchema: {
        type: 'object',
        properties: {
          symbol: { type: 'string', description: 'Crypto symbol (BTC, ETH, SOL, DOGE, etc.)' }
        },
        required: ['symbol']
      }
    },
  • Tool handler implementation that calls getCryptoPrice when the 'price' tool is invoked.
    case 'price':
      return await getCryptoPrice(args.symbol);

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/ShipItAndPray/mcp-market-data'

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