Skip to main content
Glama
nonnname

T-Invest MCP Server

by nonnname

get_bond_coupons

Retrieve bond coupon payment schedules from T-Invest for specified tickers and date ranges to track upcoming income and plan investments.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tickersYesМассив тикеров облигаций
fromNoНачало периода (ISO 8601)
toNoКонец периода (ISO 8601)

Implementation Reference

  • The handler implementation and registration for the 'get_bond_coupons' MCP tool.
    export function registerGetBondCoupons(server: McpServer, client: TInvestClient): void {
      server.tool(
        'get_bond_coupons',
        'Получить расписание купонных выплат по облигациям из Т-Инвестиций',
        {
          tickers: z.array(z.string()).min(1).max(50).describe('Массив тикеров облигаций'),
          from: z.string().optional().describe('Начало периода (ISO 8601)'),
          to: z.string().optional().describe('Конец периода (ISO 8601)'),
        },
        READ_ONLY,
        async ({ tickers, from, to }) => {
          try {
            const instrumentMap = await resolveTickersToInstruments(client, tickers);
            const notFound = tickers.filter((t) => !instrumentMap.has(t.toUpperCase()));
            const results: string[] = [];
    
            await Promise.allSettled(
              tickers
                .filter((t) => instrumentMap.has(t.toUpperCase()))
                .map(async (ticker) => {
                  const instrument = instrumentMap.get(ticker.toUpperCase())!;
                  const body: Record<string, unknown> = { figi: instrument.figi };
                  if (from) body.from = from;
                  if (to) body.to = to;
    
                  try {
                    const resp = await client.post<GetBondCouponsResponse>(
                      API_PATHS.INSTRUMENTS.GET_BOND_COUPONS,
                      body,
                    );
    
                    if (!resp.events || resp.events.length === 0) {
                      results.push(`${ticker}: купоны не найдены`);
                      return;
                    }
    
                    const couponLines = resp.events.map((c) => {
                      const parts = [
                        `  Дата выплаты: ${formatDate(c.couponDate)}`,
                        `  Тип: ${COUPON_TYPE_LABELS[c.couponType] ?? c.couponType}`,
                      ];
                      if (c.payOneBond) parts.push(`  Выплата на бумагу: ${formatMoney(c.payOneBond)}`);
                      if (c.couponPeriod) parts.push(`  Период (дней): ${c.couponPeriod}`);
                      return parts.join('\n');
                    });
    
                    results.push(`${ticker}:\n${couponLines.join('\n\n')}`);
                  } catch {
                    results.push(`${ticker}: ошибка запроса`);
                  }
                }),
            );
    
            if (notFound.length > 0) results.push(`\nНе найдены: ${notFound.join(', ')}`);
    
            return {
              content: [{ type: 'text' as const, text: results.length > 0 ? results.join(SEPARATOR) : 'Данные не найдены.' }],
            };
          } 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