Skip to main content
Glama

sui-balance

Check the balance of addresses across Sui blockchain networks, including mainnet, testnet, devnet, and localnet. Input addresses to retrieve current token balances.

Instructions

Get balance of an address from sui networks

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressesYes
networkNomainnet

Implementation Reference

  • The handler function (cb method) that implements the core logic: creates SuiClient, fetches balances in mist for each address using getBalanceInMist, converts to SUI, formats response as JSON.
    async cb(args: BalanceParams, suiClient: SuiClient | null = null) {
      const addresses = args.addresses.map(address => address.trim());
      const client = suiClient ?? new SuiClient({ url: getFullnodeUrl(args.network) });
    
      const promises = [];
      for (const address of addresses) {
        promises.push(getBalanceInMist(address, client));
      }
    
      const getBalanceResults = await Promise.all(promises);
      const balances = getBalanceResults.map((balanceInMist, index) => {
        if (balanceInMist === null) return null;
    
        const balanceInSui = convertMistToSui(balanceInMist);
        return {
          address: addresses[index],
          mist: balanceInMist.toString(),
          sui: balanceInSui.toString(),
        };
      });
    
      return this.createTextResponse(JSON.stringify(balances));
    }
  • Zod schema defining input parameters: network (SUI networks enum, default mainnet) and array of Sui addresses.
    const balanceParamsSchema = z.object({
      network: z.enum(SUI_NETWORKS).default('mainnet'),
      addresses: z.array(z.string()),
    });
  • Imports the SuiBalanceTool instance from get-balance.js and includes it in the array of all exported tools, which is later registered in the MCP server.
    import suiBalanceTool from './sui/get-balance.js';
    import suiTransferTool from './sui/transfer.js';
    import randomSuiAccountTool from './account/gen-random.js';
    import genMnemonicTool from './account/gen-mnemonic.js';
    import genSuiAccountsByMnemonicTool from './account/gen-by-mnemonic.js';
    import getAccountInfoByPriKeyTool from './account/get-info-by-pri-key.js';
    
    export default [
      faucetTool,
      suiBalanceTool,
      suiTransferTool,
      randomSuiAccountTool,
      genMnemonicTool,
      genSuiAccountsByMnemonicTool,
      getAccountInfoByPriKeyTool,
    ];
  • Helper function to fetch SUI coin balance in mist for a given address using SuiClient.getBalance.
    export const getBalanceInMist = async (
      address: string,
      client: SuiClient
    ): Promise<bigint | null> => {
      try {
        const balance = await client.getBalance({
          owner: address,
          coinType: '0x2::sui::SUI',
        });
        return BigInt(balance.totalBalance);
      } catch (error) {
        console.error('Error getting balance:', error);
        return null;
      }
    };
  • Helper function to convert balance from mist (big int) to SUI (number).
    export const convertMistToSui = (mist: bigint): number => {
      return Number(mist) / Number(MIST_PER_SUI);
    };
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states this is a read operation ('Get'), which implies it's non-destructive, but doesn't cover other important aspects like network latency, rate limits, authentication requirements, error conditions, or what happens with invalid addresses. For a tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

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 with zero wasted words. It's front-loaded with the core purpose ('Get balance'), making it immediately clear. Every word earns its place by contributing to understanding the tool's function.

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 tool's moderate complexity (2 parameters, no annotations, no output schema), the description is incomplete. It lacks details on return values (e.g., balance format, units), error handling, and behavioral constraints. For a financial tool querying blockchain networks, this omission is significant, as agents need to understand what to expect from the output.

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 0%, so the schema provides no parameter descriptions. The description mentions 'address' and 'sui networks', which loosely map to the 'addresses' and 'network' parameters, but doesn't explain their semantics (e.g., that 'addresses' is an array, 'network' has enum values with defaults). It adds minimal value beyond the schema's structure, resulting in a baseline score.

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 balance') and target resource ('of an address from sui networks'), making the purpose immediately understandable. It distinguishes itself from siblings like 'sui-transfer' (which moves funds) and 'faucet' (which distributes funds), though it doesn't explicitly name these alternatives. The verb 'Get' is specific enough for a read operation.

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. It doesn't mention prerequisites (e.g., needing a valid address), exclusions, or comparisons to sibling tools like 'get_account_info_by_private_key' (which might provide similar balance information). Usage is implied by the purpose but not explicitly defined.

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/deanpluse/sui-mcp'

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