Skip to main content
Glama
nonnname

T-Invest MCP Server

by nonnname

get_tech_analysis

Retrieve technical analysis indicators (BB, EMA, RSI, MACD, SMA) for financial instruments using T-Invest API data to support investment decisions.

Instructions

Получить технический анализ (BB, EMA, RSI, MACD, SMA) по тикеру из Т-Инвестиций

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tickerYesТикер инструмента
indicatorYesТип индикатора
fromYesНачало периода (ISO 8601)
toYesКонец периода (ISO 8601)
intervalNoИнтервалday
lengthNoПериод индикатора

Implementation Reference

  • The implementation of the 'get_tech_analysis' tool handler, which includes parameter validation using Zod and logic to call the external API via the TInvest client.
    export function registerGetTechAnalysis(server: McpServer, client: TInvestClient): void {
      server.tool(
        'get_tech_analysis',
        'Получить технический анализ (BB, EMA, RSI, MACD, SMA) по тикеру из Т-Инвестиций',
        {
          ticker: z.string().describe('Тикер инструмента'),
          indicator: z.enum(['BB', 'EMA', 'RSI', 'MACD', 'SMA']).describe('Тип индикатора'),
          from: z.string().describe('Начало периода (ISO 8601)'),
          to: z.string().describe('Конец периода (ISO 8601)'),
          interval: z
            .enum(['1min', '5min', '15min', 'hour', 'day', 'week', 'month'])
            .default('day')
            .describe('Интервал'),
          length: z.number().int().min(1).max(200).default(14).describe('Период индикатора'),
        },
        READ_ONLY,
        async ({ ticker, indicator, from, to, interval, length }) => {
          try {
            const instrument = await resolveTickerToInstrument(client, ticker);
            if (!instrument) {
              return { content: [{ type: 'text' as const, text: `Инструмент "${ticker}" не найден.` }], isError: true };
            }
    
            const response = await client.post<GetTechAnalysisResponse>(
              API_PATHS.MARKET_DATA.GET_TECH_ANALYSIS,
              {
                indicatorType: INDICATOR_MAP[indicator],
                instrumentUid: instrument.uid,
                from,
                to,
                interval: INTERVAL_MAP[interval],
                typeOfPrice: 'TYPE_OF_PRICE_CLOSE',
                length,
              },
            );
    
            if (!response.technicalIndicators || response.technicalIndicators.length === 0) {
              return { content: [{ type: 'text' as const, text: 'Данные технического анализа не найдены.' }] };
            }
    
            const fmt = (q: Parameters<typeof quotationToNumber>[0]) =>
              q ? quotationToNumber(q).toFixed(4) : 'н/д';
    
            const header = `${ticker} — ${indicator}(${length}), ${interval}\n${'─'.repeat(50)}`;
            const lines = response.technicalIndicators.map((ti) => {
              const parts: string[] = [formatDateTime(ti.timestamp)];
              if (ti.middleBand !== undefined) parts.push(`Mid: ${fmt(ti.middleBand)}`);
              if (ti.upperBand !== undefined) parts.push(`Up: ${fmt(ti.upperBand)}`);
              if (ti.lowerBand !== undefined) parts.push(`Low: ${fmt(ti.lowerBand)}`);
              if (ti.signal !== undefined) parts.push(`Signal: ${fmt(ti.signal)}`);
              if (ti.macd !== undefined) parts.push(`MACD: ${fmt(ti.macd)}`);
              if (ti.rsi !== undefined) parts.push(`RSI: ${fmt(ti.rsi)}`);
              return parts.join(' | ');
            });
    
            return { content: [{ type: 'text' as const, text: `${header}\n${lines.join('\n')}` }] };
          } catch (error) {
            return {
              content: [{ type: 'text' as const, text: `Ошибка: ${error instanceof Error ? error.message : String(error)}` }],
              isError: true,
            };
          }
        },
      );
    }

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/nonnname/t-invest-mcp-server'

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