Skip to main content
Glama

fetchBalance

Retrieve current cryptocurrency account balances from configured exchange accounts to monitor holdings and track portfolio value.

Instructions

Fetch account balance for a configured account

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
accountNameYesAccount name defined in the configuration file (e.g., 'bybit_main')

Implementation Reference

  • The handler function that executes the tool logic: retrieves the CCXT exchange instance for the given account and calls fetchBalance() on it, returning the balance as JSON or an error message.
    async ({ accountName }) => { try { // 설정 파일에서 로드된 인스턴스 가져오기 const exchange = ccxtServer.getExchangeInstance(accountName); // getExchangeInstance가 성공하면 인증은 보장됨 const balance = await exchange.fetchBalance(); return { content: [ { type: "text", text: JSON.stringify(balance, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error fetching balance for account '${accountName}': ${ (error as Error).message }`, }, ], isError: true, }; } }
  • Input schema using Zod: requires 'accountName' string parameter describing the configured account name.
    { accountName: z .string() .describe( "Account name defined in the configuration file (e.g., 'bybit_main')" ), },
  • Direct registration of the 'fetchBalance' tool on the MCP server using server.tool(), specifying name, description, input schema, and handler function.
    server.tool( "fetchBalance", "Fetch account balance for a configured account", { accountName: z .string() .describe( "Account name defined in the configuration file (e.g., 'bybit_main')" ), }, async ({ accountName }) => { try { // 설정 파일에서 로드된 인스턴스 가져오기 const exchange = ccxtServer.getExchangeInstance(accountName); // getExchangeInstance가 성공하면 인증은 보장됨 const balance = await exchange.fetchBalance(); return { content: [ { type: "text", text: JSON.stringify(balance, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error fetching balance for account '${accountName}': ${ (error as Error).message }`, }, ], isError: true, }; } } );
  • src/server.ts:371-376 (registration)
    Top-level registration method in CcxtMcpServer that calls registerAccountTools (among others), which registers the fetchBalance tool.
    private registerTools() { registerMarketTools(this.server, this); registerOrderTools(this.server, this); registerAccountTools(this.server, this); registerAnalysisTools(this.server, this); }

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/lazy-dinosaur/ccxt-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server