Skip to main content
Glama

fetchBalance

Retrieve account balance from a configured cryptocurrency exchange account using the CCXT MCP Server, ideal for managing assets and monitoring financial positions.

Instructions

Fetch account balance for a configured account

Input Schema

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

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "accountName": { "description": "Account name defined in the configuration file (e.g., 'bybit_main')", "type": "string" } }, "required": [ "accountName" ], "type": "object" }

Implementation Reference

  • The handler function for the 'fetchBalance' tool. It retrieves the CCXT exchange instance for the given account name and fetches the account balance, returning it as JSON-formatted text or an error if failed.
    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, }; } }
  • Zod schema defining the input parameter 'accountName' for the 'fetchBalance' tool.
    { accountName: z .string() .describe( "Account name defined in the configuration file (e.g., 'bybit_main')" ), },
  • The 'server.tool()' call that registers the 'fetchBalance' tool with its description, schema, and handler on the MCP server.
    "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:374-374 (registration)
    Call within CcxtMcpServer.registerTools() that invokes registerAccountTools, thereby registering the 'fetchBalance' tool among others.
    registerAccountTools(this.server, this);
  • src/server.ts:86-86 (registration)
    Invocation of registerTools() in the CcxtMcpServer constructor, which leads to the registration of the 'fetchBalance' tool.
    this.registerTools();

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