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
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/get-accounts.ts:14-41 (handler)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, }; } }, ); - src/tools/get-accounts.ts:8-41 (registration)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, }; } }, );