market_cap
Retrieve cryptocurrency market capitalization rankings with prices, volumes, and 24-hour changes to analyze market trends and asset performance.
Instructions
Get top cryptocurrencies ranked by market cap with prices, volumes, and 24h changes.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Number of coins to return (default: 20, max: 100) |
Implementation Reference
- index.js:122-135 (handler)The `getMarketCap` function fetches top cryptocurrencies by market cap from the CoinGecko API.
async function getMarketCap(limit = 20) { const data = await fetch( `https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&order=market_cap_desc&per_page=${limit}&page=1&sparkline=false` ); return data.map((c, i) => ({ rank: i + 1, symbol: c.symbol.toUpperCase(), name: c.name, price: c.current_price, market_cap: c.market_cap, volume_24h: c.total_volume, change_24h: c.price_change_percentage_24h, })); } - index.js:273-281 (registration)The `market_cap` tool is defined in the `getToolDefinitions` method of the `MCPMarketServer` class.
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)' } } } }, - index.js:329-330 (handler)The `handleToolCall` method handles the `market_cap` tool invocation by calling `getMarketCap`.
case 'market_cap': return await getMarketCap(Math.min(args.limit || 20, 100));