crypto_price
Get current cryptocurrency prices, market capitalization, and 24-hour change data for any coin. Input a coin ID to retrieve real-time financial metrics.
Instructions
Get current price, market cap, and 24h change for any cryptocurrency
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| coin | Yes | Coin ID (e.g. bitcoin, ethereum, solana) |
Implementation Reference
- src/modules/crypto.ts:8-15 (handler)Registration and handler implementation for the "crypto_price" tool.
server.tool("crypto_price", "Get current price, market cap, and 24h change for any cryptocurrency", { coin: z.string().describe("Coin ID (e.g. bitcoin, ethereum, solana)") }, async ({ coin }) => { const data = await safeFetch(`https://api.coingecko.com/api/v3/simple/price?ids=${coin}&vs_currencies=usd&include_market_cap=true&include_24hr_change=true&include_24hr_vol=true`); const c = data[coin]; if (!c) return { content: [{ type: "text", text: `Coin "${coin}" not found. Try: bitcoin, ethereum, solana, dogecoin` }] }; return { content: [{ type: "text", text: `**${coin.toUpperCase()}**\nPrice: ${formatCurrency(c.usd)}\nMarket Cap: ${formatNumber(c.usd_market_cap)}\n24h Change: ${formatPercent(c.usd_24h_change)}\n24h Volume: ${formatNumber(c.usd_24h_vol)}` }] }; });