Skip to main content
Glama
nonnname

T-Invest MCP Server

by nonnname

get_stop_orders

Read-only

Retrieve active stop orders for a T-Invest account to monitor pending trades and manage risk exposure.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
accountIdYesИдентификатор счёта

Implementation Reference

  • The handler for 'get_stop_orders' tool, which fetches active stop orders from the T-Invest API and formats them for the user.
    server.tool(
      'get_stop_orders',
      'Получить активные стоп-заявки по счёту из Т-Инвестиций',
      {
        accountId: z.string().describe('Идентификатор счёта'),
      },
      READ_ONLY,
      async ({ accountId }) => {
        try {
          const response = await client.post<GetStopOrdersResponse>(
            API_PATHS.STOP_ORDERS.GET_STOP_ORDERS,
            { accountId },
          );
    
          if (!response.stopOrders || response.stopOrders.length === 0) {
            return { content: [{ type: 'text' as const, text: 'Активных стоп-заявок нет.' }] };
          }
    
          const settled = await inBatches(
            response.stopOrders,
            (order) => resolveInstrumentByFigi(client, order.figi),
          );
    
          const lines = response.stopOrders.map((order, i) => {
            const result = settled[i];
            const ticker = (result.status === 'fulfilled' && result.value) ? result.value : order.figi;
            const parts = [
              `Тикер: ${ticker}`,
              `ID: ${order.stopOrderId}`,
              `Тип: ${STOP_ORDER_TYPE_LABELS[order.orderType] ?? order.orderType}`,
              `Направление: ${DIRECTION_LABELS[order.direction] ?? order.direction}`,
              `Лотов: ${order.lotsRequested}`,
            ];
            if (order.stopPrice) parts.push(`Стоп-цена: ${formatMoney(order.stopPrice)}`);
            if (order.price) parts.push(`Лимит-цена: ${formatMoney(order.price)}`);
            if (order.expirationTime) parts.push(`Истекает: ${formatDateTime(order.expirationTime)}`);
            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,
          };
        }
      },
    );
  • Function that registers the 'get_stop_orders' tool with the MCP server.
    export function registerGetStopOrders(server: McpServer, client: TInvestClient): void {
      server.tool(
        'get_stop_orders',
        'Получить активные стоп-заявки по счёту из Т-Инвестиций',
        {
          accountId: z.string().describe('Идентификатор счёта'),
        },
        READ_ONLY,
        async ({ accountId }) => {
          try {
            const response = await client.post<GetStopOrdersResponse>(
              API_PATHS.STOP_ORDERS.GET_STOP_ORDERS,
              { accountId },
            );
    
            if (!response.stopOrders || response.stopOrders.length === 0) {
              return { content: [{ type: 'text' as const, text: 'Активных стоп-заявок нет.' }] };
            }
    
            const settled = await inBatches(
              response.stopOrders,
              (order) => resolveInstrumentByFigi(client, order.figi),
            );
    
            const lines = response.stopOrders.map((order, i) => {
              const result = settled[i];
              const ticker = (result.status === 'fulfilled' && result.value) ? result.value : order.figi;
              const parts = [
                `Тикер: ${ticker}`,
                `ID: ${order.stopOrderId}`,
                `Тип: ${STOP_ORDER_TYPE_LABELS[order.orderType] ?? order.orderType}`,
                `Направление: ${DIRECTION_LABELS[order.direction] ?? order.direction}`,
                `Лотов: ${order.lotsRequested}`,
              ];
              if (order.stopPrice) parts.push(`Стоп-цена: ${formatMoney(order.stopPrice)}`);
              if (order.price) parts.push(`Лимит-цена: ${formatMoney(order.price)}`);
              if (order.expirationTime) parts.push(`Истекает: ${formatDateTime(order.expirationTime)}`);
              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,
            };
          }
        },
      );
    }
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations declare readOnlyHint=true, and the description confirms this is a read operation ('Получить'). It adds valuable scope context by specifying only 'active' stop orders are returned, which implies executed or cancelled orders are excluded. However, it lacks details on rate limits, pagination, error cases (e.g., invalid accountId), or the specific types of stop orders included.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, front-loaded sentence with zero redundancy. It efficiently conveys the essential function without extraneous words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a read-only tool with a single required parameter and no output schema, the description adequately covers the primary function. The mention of 'active' provides necessary filtering context. It is complete enough given the tool's simplicity, though additional behavioral details would enhance robustness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 100% schema description coverage and a single parameter, the baseline is appropriate. The description does not add semantic details beyond the schema (e.g., account ID format, where to obtain it), but the schema is self-sufficient for this simple case.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action (get/obtain), the resource (active stop orders), the target (by account), and the system (T-Investments). It implicitly distinguishes from the sibling 'get_orders' by specifying 'stop orders', though it could be improved by explicitly contrasting with regular orders or clarifying what constitutes a stop order in this context.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

There is no guidance on when to use this tool versus alternatives (e.g., 'get_orders' for regular orders, 'cancel_stop_order' to manage them). It does not mention prerequisites, conditions for use, or when not to use it.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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