compare
Compare asset prices, changes, and market caps side by side by providing a comma-separated list of symbols.
Instructions
Compare multiple assets side by side — prices, changes, market caps.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| symbols | Yes | Comma-separated symbols (e.g., "BTC,ETH,SOL") |
Implementation Reference
- index.js:340-352 (handler)Handler for the 'compare' tool: splits comma-separated symbols, fetches price data for each (up to 10), and returns results side by side.
case 'compare': { const symbols = args.symbols.split(',').map(s => s.trim()); const results = []; for (const sym of symbols.slice(0, 10)) { try { const p = await getCryptoPrice(sym); results.push(p); } catch (e) { results.push({ symbol: sym, error: e.message }); } } return results; } - index.js:299-309 (schema)Schema definition and registration for the 'compare' tool within getToolDefinitions().
{ name: 'compare', description: 'Compare multiple assets side by side — prices, changes, market caps.', inputSchema: { type: 'object', properties: { symbols: { type: 'string', description: 'Comma-separated symbols (e.g., "BTC,ETH,SOL")' } }, required: ['symbols'] } }, - index.js:236-316 (registration)The tool definitions are returned by getToolDefinitions() and listed via 'tools/list' in the MCP protocol.
getToolDefinitions() { return [ { 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'] } }, { name: 'candles', description: 'Get OHLCV candlestick data for any crypto. Returns open, high, low, close for each period.', inputSchema: { type: 'object', properties: { symbol: { type: 'string', description: 'Crypto symbol' }, days: { type: 'number', description: 'Number of days of history (1, 7, 14, 30, 90, 180, 365). Default: 7' } }, required: ['symbol'] } }, { name: 'order_book', description: 'Get live order book — top 20 bids and asks with spread. Shows market depth and liquidity.', inputSchema: { type: 'object', properties: { symbol: { type: 'string', description: 'Trading pair (BTC, ETHUSDT, etc.)' } }, required: ['symbol'] } }, { name: 'market_cap', description: 'Get top cryptocurrencies ranked by market cap with prices, volumes, and 24h changes.', inputSchema: { type: 'object', properties: { limit: { type: 'number', description: 'Number of coins to return (default: 20, max: 100)' } } } }, { name: 'trending', description: 'Get trending cryptocurrencies right now — what people are searching for and trading.', inputSchema: { type: 'object', properties: {} } }, { name: 'analyze', description: 'Technical analysis for any crypto: RSI, SMA, volatility, z-score, trend direction. Actionable signals included.', inputSchema: { type: 'object', properties: { symbol: { type: 'string', description: 'Crypto symbol' }, days: { type: 'number', description: 'Lookback period in days (default: 30)' } }, required: ['symbol'] } }, { name: 'compare', description: 'Compare multiple assets side by side — prices, changes, market caps.', inputSchema: { type: 'object', properties: { symbols: { type: 'string', description: 'Comma-separated symbols (e.g., "BTC,ETH,SOL")' } }, required: ['symbols'] } }, { name: 'feargreed', description: 'Crypto Fear & Greed Index — market sentiment indicator. Shows last 7 days.', inputSchema: { type: 'object', properties: {} } } ]; } - index.js:50-78 (helper)Helper function getCryptoPrice() is called by the compare handler to fetch price data for each symbol via CoinGecko API.
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, }; }