Skip to main content
Glama
nonnname

T-Invest MCP Server

by nonnname

get_operations

Retrieve historical investment account operations from T-Invest within specified date ranges to track transactions and analyze portfolio activity.

Instructions

Получить историю операций по счёту в Т-Инвестициях

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
accountIdYesИдентификатор счёта (можно получить через get_accounts)
fromNoНачало периода (ISO 8601, например 2024-01-01T00:00:00Z)
toNoКонец периода (ISO 8601)
limitNoМаксимальное количество операций

Implementation Reference

  • The `registerGetOperations` function registers the `get_operations` MCP tool and contains the core logic for fetching and formatting operations from the T-Invest API.
    export function registerGetOperations(server: McpServer, client: TInvestClient): void {
      server.tool(
        'get_operations',
        'Получить историю операций по счёту в Т-Инвестициях',
        {
          accountId: z.string().describe('Идентификатор счёта (можно получить через get_accounts)'),
          from: z.string().optional().describe('Начало периода (ISO 8601, например 2024-01-01T00:00:00Z)'),
          to: z.string().optional().describe('Конец периода (ISO 8601)'),
          limit: z.number().int().min(1).max(1000).default(50).describe('Максимальное количество операций'),
        },
        READ_ONLY,
        async ({ accountId, from, to, limit }) => {
          try {
            const body: Record<string, unknown> = { accountId, limit };
            if (from) body.from = from;
            if (to) body.to = to;
    
            const response = await client.post<GetOperationsByCursorResponse>(
              API_PATHS.OPERATIONS.GET_OPERATIONS_BY_CURSOR,
              body,
            );
    
            if (!response.items || response.items.length === 0) {
              return { content: [{ type: 'text' as const, text: 'Операции не найдены.' }] };
            }
    
            const lines = response.items.map((op) => {
              const parts = [
                `Дата: ${formatDateTime(op.date)}`,
                `Тип: ${OPERATION_TYPE_LABELS[op.type] ?? op.type}`,
              ];
              if (op.name) parts.push(`Инструмент: ${op.name}`);
              if (op.payment) parts.push(`Сумма: ${formatMoney(op.payment)}`);
              if (op.price && op.quantity) {
                parts.push(`Цена: ${formatMoney(op.price)}, Количество: ${op.quantityDone ?? op.quantity}`);
              }
              if (op.commissionSum) parts.push(`Комиссия: ${formatMoney(op.commissionSum)}`);
              return parts.join('\n');
            });
    
            let text = lines.join(SEPARATOR);
            if (response.hasnext) {
              text += '\n\n(Есть ещё операции. Уточните период или уменьшите limit.)';
            }
    
            return { content: [{ type: 'text' as const, text }] };
          } 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