price
Fetch real-time cryptocurrency market data: current value, 24-hour change, volume, and market cap for any symbol like BTC, ETH, or SOL.
Instructions
Get current price, 24h change, volume, market cap for any cryptocurrency. Examples: BTC, ETH, SOL, DOGE.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| symbol | Yes | Crypto symbol (BTC, ETH, SOL, DOGE, etc.) |
Implementation Reference
- index.js:50-78 (handler)The `getCryptoPrice` async function is the actual handler/implementation of the 'price' tool. It fetches live crypto price data from CoinGecko API and returns price, 24h/7d changes, market cap, volume, high/low, and ATH data.
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:239-248 (schema)The tool definition/schema for 'price' registered in `getToolDefinitions()`. Defines name 'price', description, and inputSchema requiring a 'symbol' string.
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:318-322 (registration)The tool dispatch in `handleToolCall` — case 'price' routes to `getCryptoPrice(args.symbol)`.
async handleToolCall(name, args) { switch (name) { case 'price': return await getCryptoPrice(args.symbol);