trending
Identify which cryptocurrencies are trending by analyzing real-time search and trading activity.
Instructions
Get trending cryptocurrencies right now — what people are searching for and trading.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- index.js:137-147 (handler)The getTrending() function fetches trending cryptocurrencies from CoinGecko's /search/trending API and returns an array of coins with name, symbol, market_cap_rank, and price_btc.
async function getTrending() { const data = await fetch('https://api.coingecko.com/api/v3/search/trending'); return { coins: data.coins.map(c => ({ name: c.item.name, symbol: c.item.symbol, market_cap_rank: c.item.market_cap_rank, price_btc: c.item.price_btc, })), }; } - index.js:282-285 (schema)Tool definition/schema for the 'trending' tool: accepts no input parameters and returns trending cryptocurrencies.
{ name: 'trending', description: 'Get trending cryptocurrencies right now — what people are searching for and trading.', inputSchema: { type: 'object', properties: {} } - index.js:332-333 (registration)The switch-case handler in handleToolCall() that dispatches 'trending' calls to getTrending().
case 'trending': return await getTrending(); - index.js:31-44 (helper)The fetch() helper used by getTrending() to make HTTP requests to the CoinGecko API.
function fetch(url) { return new Promise((resolve, reject) => { const req = https.get(url, { headers: { 'User-Agent': 'mcp-market-data/0.1' } }, (res) => { let data = ''; res.on('data', chunk => data += chunk); res.on('end', () => { try { resolve(JSON.parse(data)); } catch (e) { reject(new Error(`Parse error: ${data.slice(0, 200)}`)); } }); }); req.on('error', reject); req.setTimeout(15000, () => { req.destroy(); reject(new Error('Timeout')); }); }); }