get_trading_schedules
Retrieve exchange trading schedules for specified periods to plan investment activities and avoid market closures.
Instructions
Получить расписание торгов на бирже из Т-Инвестиций
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| exchange | No | Код биржи (например MOEX, SPB, NYSE) | MOEX |
| from | Yes | Начало периода (ISO 8601) | |
| to | Yes | Конец периода (ISO 8601) |
Implementation Reference
- src/tools/get-trading-schedules.ts:19-56 (handler)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, }; } }, - src/tools/get-trading-schedules.ts:9-57 (registration)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)'), },