Skip to main content
Glama

crypto_price_history

Retrieve historical cryptocurrency price data for analysis by specifying a coin and time period.

Instructions

Get price history for a coin over a number of days

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
coinYesCoin ID (e.g. bitcoin)
daysNoNumber of days (1, 7, 30, 90, 365)

Implementation Reference

  • The `crypto_price_history` tool is implemented here, defining the input schema (coin, days) and executing the handler by fetching market data from CoinGecko and formatting the result.
    server.tool("crypto_price_history", "Get price history for a coin over a number of days", {
      coin: z.string().describe("Coin ID (e.g. bitcoin)"),
      days: z.number().default(7).describe("Number of days (1, 7, 30, 90, 365)")
    }, async ({ coin, days }) => {
      const data = await safeFetch(`https://api.coingecko.com/api/v3/coins/${coin}/market_chart?vs_currency=usd&days=${days}`);
      const prices = data.prices;
      const first = prices[0][1];
      const last = prices[prices.length - 1][1];
      const change = ((last - first) / first) * 100;
      const high = Math.max(...prices.map((p: any) => p[1]));
      const low = Math.min(...prices.map((p: any) => p[1]));
      return { content: [{ type: "text", text: `**${coin.toUpperCase()} — ${days}d History**\nStart: ${formatCurrency(first)}\nEnd: ${formatCurrency(last)}\nChange: ${formatPercent(change)}\nHigh: ${formatCurrency(high)}\nLow: ${formatCurrency(low)}\nData Points: ${prices.length}` }] };
    });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ElromEvedElElyon/claw-mcp-toolkit'

If you have feedback or need assistance with the MCP directory API, please join our Discord server