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
| Name | Required | Description | Default |
|---|---|---|---|
| symbol | Yes | Crypto 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'] } }, - index.js:320-321 (handler)Tool handler implementation that calls getCryptoPrice when the 'price' tool is invoked.
case 'price': return await getCryptoPrice(args.symbol);