Skip to main content
Glama
nonnname

T-Invest MCP Server

by nonnname

get_consensus_forecasts

Read-only

Retrieve analyst consensus forecasts for stock tickers from T-Invest to inform investment decisions with aggregated market predictions.

Instructions

Получить консенсус-прогнозы аналитиков по тикерам из Т-Инвестиций

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tickersYesМассив тикеров

Implementation Reference

  • The registration function contains the handler logic for the 'get_consensus_forecasts' tool, which fetches analyst consensus forecasts from the T-Invest API and formats the response.
    export function registerGetConsensusForecasts(server: McpServer, client: TInvestClient): void {
      server.tool(
        'get_consensus_forecasts',
        'Получить консенсус-прогнозы аналитиков по тикерам из Т-Инвестиций',
        {
          tickers: z.array(z.string()).min(1).max(50).describe('Массив тикеров'),
        },
        READ_ONLY,
        async ({ tickers }) => {
          try {
            const instrumentMap = await resolveTickersToInstruments(client, tickers);
    
            if (instrumentMap.size === 0) {
              return { content: [{ type: 'text' as const, text: 'Инструменты не найдены.' }] };
            }
    
            const uidToTicker = new Map(
              Array.from(instrumentMap.entries()).map(([ticker, inst]) => [inst.uid, ticker]),
            );
    
            const response = await client.post<GetConsensusForecastsResponse>(
              API_PATHS.INSTRUMENTS.GET_CONSENSUS_FORECASTS,
              {
                instrumentIds: Array.from(uidToTicker.keys()),
                paging: { pageNumber: 0, pageSize: 100 },
              },
            );
    
            if (!response.items || response.items.length === 0) {
              return { content: [{ type: 'text' as const, text: 'Прогнозы не найдены.' }] };
            }
    
            const lines = response.items.map((f) => {
              const ticker = uidToTicker.get(f.assetUid) ?? f.assetUid;
              const parts = [`${ticker}:`];
              if (f.consensus) parts.push(`  Консенсус: ${CONSENSUS_LABELS[f.consensus] ?? f.consensus}`);
              if (f.bestTargetPrice) parts.push(`  Целевая цена: ${quotationToNumber(f.bestTargetPrice).toFixed(2)} ${f.currency ?? ''}`);
              if (f.bestTargetLow) parts.push(`  Диапазон: ${quotationToNumber(f.bestTargetLow).toFixed(2)} – ${quotationToNumber(f.bestTargetHigh).toFixed(2)}`);
              const total = (f.totalBuyRecommendations ?? 0) + (f.totalHoldRecommendations ?? 0) + (f.totalSellRecommendations ?? 0);
              if (total > 0) {
                parts.push(`  Рекомендации: покупать ${f.totalBuyRecommendations ?? 0}, держать ${f.totalHoldRecommendations ?? 0}, продавать ${f.totalSellRecommendations ?? 0}`);
              }
              if (f.prognozDateEnd) parts.push(`  Горизонт: до ${formatDate(f.prognozDateEnd)}`);
              return parts.join('\n');
            });
    
            return { content: [{ type: 'text' as const, text: lines.join(SEPARATOR) }] };
          } catch (error) {
            return {
              content: [{ type: 'text' as const, text: `Ошибка: ${error instanceof Error ? error.message : String(error)}` }],
              isError: true,
            };
          }
        },
      );
    }
  • Tool registration using the MCP server instance.
    export function registerGetConsensusForecasts(server: McpServer, client: TInvestClient): void {
      server.tool(
        'get_consensus_forecasts',
        'Получить консенсус-прогнозы аналитиков по тикерам из Т-Инвестиций',
        {
          tickers: z.array(z.string()).min(1).max(50).describe('Массив тикеров'),
        },
        READ_ONLY,
        async ({ tickers }) => {
          try {
            const instrumentMap = await resolveTickersToInstruments(client, tickers);
    
            if (instrumentMap.size === 0) {
              return { content: [{ type: 'text' as const, text: 'Инструменты не найдены.' }] };
            }
    
            const uidToTicker = new Map(
              Array.from(instrumentMap.entries()).map(([ticker, inst]) => [inst.uid, ticker]),
            );
    
            const response = await client.post<GetConsensusForecastsResponse>(
              API_PATHS.INSTRUMENTS.GET_CONSENSUS_FORECASTS,
              {
                instrumentIds: Array.from(uidToTicker.keys()),
                paging: { pageNumber: 0, pageSize: 100 },
              },
            );
    
            if (!response.items || response.items.length === 0) {
              return { content: [{ type: 'text' as const, text: 'Прогнозы не найдены.' }] };
            }
    
            const lines = response.items.map((f) => {
              const ticker = uidToTicker.get(f.assetUid) ?? f.assetUid;
              const parts = [`${ticker}:`];
              if (f.consensus) parts.push(`  Консенсус: ${CONSENSUS_LABELS[f.consensus] ?? f.consensus}`);
              if (f.bestTargetPrice) parts.push(`  Целевая цена: ${quotationToNumber(f.bestTargetPrice).toFixed(2)} ${f.currency ?? ''}`);
              if (f.bestTargetLow) parts.push(`  Диапазон: ${quotationToNumber(f.bestTargetLow).toFixed(2)} – ${quotationToNumber(f.bestTargetHigh).toFixed(2)}`);
              const total = (f.totalBuyRecommendations ?? 0) + (f.totalHoldRecommendations ?? 0) + (f.totalSellRecommendations ?? 0);
              if (total > 0) {
                parts.push(`  Рекомендации: покупать ${f.totalBuyRecommendations ?? 0}, держать ${f.totalHoldRecommendations ?? 0}, продавать ${f.totalSellRecommendations ?? 0}`);
              }
              if (f.prognozDateEnd) parts.push(`  Горизонт: до ${formatDate(f.prognozDateEnd)}`);
              return parts.join('\n');
            });
    
            return { content: [{ type: 'text' as const, text: lines.join(SEPARATOR) }] };
          } catch (error) {
            return {
              content: [{ type: 'text' as const, text: `Ошибка: ${error instanceof Error ? error.message : String(error)}` }],
              isError: true,
            };
          }
        },
      );
    }
  • Type definition for the GetConsensusForecastsResponse object.
    export interface GetConsensusForecastsResponse {
Behavior3/5

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

Annotations declare readOnlyHint=true, which the description doesn't contradict. Description adds valuable data provenance (Т-Инвестиции source) not in annotations, but omits behavioral details like rate limits, handling of invalid tickers, or forecast types included.

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, front-loaded with verb. Zero redundancy or boilerplate. Highly efficient for the information conveyed.

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?

Adequate for a simple read-only tool with single parameter and clear domain. Source attribution (T-Investments) provides necessary context. Could be improved by mentioning return data structure or error behavior, but sufficient given schema completeness and annotations.

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?

Schema coverage is 100% (tickers fully documented as 'Массив тикеров'). Description mentions 'по тикерам' which aligns with schema but doesn't add semantic depth beyond schema (e.g., exchange suffix format, ticker validation). Baseline 3 appropriate for complete schema coverage.

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?

Specifies exact action (получить/get), resource (consensus forecasts), data source (Т-Инвестиции/T-Investments), and scope (by tickers). Clearly distinguishes from siblings like get_last_prices or get_asset_fundamentals by specifying 'analyst consensus' data type.

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

Usage Guidelines3/5

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

Implies usage context through 'analyst consensus forecasts' (suggests use for aggregated opinion data vs raw market data), but lacks explicit when-to-use guidance versus sibling data tools like get_asset_fundamentals or get_signals, and no prerequisites mentioned.

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

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