Skip to main content
Glama

account-balance

Retrieve your cryptocurrency account balance from supported exchanges by providing API keys, secrets, and exchange details. Supports spot, future, and other market types.

Instructions

Get your account balance from a crypto exchange

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
apiKeyYesAPI key for authentication
exchangeYesExchange ID (e.g., binance, coinbase)
marketTypeNoMarket type (default: spot)
passphraseNoPassphrase for authentication (required for some exchanges like KuCoin)
secretYesAPI secret for authentication

Implementation Reference

  • The core handler function that executes the 'account-balance' tool logic: authenticates with the exchange using provided credentials, fetches the balance via ccxt-like API, formats the response, and handles errors.
    }, async ({ exchange, apiKey, secret, passphrase, marketType }) => {
      try {
        return await rateLimiter.execute(exchange, async () => {
          // Get exchange with market type
          const ex = getExchangeWithCredentials(exchange, apiKey, secret, marketType, passphrase);
          
          // Fetch balance
          log(LogLevel.INFO, `Fetching account balance for ${exchange}`);
          const balance = await ex.fetchBalance();
          
          // Format the balance for better readability
          const formattedBalance = {
            total: balance.total,
            free: balance.free,
            used: balance.used,
            timestamp: new Date(balance.timestamp || Date.now()).toISOString()
          };
          
          return {
            content: [{
              type: "text",
              text: JSON.stringify(formattedBalance, null, 2)
            }]
          };
        });
      } catch (error) {
        log(LogLevel.ERROR, `Error fetching account balance: ${error instanceof Error ? error.message : String(error)}`);
        return {
          content: [{
            type: "text",
            text: `Error fetching account balance: ${error instanceof Error ? error.message : String(error)}`
          }],
          isError: true
        };
      }
    });
  • Zod input schema for validating parameters: exchange ID, API credentials, optional passphrase and market type.
    exchange: z.string().describe("Exchange ID (e.g., binance, coinbase)"),
    apiKey: z.string().describe("API key for authentication"),
    secret: z.string().describe("API secret for authentication"),
    passphrase: z.string().optional().describe("Passphrase for authentication (required for some exchanges like KuCoin)"),
    marketType: z.enum(["spot", "future", "swap", "option", "margin"]).optional().describe("Market type (default: spot)")
  • The direct registration of the 'account-balance' tool using McpServer.tool() method within registerPrivateTools, specifying name, description, input schema, and handler.
    server.tool("account-balance", "Get your account balance from a crypto exchange", {
      exchange: z.string().describe("Exchange ID (e.g., binance, coinbase)"),
      apiKey: z.string().describe("API key for authentication"),
      secret: z.string().describe("API secret for authentication"),
      passphrase: z.string().optional().describe("Passphrase for authentication (required for some exchanges like KuCoin)"),
      marketType: z.enum(["spot", "future", "swap", "option", "margin"]).optional().describe("Market type (default: spot)")
    }, async ({ exchange, apiKey, secret, passphrase, marketType }) => {
      try {
        return await rateLimiter.execute(exchange, async () => {
          // Get exchange with market type
          const ex = getExchangeWithCredentials(exchange, apiKey, secret, marketType, passphrase);
          
          // Fetch balance
          log(LogLevel.INFO, `Fetching account balance for ${exchange}`);
          const balance = await ex.fetchBalance();
          
          // Format the balance for better readability
          const formattedBalance = {
            total: balance.total,
            free: balance.free,
            used: balance.used,
            timestamp: new Date(balance.timestamp || Date.now()).toISOString()
          };
          
          return {
            content: [{
              type: "text",
              text: JSON.stringify(formattedBalance, null, 2)
            }]
          };
        });
      } catch (error) {
        log(LogLevel.ERROR, `Error fetching account balance: ${error instanceof Error ? error.message : String(error)}`);
        return {
          content: [{
            type: "text",
            text: `Error fetching account balance: ${error instanceof Error ? error.message : String(error)}`
          }],
          isError: true
        };
      }
    });
  • Invocation of registerPrivateTools in the tools index, which registers the private tools including 'account-balance'.
    registerPrivateTools(server);
  • src/index.ts:194-194 (registration)
    Top-level call to registerAllTools in the main server file, which chains to private tools registration including 'account-balance'.
    registerAllTools(server);
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. While 'Get' implies a read operation, it doesn't disclose important behavioral aspects: authentication requirements (though hinted in parameters), rate limits, whether this is a real-time or cached balance, error conditions, or what format the balance information returns. For a financial tool with authentication parameters, this is a significant gap.

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 gets straight to the point with zero wasted words. It's appropriately sized for a straightforward data retrieval tool and front-loads the essential information without unnecessary elaboration.

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?

For a financial tool with authentication parameters and no output schema, the description is insufficiently complete. It doesn't explain what the balance information includes (total balance, available balance, by currency), doesn't mention error handling for invalid credentials, and provides no context about how this tool fits within the broader crypto exchange operations available in the sibling toolset.

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%, so the schema already documents all 5 parameters thoroughly. The description adds no additional parameter semantics beyond what's in the schema - it doesn't explain relationships between parameters (like which exchanges require passphrase) or provide examples beyond the basic purpose statement. This meets the baseline for high schema coverage.

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 action ('Get') and resource ('account balance from a crypto exchange'), making the purpose immediately understandable. However, it doesn't differentiate this tool from potential sibling tools that might also retrieve balance information or explain what distinguishes 'account balance' from other financial data tools in the server.

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 no guidance on when to use this tool versus alternatives. With multiple sibling tools like 'get-exchange-info', 'get-funding-rates', and various order placement tools, there's no indication of when account balance retrieval is appropriate versus other financial data tools or how it relates to the broader toolset.

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

Related 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/doggybee/mcp-server-ccxt'

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