Skip to main content
Glama
nonnname

T-Invest MCP Server

by nonnname

get_positions

Read-only

Retrieve account positions including cash, securities, and futures from T-Invest to monitor portfolio holdings and investment status.

Instructions

Получить позиции счёта (деньги, ценные бумаги, фьючерсы) из Т-Инвестиций

Input Schema

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

Implementation Reference

  • The handler and registration function for the 'get_positions' tool. It fetches data from the T-Invest API and formats the response for MCP.
    export function registerGetPositions(server: McpServer, client: TInvestClient): void {
      server.tool(
        'get_positions',
        'Получить позиции счёта (деньги, ценные бумаги, фьючерсы) из Т-Инвестиций',
        {
          accountId: z.string().describe('Идентификатор счёта (можно получить через get_accounts)'),
        },
        READ_ONLY,
        async ({ accountId }) => {
          try {
            const response = await client.post<GetPositionsResponse>(
              API_PATHS.OPERATIONS.GET_POSITIONS,
              { accountId },
            );
    
            const lines: string[] = [];
    
            if (response.money && response.money.length > 0) {
              lines.push('Денежные позиции:');
              for (const m of response.money) lines.push(`  ${formatMoney(m)}`);
            }
    
            if (response.blocked && response.blocked.length > 0) {
              lines.push('\nЗаблокировано:');
              for (const m of response.blocked) lines.push(`  ${formatMoney(m)}`);
            }
    
            const allSecurities = [
              ...(response.securities ?? []).map((s) => ({ ...s, kind: 'Бумага' })),
              ...(response.futures ?? []).map((s) => ({ ...s, kind: 'Фьючерс' })),
              ...(response.options ?? []).map((s) => ({ ...s, kind: 'Опцион' })),
            ];
    
            if (allSecurities.length > 0) {
              const settled = await inBatches(
                allSecurities,
                (s) => resolveInstrumentByFigi(client, s.figi),
              );
    
              lines.push('\nЦенные бумаги:');
              for (let i = 0; i < allSecurities.length; i++) {
                const s = allSecurities[i];
                const result = settled[i];
                const ticker = (result.status === 'fulfilled' && result.value) ? result.value : s.figi;
                const blocked = parseInt(s.blocked) > 0 ? `, заблокировано: ${s.blocked}` : '';
                lines.push(`  ${ticker} (${s.kind}): ${s.balance} лот(ов)${blocked}`);
              }
            }
    
            if (response.limitsLoadingInProgress) {
              lines.push('\n⚠ Лимиты ещё загружаются...');
            }
    
            return {
              content: [{ type: 'text' as const, text: lines.length > 0 ? lines.join('\n') : 'Позиций нет.' }],
            };
          } 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. Description adds value by specifying the scope of returned data (three specific asset classes) and source system (T-Investments), but omits caching behavior, rate limits, or error conditions.

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?

Single dense sentence efficiently communicates action, resource, content types, and source system. Parenthetical enumeration prevents ambiguity without verbosity.

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

Completeness3/5

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

Adequate for a simple read-only tool with one parameter. Description clarifies return contents but lacks output schema details and sibling differentiation that would be necessary for complex filtering or mutation tools.

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?

Schema description coverage is 100% with accountId fully documented including cross-reference to get_accounts. Main description adds no parameter details, but baseline 3 is appropriate given schema completeness.

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?

Uses specific verb (Получить/Get) and resource (positions), with clear parenthetical enumeration of asset types (money, securities, futures). Falls short of distinguishing from sibling 'get_portfolio' which likely overlaps in functionality.

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?

No explicit guidance on when to use this versus alternatives like 'get_portfolio'. While the parameter schema references get_accounts as a prerequisite, the main description lacks when-to-use context or exclusion criteria.

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