Skip to main content
Glama

get-balance

Retrieve the balance of a specified address on the MantraChain blockchain. Defaults to the current address if none is provided. Requires the network name for accurate querying.

Instructions

Get balance of an address (defaults to your own address if none provided)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressNoOptional address to get balance for, defaults to current address
networkNameYesName of the network to use - must first check what networks are available through the mantrachain-mcp server by accessing the networks resource `networks://all` before you pass this arguments

Implementation Reference

  • Handler function that executes the get-balance tool: initializes the MantraClient for the specified network, fetches the balance, and returns it formatted as MCP text content.
    async ({ address, networkName }) => { await mantraClient.initialize(networkName); const balance = await mantraClient.getBalance(address); return { content: [{type: "text", text: JSON.stringify(balance)}], }; }
  • Zod input schema defining parameters: optional address (defaults to current) and networkName with validation.
    { address: z.string().optional().describe("Optional address to get balance for, defaults to current address"), networkName: z.string().refine(val => Object.keys(networks).includes(val), { message: "Must be a valid network name" }).describe("Name of the network to use - must first check what networks are available by accessing the networks resource `networks://all` before you pass this arguments. Defaults to `mantra-dukong-1` testnet."), },
  • Registration of the 'get-balance' MCP tool using server.tool, including description, input schema, and handler.
    server.tool( "get-balance", "Get balance of an address (defaults to your own address if none provided)", { address: z.string().optional().describe("Optional address to get balance for, defaults to current address"), networkName: z.string().refine(val => Object.keys(networks).includes(val), { message: "Must be a valid network name" }).describe("Name of the network to use - must first check what networks are available by accessing the networks resource `networks://all` before you pass this arguments. Defaults to `mantra-dukong-1` testnet."), }, async ({ address, networkName }) => { await mantraClient.initialize(networkName); const balance = await mantraClient.getBalance(address); return { content: [{type: "text", text: JSON.stringify(balance)}], }; } );
  • Core helper method in BankService that performs the actual balance query using StargateClient.getAllBalances.
    async getBalance(address?: string) { const targetAddress = address || this.address; if (!targetAddress) { throw new Error('No address provided and no default address set.'); } try { const balances = await this.stargateClient.getAllBalances(targetAddress); return { balances: balances, explorerUrl: `${this.network.explorerUrl}/address/${targetAddress}`, }; } catch (error) { throw new Error(`Failed to query balance: ${error instanceof Error ? error.message : String(error)}`); } }
  • MantraClient wrapper method that delegates getBalance calls to the underlying BankService.
    async getBalance(address?: string) { if (!this.bankService) { throw new Error('Client not initialized. Call initialize() first.'); } return this.bankService.getBalance(address); }

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/allthatjazzleo/mantrachain-mcp'

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