Skip to main content
Glama
nonnname

T-Invest MCP Server

by nonnname

get_trading_schedules

Retrieve exchange trading schedules for specified periods to plan investment activities and avoid market closures.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
exchangeNoКод биржи (например MOEX, SPB, NYSE)MOEX
fromYesНачало периода (ISO 8601)
toYesКонец периода (ISO 8601)

Implementation Reference

  • The handler function inside 'registerGetTradingSchedules' that performs the API call and formats the trading schedule response.
    async ({ exchange, from, to }) => {
      try {
        const response = await client.post<GetTradingSchedulesResponse>(
          API_PATHS.INSTRUMENTS.GET_TRADING_SCHEDULES,
          { exchange, from, to },
        );
    
        if (!response.exchanges || response.exchanges.length === 0) {
          return { content: [{ type: 'text' as const, text: 'Расписание не найдено.' }] };
        }
    
        const lines: string[] = [];
        for (const ex of response.exchanges) {
          lines.push(`Биржа: ${ex.exchange}`);
          for (const day of ex.tradingDays ?? []) {
            const date = formatDate(day.date);
            if (!day.isTradingDay) {
              lines.push(`  ${date}: выходной`);
              continue;
            }
            const start = day.startTime
              ? new Date(day.startTime).toLocaleTimeString('ru-RU', { timeZone: 'Europe/Moscow', hour: '2-digit', minute: '2-digit' })
              : '?';
            const end = day.endTime
              ? new Date(day.endTime).toLocaleTimeString('ru-RU', { timeZone: 'Europe/Moscow', hour: '2-digit', minute: '2-digit' })
              : '?';
            lines.push(`  ${date}: ${start} – ${end}`);
          }
        }
    
        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 'registerGetTradingSchedules' function which registers the 'get_trading_schedules' tool with the MCP server.
    export function registerGetTradingSchedules(server: McpServer, client: TInvestClient): void {
      server.tool(
        'get_trading_schedules',
        'Получить расписание торгов на бирже из Т-Инвестиций',
        {
          exchange: z.string().default('MOEX').describe('Код биржи (например MOEX, SPB, NYSE)'),
          from: z.string().describe('Начало периода (ISO 8601)'),
          to: z.string().describe('Конец периода (ISO 8601)'),
        },
        READ_ONLY,
        async ({ exchange, from, to }) => {
          try {
            const response = await client.post<GetTradingSchedulesResponse>(
              API_PATHS.INSTRUMENTS.GET_TRADING_SCHEDULES,
              { exchange, from, to },
            );
    
            if (!response.exchanges || response.exchanges.length === 0) {
              return { content: [{ type: 'text' as const, text: 'Расписание не найдено.' }] };
            }
    
            const lines: string[] = [];
            for (const ex of response.exchanges) {
              lines.push(`Биржа: ${ex.exchange}`);
              for (const day of ex.tradingDays ?? []) {
                const date = formatDate(day.date);
                if (!day.isTradingDay) {
                  lines.push(`  ${date}: выходной`);
                  continue;
                }
                const start = day.startTime
                  ? new Date(day.startTime).toLocaleTimeString('ru-RU', { timeZone: 'Europe/Moscow', hour: '2-digit', minute: '2-digit' })
                  : '?';
                const end = day.endTime
                  ? new Date(day.endTime).toLocaleTimeString('ru-RU', { timeZone: 'Europe/Moscow', hour: '2-digit', minute: '2-digit' })
                  : '?';
                lines.push(`  ${date}: ${start} – ${end}`);
              }
            }
    
            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 input schema definition for the 'get_trading_schedules' tool using Zod.
    {
      exchange: z.string().default('MOEX').describe('Код биржи (например MOEX, SPB, NYSE)'),
      from: z.string().describe('Начало периода (ISO 8601)'),
      to: z.string().describe('Конец периода (ISO 8601)'),
    },

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