Skip to main content
Glama
nonnname

T-Invest MCP Server

by nonnname

get_accounts

Retrieve a list of user investment accounts from T-Invest to view portfolio holdings and manage trading activities.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the 'get_accounts' tool. It fetches accounts using the TInvestClient and formats the response.
      async () => {
        try {
          const response = await client.post<GetAccountsResponse>(
            API_PATHS.USERS.GET_ACCOUNTS,
            { status: 2 },
          );
    
          if (!response.accounts || response.accounts.length === 0) {
            return { content: [{ type: 'text' as const, text: 'Счета не найдены.' }] };
          }
    
          const lines = response.accounts.map((account) => {
            return [
              `ID: ${account.id}`,
              `Название: ${account.name}`,
              `Уровень доступа: ${account.accessLevel}`,
            ].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,
          };
        }
      },
    );
  • The registration function that defines the 'get_accounts' tool within the MCP server.
    export function registerGetAccounts(server: McpServer, client: TInvestClient): void {
      server.tool(
        'get_accounts',
        'Получить список счетов пользователя в Т-Инвестициях',
        {},
        READ_ONLY,
        async () => {
          try {
            const response = await client.post<GetAccountsResponse>(
              API_PATHS.USERS.GET_ACCOUNTS,
              { status: 2 },
            );
    
            if (!response.accounts || response.accounts.length === 0) {
              return { content: [{ type: 'text' as const, text: 'Счета не найдены.' }] };
            }
    
            const lines = response.accounts.map((account) => {
              return [
                `ID: ${account.id}`,
                `Название: ${account.name}`,
                `Уровень доступа: ${account.accessLevel}`,
              ].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