Skip to main content
Glama
nonnname

T-Invest MCP Server

by nonnname

get_portfolio

Read-only

Retrieve a client's investment portfolio from T-Invest, including positions and balances, with optional filtering by specific tickers.

Instructions

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

Input Schema

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

Implementation Reference

  • The function `registerGetPortfolio` registers the 'get_portfolio' MCP tool and contains the main handler logic, including API interaction and response formatting.
    export function registerGetPortfolio(server: McpServer, client: TInvestClient): void {
      server.tool(
        'get_portfolio',
        'Получить портфель клиента в Т-Инвестициях',
        {
          accountId: z.string().describe('Идентификатор счёта (можно получить через get_accounts)'),
          tickers: z.array(z.string()).optional().describe('Фильтр по тикерам'),
        },
        READ_ONLY,
        async ({ accountId, tickers }) => {
          try {
            const response = await client.post<GetPortfolioResponse>(
              API_PATHS.OPERATIONS.GET_PORTFOLIO,
              { accountId, currency: 'RUB' },
            );
    
            if (!response.positions || response.positions.length === 0) {
              return { content: [{ type: 'text' as const, text: 'Портфель пуст.' }] };
            }
    
            const settled = await inBatches(
              response.positions,
              (pos) => resolveInstrumentByFigi(client, pos.figi),
            );
    
            const tickerFilter = tickers?.map((t) => t.toUpperCase());
            const results: string[] = [];
    
            for (let i = 0; i < response.positions.length; i++) {
              const pos = response.positions[i];
              const result = settled[i];
              const ticker = (result.status === 'fulfilled' && result.value) ? result.value : pos.figi;
    
              if (tickerFilter && tickerFilter.length > 0 && !tickerFilter.includes(ticker.toUpperCase())) {
                continue;
              }
              results.push(formatPosition(ticker, pos));
            }
    
            if (results.length === 0) {
              return { content: [{ type: 'text' as const, text: 'Позиции по указанным тикерам не найдены.' }] };
            }
    
            return { content: [{ type: 'text' as const, text: results.join(SEPARATOR) }] };
          } catch (error) {
            return {
              content: [{ type: 'text' as const, text: `Ошибка: ${error instanceof Error ? error.message : String(error)}` }],
              isError: true,
            };
          }
        },
      );
  • src/index.ts:69-69 (registration)
    Registration of the get_portfolio tool in the main server entry point.
    registerGetPortfolio(server, client);
Behavior3/5

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

Annotations declare readOnlyHint=true confirming safe read operation. Description adds domain context (T-Investments) but does not disclose what portfolio data includes (cash, securities, totals) or behavioral details like caching.

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

Conciseness4/5

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

Single sentence with action front-loaded. Appropriate length for the tool's complexity, though extremely minimal with no elaboration on scope or contents of the returned portfolio.

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?

Sufficient for a simple 2-parameter read operation with good annotations. Identifies the brokerage system context. Lacks completeness regarding output structure, but no output schema exists to reference.

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 has 100% description coverage with clear Russian descriptions (accountId references get_accounts, tickers explains filtering). Description adds no parameter details, but baseline 3 is appropriate given complete schema documentation.

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) with resource 'портфель клиента' (client portfolio) and identifies the domain 'Т-Инвестиции' (T-Investments). However, it does not distinguish from sibling tool 'get_positions' which likely returns similar holdings data.

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 'get_positions' or other sibling tools. No mention of prerequisites or workflow (though the accountId schema description references get_accounts).

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