Skip to main content
Glama

get_apt_balance

Retrieve the APT token balance for an Aptos blockchain account, displaying amounts in both Octas and APT units for accurate financial tracking.

Instructions

Get the native APT token balance of an Aptos account. This is used for checking the current balance of APT tokens in an account. Returns the account balance in both Octas and APT.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
account_addressYesAptos account address, e.g., 0x1 or 0x742d35Cc6634C0532925a3b8D6Ac0C4db9c8b3

Implementation Reference

  • Main handler function for the get_apt_balance tool. Validates input arguments, calls the performance helper, and returns formatted success or error response.
    export async function getAptBalanceHandler(args: Record<string, any> | undefined) {
      if (!isGetAptBalanceArgs(args)) {
        throw new Error("Invalid arguments for get_apt_balance");
      }
    
      const { account_address } = args;
    
      try {
        const results = await performGetAptBalance(account_address);
        return {
          content: [{ type: "text", text: results }],
          isError: false,
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: `Error getting APT balance: ${error instanceof Error ? error.message : String(error)}`,
            },
          ],
          isError: true,
        };
      }
    }
  • Tool schema definition including name, description, and input schema requiring 'account_address' string.
    export const GET_APT_BALANCE: Tool = {
      name: "get_apt_balance",
      description: "Get the native APT token balance of an Aptos account. This is used for checking the current balance of APT tokens in an account. Returns the account balance in both Octas and APT.",
      inputSchema: {
        type: "object",
        properties: {
          account_address: {
            type: "string",
            description: "Aptos account address, e.g., 0x1 or 0x742d35Cc6634C0532925a3b8D6Ac0C4db9c8b3",
          },
        },
        required: ["account_address"],
      },
    };
  • Core logic to fetch APT balance using Aptos client, format output in Octas and APT, handle account not found cases.
    export async function performGetAptBalance(accountAddress: string): Promise<string> {
      try {
        const aptos = getAptosClient();
        
        // Get account APT balance
        const balance = await aptos.getAccountAPTAmount({ accountAddress });
    
        return `APT Balance Information:
    Account: ${formatAddress(accountAddress)}
    Balance: ${balance} Octas
    Balance: ${formatAPT(balance)} APT
    
    Full Account Address: ${accountAddress}`;
      } catch (error) {
        console.error('Error getting APT balance:', error);
        
        // Check if account doesn't exist
        if (error instanceof Error && error.message.includes('not found')) {
          return `APT Balance Information:
    Account: ${formatAddress(accountAddress)}
    Balance: 0 Octas (0 APT)
    Status: Account does not exist or has not been initialized
    
    Note: Account needs to receive at least one transaction to be initialized on-chain`;
        }
        
        throw new Error(`Failed to get APT balance: ${error instanceof Error ? error.message : String(error)}`);
      }
    }
  • Type guard function to validate input arguments contain a string 'account_address'.
    export function isGetAptBalanceArgs(args: unknown): args is { account_address: string } {
      return (
        typeof args === "object" &&
        args !== null &&
        "account_address" in args &&
        typeof (args as any).account_address === "string"
      );
    }
  • src/index.ts:120-121 (registration)
    Tool registration in the main MCP server switch statement for stdio transport, dispatching to getAptBalanceHandler.
    case "get_apt_balance":
      return await getAptBalanceHandler(args);
Behavior3/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 specifies that the tool returns the balance in both Octas and APT, adding useful context beyond a simple read operation. However, it lacks details on error handling, rate limits, or authentication needs, which are important for a financial query tool.

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

Conciseness4/5

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

The description is concise and front-loaded, stating the core purpose in the first sentence. The second sentence adds clarification on usage and return format, but could be slightly more streamlined by integrating the return details into the initial statement without redundancy.

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

Completeness3/5

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

Given the tool's low complexity (1 parameter, no output schema, no annotations), the description is moderately complete. It explains the return values (balance in Octas and APT), which compensates for the lack of output schema. However, it misses behavioral aspects like error cases or performance considerations, leaving room for improvement.

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?

The input schema has 100% description coverage, clearly documenting the single required parameter 'account_address' with examples. The description does not add any parameter-specific information beyond what the schema provides, so it meets the baseline score of 3 for adequate but no extra value.

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 tool's purpose with a specific verb ('Get') and resource ('native APT token balance of an Aptos account'), distinguishing it from siblings like 'get_coin_balance' by specifying APT tokens. However, it doesn't explicitly differentiate from 'get_account_info', which might also include balance information, keeping it from 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 no guidance on when to use this tool versus alternatives like 'get_account_info' or 'get_coin_balance'. It states what the tool does but offers no context on prerequisites, exclusions, or comparative use cases, leaving the agent to infer usage from the tool name alone.

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/punkpeye/aptos-mcp'

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