Skip to main content
Glama

analyze

Perform technical analysis on cryptocurrencies using RSI, SMA, volatility, z-score, and trend direction to generate actionable trading signals.

Instructions

Technical analysis for any crypto: RSI, SMA, volatility, z-score, trend direction. Actionable signals included.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolYesCrypto symbol
daysNoLookback period in days (default: 30)

Implementation Reference

  • The tool handler for 'analyze' within MCPMarketServer.handleToolCall. It fetches candlestick data and passes it to the technicalAnalysis function.
    case 'analyze': {
      const candles = await getCryptoCandles(args.symbol, '1h', args.days || 30);
      return technicalAnalysis(candles);
    }
  • The helper function `technicalAnalysis` that performs the actual RSI, SMA, volatility, and z-score calculations.
    function technicalAnalysis(candles) {
      const closes = candles.map(c => c.close);
      const n = closes.length;
      if (n < 14) return { error: 'Need at least 14 candles for analysis' };
    
      // SMA
      const sma20 = closes.slice(-20).reduce((a, b) => a + b, 0) / Math.min(20, n);
      const sma50 = n >= 50 ? closes.slice(-50).reduce((a, b) => a + b, 0) / 50 : null;
    
      // RSI (14-period)
      let gains = 0, losses = 0;
      for (let i = n - 14; i < n; i++) {
        const diff = closes[i] - closes[i - 1];
        if (diff > 0) gains += diff;
        else losses -= diff;
      }
      const avgGain = gains / 14;
      const avgLoss = losses / 14;
      const rs = avgLoss === 0 ? 100 : avgGain / avgLoss;
      const rsi = 100 - (100 / (1 + rs));
    
      // Volatility
      const returns = [];
      for (let i = 1; i < n; i++) {
        returns.push(Math.log(closes[i] / closes[i - 1]));
      }
      const mean = returns.reduce((a, b) => a + b, 0) / returns.length;
      const variance = returns.reduce((a, b) => a + (b - mean) ** 2, 0) / returns.length;
      const volatility = Math.sqrt(variance);
    
      // Z-score
      const allMean = closes.reduce((a, b) => a + b, 0) / n;
      const std = Math.sqrt(closes.reduce((a, b) => a + (b - allMean) ** 2, 0) / n);
      const zscore = std > 0 ? (closes[n - 1] - allMean) / std : 0;
    
      // Trend
      const recent = closes.slice(-5);
      const older = closes.slice(-10, -5);
      const recentAvg = recent.reduce((a, b) => a + b, 0) / recent.length;
      const olderAvg = older.length > 0 ? older.reduce((a, b) => a + b, 0) / older.length : recentAvg;
    
      const current = closes[n - 1];
    
      return {
        current_price: current,
        sma_20: Math.round(sma20 * 100) / 100,
        sma_50: sma50 ? Math.round(sma50 * 100) / 100 : 'insufficient data',
        rsi_14: Math.round(rsi * 100) / 100,
        rsi_signal: rsi > 70 ? 'OVERBOUGHT' : rsi < 30 ? 'OVERSOLD' : 'NEUTRAL',
        volatility: Math.round(volatility * 10000) / 10000,
        volatility_annualized: Math.round(volatility * Math.sqrt(365 * 24) * 10000) / 100 + '%',
        zscore: Math.round(zscore * 100) / 100,
        zscore_signal: zscore > 2 ? 'EXTENDED HIGH' : zscore < -2 ? 'EXTENDED LOW' : 'NORMAL',
        trend: recentAvg > olderAvg * 1.01 ? 'UPTREND' : recentAvg < olderAvg * 0.99 ? 'DOWNTREND' : 'SIDEWAYS',
        price_vs_sma20: current > sma20 ? 'ABOVE' : 'BELOW',
        high: Math.max(...closes),
        low: Math.min(...closes),
        range_pct: ((Math.max(...closes) - Math.min(...closes)) / Math.min(...closes) * 100).toFixed(2) + '%',
      };
    }
  • index.js:288-298 (registration)
    Registration of the 'analyze' tool in the getToolDefinitions method.
      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']
      }
    },
Behavior3/5

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

No annotations are provided, so the description carries the full disclosure burden. It effectively communicates what calculations are performed and mentions 'Actionable signals included', hinting at trading signal outputs. However, it lacks critical behavioral context such as data freshness, rate limits, error handling for invalid symbols, or whether this is a read-only operation.

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?

The description consists of two efficient sentences. The first front-loads the core capability (technical analysis) followed by a colon-delimited list of specific indicators. The second sentence adds distinct information about actionable signals. No words are wasted.

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

Completeness4/5

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

Given the simple flat schema with only 2 parameters and no output schema, the description adequately compensates by listing the specific technical indicators and signals returned. It appropriately focuses on the analytical outputs since the input schema is self-documenting. Missing only structural details about the response format.

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

Parameters3/5

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

With 100% schema description coverage ('Crypto symbol' and 'Lookback period in days'), the schema already explains the parameters fully. The description does not add semantic context beyond the schema (e.g., symbol format like 'BTC-USD' vs 'BTC', or typical day ranges for short-term vs long-term analysis), so it meets the baseline score for high-coverage schemas.

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

Purpose4/5

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

The description clearly states the tool performs 'Technical analysis' on crypto assets and specifically lists the calculated indicators (RSI, SMA, volatility, z-score, trend direction). This provides a specific verb and resource. However, it does not explicitly differentiate from sibling tools like 'price' or 'candles' which return raw market data rather than calculated analytics.

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?

The description provides no guidance on when to use this tool versus alternatives like 'price', 'candles', or 'compare'. It does not mention prerequisites (e.g., valid trading pairs) or exclusions. The user must infer from the description that this is for technical indicator calculation rather than raw data retrieval.

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