listAccounts
Retrieve all configured cryptocurrency exchange account names from the CCXT MCP Server to access trading capabilities across multiple platforms.
Instructions
List all configured account names
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/account-tools.ts:21-65 (handler)The main handler function for the 'listAccounts' tool. It fetches account names using ccxtServer.getAccountNames(), handles the case with no accounts by providing configuration instructions, and returns a formatted text list of accounts.async () => { console.error(`[DEBUG] listAccounts tool called`); const accountNames = ccxtServer.getAccountNames(); if (accountNames.length === 0) { console.error(`[WARN] No accounts found in listAccounts tool`); return { content: [ { type: "text", text: `No accounts were loaded from the configuration. Please check your config file at: ${ccxtServer['configPath']} Possible issues: 1. The config file doesn't exist 2. The config file doesn't have the correct format (should have an 'accounts' array) 3. API keys in the config file are invalid 4. Permission issues with accessing the config file Your config should look like: { "accounts": [ { "name": "account_name", "exchangeId": "exchange_id", "apiKey": "your_api_key", "secret": "your_secret_key", "defaultType": "spot" } ] }`, }, ], }; } console.error(`[DEBUG] Returning ${accountNames.length} accounts from listAccounts tool`); return { content: [ { type: "text", text: `Configured accounts (${accountNames.length}):\n${accountNames.join("\n")}`, }, ], }; }
- src/tools/account-tools.ts:17-66 (registration)Direct registration of the 'listAccounts' tool using server.tool(), including name, description, empty input schema, and inline handler function.server.tool( "listAccounts", "List all configured account names", {}, async () => { console.error(`[DEBUG] listAccounts tool called`); const accountNames = ccxtServer.getAccountNames(); if (accountNames.length === 0) { console.error(`[WARN] No accounts found in listAccounts tool`); return { content: [ { type: "text", text: `No accounts were loaded from the configuration. Please check your config file at: ${ccxtServer['configPath']} Possible issues: 1. The config file doesn't exist 2. The config file doesn't have the correct format (should have an 'accounts' array) 3. API keys in the config file are invalid 4. Permission issues with accessing the config file Your config should look like: { "accounts": [ { "name": "account_name", "exchangeId": "exchange_id", "apiKey": "your_api_key", "secret": "your_secret_key", "defaultType": "spot" } ] }`, }, ], }; } console.error(`[DEBUG] Returning ${accountNames.length} accounts from listAccounts tool`); return { content: [ { type: "text", text: `Configured accounts (${accountNames.length}):\n${accountNames.join("\n")}`, }, ], }; } );
- src/server.ts:374-374 (registration)Top-level call to registerAccountTools in CcxtMcpServer's registerTools() method, which registers the listAccounts tool among others.registerAccountTools(this.server, this);
- src/server.ts:315-319 (helper)Helper method in CcxtMcpServer that returns the list of loaded account names from exchangeInstances, directly used by the listAccounts handler.getAccountNames(): string[] { const accountNames = Object.keys(this.exchangeInstances); console.error(`[DEBUG] getAccountNames() called, returning ${accountNames.length} accounts: ${accountNames.join(', ')}`); return accountNames; }