Skip to main content
Glama
nonnname

T-Invest MCP Server

by nonnname

get_last_prices

Retrieve current market prices for specified tickers from T-Invest to monitor portfolio values and track financial instruments.

Instructions

Получить текущие рыночные цены по тикерам в Т-Инвестициях

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tickersYesМассив тикеров (до 100)

Implementation Reference

  • The tool registration and handler implementation for "get_last_prices".
    server.tool(
      'get_last_prices',
      'Получить текущие рыночные цены по тикерам в Т-Инвестициях',
      {
        tickers: z.array(z.string()).min(1).max(100).describe('Массив тикеров (до 100)'),
      },
      READ_ONLY,
      async ({ tickers }) => {
        try {
          const instrumentMap = await resolveTickersToInstruments(client, tickers);
    
          const found = tickers
            .map((t) => ({ ticker: t, instrument: instrumentMap.get(t.toUpperCase()) }))
            .filter((r): r is { ticker: string; instrument: NonNullable<typeof r.instrument> } => r.instrument !== undefined);
    
          const notFound = tickers.filter((t) => !instrumentMap.has(t.toUpperCase()));
    
          if (found.length === 0) {
            return { content: [{ type: 'text' as const, text: 'Инструменты не найдены.' }] };
          }
    
          const response = await client.post<GetLastPricesResponse>(
            API_PATHS.MARKET_DATA.GET_LAST_PRICES,
            { figi: found.map((f) => f.instrument.figi) },
          );
    
          const priceMap = new Map(response.lastPrices.map((lp) => [lp.figi, lp]));
    
          const lines = found.map(({ ticker, instrument }) => {
            const lp = priceMap.get(instrument.figi);
            if (!lp) return `${ticker}: цена недоступна`;
            const price = quotationToNumber(lp.price).toFixed(2);
            return `${ticker}: ${price} (обновлено ${formatDateTime(lp.time)})`;
          });
    
          if (notFound.length > 0) {
            lines.push(`\nНе найдены: ${notFound.join(', ')}`);
          }
    
          return { content: [{ type: 'text' as const, text: lines.join('\n') }] };
        } catch (error) {
          return {
            content: [{ type: 'text' as const, text: `Ошибка: ${error instanceof Error ? error.message : String(error)}` }],
            isError: true,
          };
        }
      },
    );
  • The registration function for the "get_last_prices" tool.
    export function registerGetLastPrices(server: McpServer, client: TInvestClient): void {

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