Skip to main content
Glama

candles

Retrieve OHLCV candlestick data for any cryptocurrency. Obtain open, high, low, and close prices for specified historical periods to analyze price action.

Instructions

Get OHLCV candlestick data for any crypto. Returns open, high, low, close for each period.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolYesCrypto symbol
daysNoNumber of days of history (1, 7, 14, 30, 90, 180, 365). Default: 7

Implementation Reference

  • index.js:80-99 (handler)
    The async function getCryptoCandles(symbol, interval, days) fetches OHLCV candlestick data from the CoinGecko API and maps the response to {time, open, high, low, close} objects.
    async function getCryptoCandles(symbol, interval = '1h', days = 7) {
      const id = symbol.toLowerCase().replace('usdt', '').replace('usd', '');
      const idMap = {
        btc: 'bitcoin', eth: 'ethereum', sol: 'solana', doge: 'dogecoin',
        xrp: 'ripple', bnb: 'binancecoin', ada: 'cardano', avax: 'avalanche-2',
      };
      const coinId = idMap[id] || id;
    
      const data = await fetch(
        `https://api.coingecko.com/api/v3/coins/${coinId}/ohlc?vs_currency=usd&days=${days}`
      );
    
      return data.map(c => ({
        time: new Date(c[0]).toISOString(),
        open: c[1],
        high: c[2],
        low: c[3],
        close: c[4],
      }));
    }
  • Tool registration definition for 'candles' with inputSchema requiring 'symbol' (string) and optional 'days' (number).
    {
      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']
      }
  • index.js:236-316 (registration)
    The getToolDefinitions() method returns all tool definitions including 'candles'. The tools/list MCP method calls this to register tools.
    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:318-324 (registration)
    The handleToolCall() method dispatches the 'candles' case to getCryptoCandles(args.symbol, '1h', args.days || 7). The interval is hardcoded to '1h'.
    async handleToolCall(name, args) {
      switch (name) {
        case 'price':
          return await getCryptoPrice(args.symbol);
    
        case 'candles':
          return await getCryptoCandles(args.symbol, '1h', args.days || 7);
  • The fetch() helper function is used by getCryptoCandles to make HTTPS requests with JSON parsing and timeout handling.
    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')); });
      });
    }
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, description carries full burden. It accurately states this is a read operation ('Get') and lists returned fields. However, it does not disclose potential rate limits, data source, or period granularity, which are relevant for correct usage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Single sentence that is front-loaded with the main action ('Get OHLCV candlestick data'). No redundant words; every part contributes to understanding.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no output schema, description does mention return fields but omits volume (despite tool name 'candles' implying OHLCV). Missing granularity of 'period' and any behavioral constraints. Adequate but incomplete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Input schema covers both parameters with descriptions. Description adds value by clarifying the resource is crypto and specifying the returned fields (OHLC). This goes beyond the schema which only defines 'symbol' and 'days'.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description uses clear verb 'Get' and resource 'OHLCV candlestick data', specifying the output fields (open, high, low, close). It distinguishes from sibling tools like 'price' (single price) and 'market_cap' (market capitalization).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No explicit guidance on when to use this tool versus alternatives (e.g., 'price' for single point, 'order_book' for depth). No 'when not to use' or comparison to siblings.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/ShipItAndPray/mcp-market-data'

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