Skip to main content
Glama

get_balance

Check USDC and SOL balances in the agent wallet on Solana devnet to monitor cryptocurrency holdings.

Instructions

Check the USDC and SOL balance of the agent wallet. Returns balances on Solana devnet.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • src/index.ts:34-42 (registration)
    Registration of the 'get_balance' tool in the TOOLS array, including name, description, and empty input schema.
    {
      name: "get_balance",
      description: "Check the USDC and SOL balance of the agent wallet. Returns balances on Solana devnet.",
      inputSchema: {
        type: "object",
        properties: {},
        required: [],
      },
    },
  • MCP server handler for 'get_balance' tool call: invokes wallet.getBalances() and returns JSON-formatted response.
    case "get_balance": {
      const balances = await wallet.getBalances();
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(balances, null, 2),
          },
        ],
      };
    }
  • Core implementation of getBalances() in AgentWallet class: fetches SOL balance via connection.getBalance and USDC balance via SPL token account.
    async getBalances(): Promise<BalanceInfo> {
      const address = this.keypair.publicKey;
    
      // Get SOL balance
      const solBalance = await this.connection.getBalance(address);
      const sol = solBalance / LAMPORTS_PER_SOL;
    
      // Get USDC balance
      let usdc = 0;
      try {
        const usdcAta = await getAssociatedTokenAddress(USDC_MINT, address);
        const tokenAccount = await getAccount(this.connection, usdcAta);
        usdc = Number(tokenAccount.amount) / Math.pow(10, USDC_DECIMALS);
      } catch {
        // Token account doesn't exist yet
        usdc = 0;
      }
    
      return {
        sol: parseFloat(sol.toFixed(4)),
        usdc: parseFloat(usdc.toFixed(2)),
        network: "devnet",
        address: address.toBase58(),
      };
    }
  • TypeScript interface defining the output structure for balance information.
      sol: number;
      usdc: number;
      network: string;
      address: string;
    }
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. It discloses the network ('Solana devnet') and return content ('Returns balances'), which are useful behavioral traits. However, it doesn't mention potential limitations like rate limits, authentication requirements, or whether this is a read-only operation (though 'Check' implies non-destructive).

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 perfectly concise with two sentences that each earn their place: the first states the core functionality, and the second adds critical context about the return and network. There's zero wasted language or redundancy.

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

Completeness4/5

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

For a simple balance-checking tool with 0 parameters and no output schema, the description provides good context: it specifies which assets (USDC, SOL), whose wallet (agent), and which network (Solana devnet). The main gap is lack of output format details, but given the tool's simplicity and the clear return statement, this is reasonably complete.

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

Parameters4/5

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

The tool has 0 parameters with 100% schema description coverage, so the schema already fully documents the lack of inputs. The description appropriately doesn't add parameter information, maintaining focus on what the tool does rather than unnecessary details about non-existent parameters.

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

Purpose5/5

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

The description clearly states the specific action ('Check') and resources ('USDC and SOL balance of the agent wallet'), and distinguishes it from siblings like get_recent_transactions (transaction history) and get_wallet_address (address retrieval). It provides exact scope information about which assets and network are involved.

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

Usage Guidelines3/5

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

The description implies usage context by specifying 'agent wallet' and 'Solana devnet', suggesting this is for checking balances in a development environment. However, it doesn't explicitly state when to use this versus alternatives like send_usdc (for transfers) or request_devnet_airdrop (for funding), nor does it mention any prerequisites or exclusions.

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/noah-ing/agent-wallet-mcp'

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