Skip to main content
Glama
nonnname

T-Invest MCP Server

by nonnname

get_orders

Retrieve active exchange orders for a T-Invest account to monitor pending trades and manage investment positions.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
accountIdYesИдентификатор счёта (можно получить через get_accounts)

Implementation Reference

  • The handler implementation for the 'get_orders' MCP tool.
    server.tool(
      'get_orders',
      'Получить активные биржевые заявки по счёту в Т-Инвестициях',
      {
        accountId: z.string().describe('Идентификатор счёта (можно получить через get_accounts)'),
      },
      READ_ONLY,
      async ({ accountId }) => {
        try {
          const response = await client.post<GetOrdersResponse>(
            API_PATHS.ORDERS.GET_ORDERS,
            { accountId },
          );
    
          if (!response.orders || response.orders.length === 0) {
            return { content: [{ type: 'text' as const, text: 'Активных заявок нет.' }] };
          }
    
          const settled = await inBatches(
            response.orders,
            (order) => resolveInstrumentByFigi(client, order.figi),
          );
    
          const lines = response.orders.map((order, i) => {
            const result = settled[i];
            const ticker = (result.status === 'fulfilled' && result.value) ? result.value : order.figi;
            const parts = [
              `Тикер: ${ticker}`,
              `Направление: ${DIRECTION_LABELS[order.direction] ?? order.direction}`,
              `Тип: ${ORDER_TYPE_LABELS[order.orderType] ?? order.orderType}`,
              `Статус: ${ORDER_STATUS_LABELS[order.executionReportStatus] ?? order.executionReportStatus}`,
              `Лотов запрошено / исполнено: ${order.lotsRequested} / ${order.lotsExecuted}`,
            ];
            if (order.initialOrderPrice) parts.push(`Цена заявки: ${formatMoney(order.initialOrderPrice)}`);
            if (order.totalOrderAmount) parts.push(`Сумма: ${formatMoney(order.totalOrderAmount)}`);
            if (order.orderDate) parts.push(`Дата: ${formatDateTime(order.orderDate)}`);
            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,
          };
        }
      },
    );
  • Registration function for the 'get_orders' MCP tool.
    export function registerGetOrders(server: McpServer, client: TInvestClient): void {
      server.tool(
        'get_orders',
        'Получить активные биржевые заявки по счёту в Т-Инвестициях',
        {
          accountId: z.string().describe('Идентификатор счёта (можно получить через get_accounts)'),
        },
        READ_ONLY,
        async ({ accountId }) => {
          try {
            const response = await client.post<GetOrdersResponse>(
              API_PATHS.ORDERS.GET_ORDERS,
              { accountId },
            );
    
            if (!response.orders || response.orders.length === 0) {
              return { content: [{ type: 'text' as const, text: 'Активных заявок нет.' }] };
            }
    
            const settled = await inBatches(
              response.orders,
              (order) => resolveInstrumentByFigi(client, order.figi),
            );
    
            const lines = response.orders.map((order, i) => {
              const result = settled[i];
              const ticker = (result.status === 'fulfilled' && result.value) ? result.value : order.figi;
              const parts = [
                `Тикер: ${ticker}`,
                `Направление: ${DIRECTION_LABELS[order.direction] ?? order.direction}`,
                `Тип: ${ORDER_TYPE_LABELS[order.orderType] ?? order.orderType}`,
                `Статус: ${ORDER_STATUS_LABELS[order.executionReportStatus] ?? order.executionReportStatus}`,
                `Лотов запрошено / исполнено: ${order.lotsRequested} / ${order.lotsExecuted}`,
              ];
              if (order.initialOrderPrice) parts.push(`Цена заявки: ${formatMoney(order.initialOrderPrice)}`);
              if (order.totalOrderAmount) parts.push(`Сумма: ${formatMoney(order.totalOrderAmount)}`);
              if (order.orderDate) parts.push(`Дата: ${formatDateTime(order.orderDate)}`);
              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,
            };
          }
        },
      );
    }

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