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);
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states 'fetch' which implies a read operation, but doesn't specify whether this requires authentication, rate limits, error conditions, or what the return format looks like. For a financial tool with zero annotation coverage, this leaves significant behavioral gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose without unnecessary words. It's appropriately sized and front-loaded, making it easy for an agent to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of financial data retrieval and the absence of both annotations and output schema, the description is insufficient. It doesn't explain what balance information is returned (e.g., total balance, available balance, currency details) or address potential error scenarios, leaving the agent with incomplete context for proper tool invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with the single parameter 'accountName' fully documented in the schema. The description adds no additional parameter information beyond what the schema provides, so it meets the baseline score of 3 where the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'fetch' and resource 'account balance' with the context 'for a configured account', making the purpose understandable. However, it doesn't explicitly differentiate from sibling tools like 'listAccounts' or 'fetchDeposits', which prevents a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides minimal guidance with 'for a configured account', implying usage when balance information is needed for a specific account. However, it lacks explicit when-to-use scenarios, prerequisites, or alternatives compared to sibling tools like 'listAccounts' or 'fetchDeposits', leaving the agent with insufficient context for optimal selection.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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