Skip to main content
Glama

ta_rsi

Calculate the Relative Strength Index (RSI) for crypto market analysis using Wilder's method to identify overbought or oversold conditions in token price data.

Instructions

Compute RSI (Wilder). Inputs: values:number[] (oldest→newest), period?:number(14). Returns latest RSI.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
valuesYes
periodNo

Implementation Reference

  • MCP tool handler for ta_rsi: validates input array of values and period, calls taRSI helper, returns RSI value or error.
    "ta_rsi": async (args) => { const values = Array.isArray(args?.values) ? args.values : null; const period = Number.isFinite(Number(args?.period)) ? Number(args.period) : 14; if (!values || values.length === 0) { return { content: textContent({ error:true, message:"'values' must be a non-empty array of numbers (oldest → newest)" }), isError:true }; } const out = taRSI(values, period); return { content: textContent({ ok:true, rsi: out, period }) }; },
  • mcp-server.js:328-335 (registration)
    Registration of ta_rsi tool in the tools list, including description, input schema, and annotations for MCP protocol.
    { name:"ta_rsi", description:"Compute RSI (Wilder). Inputs: values:number[] (oldest→newest), period?:number(14). Returns latest RSI.", inputSchema:{ type:"object", properties:{ values:{ type:"array", items:{ type:"number" } }, period:{ type:"number" } }, required:["values"] }, annotations:{ title:"TA: RSI", readOnlyHint:true, openWorldHint:false } },
  • Input schema definition for ta_rsi tool parameters.
    inputSchema:{ type:"object", properties:{ values:{ type:"array", items:{ type:"number" } }, period:{ type:"number" } }, required:["values"] },
  • Core implementation of RSI (Wilder's method) computation function, exported and used as taRSI by the handler.
    export function rsi(values, period = 14) { const arr = normalize(values); if (arr.length < period + 1) return null; // Seed averages over the first `period` deltas let gains = 0, losses = 0; for (let i = 1; i <= period; i++) { const d = arr[i] - arr[i - 1]; if (d >= 0) gains += d; else losses -= d; } let avgGain = gains / period; let avgLoss = losses / period; // Wilder smoothing for the remaining deltas for (let i = period + 1; i < arr.length; i++) { const d = arr[i] - arr[i - 1]; const gain = d > 0 ? d : 0; const loss = d < 0 ? -d : 0; avgGain = (avgGain * (period - 1) + gain) / period; avgLoss = (avgLoss * (period - 1) + loss) / period; } if (!isFiniteNum(avgGain) || !isFiniteNum(avgLoss)) return null; // Handle flat / division-by-zero cases explicitly if (avgLoss === 0) { if (avgGain === 0) return 50; // perfectly flat return 100; // only gains } const rs = avgGain / avgLoss; if (!isFiniteNum(rs)) return null; const rsi = 100 - (100 / (1 + rs)); return isFiniteNum(rsi) ? clamp(rsi, 0, 100) : null; }

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/JCF0/cg-alpha-mcp'

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