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; }

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