Skip to main content
Glama
buildwithgrove

Grove's MCP Server for Pocket Network

get_sui_balance

Retrieve SUI token balance for any Sui blockchain address on mainnet or testnet networks using Grove's blockchain data service.

Instructions

Get SUI balance for an address

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressYesSui address
networkNoNetwork type (defaults to mainnet)

Implementation Reference

  • Handler logic in handleSuiTool function that processes arguments, calls SuiService.getBalance, and returns the result as MCP tool response.
    case 'get_sui_balance': { const address = args?.address as string; const network = (args?.network as 'mainnet' | 'testnet') || 'mainnet'; const result = await suiService.getBalance(address, network); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], isError: !result.success, }; }
  • Input schema for the get_sui_balance tool, requiring 'address' and optionally 'network'.
    inputSchema: { type: 'object', properties: { address: { type: 'string', description: 'Sui address', }, network: { type: 'string', enum: ['mainnet', 'testnet'], description: 'Network type (defaults to mainnet)', }, }, required: ['address'], },
  • Tool registration object defining name, description, and schema for get_sui_balance, returned by registerSuiHandlers.
    { name: 'get_sui_balance', description: 'Get SUI balance for an address', inputSchema: { type: 'object', properties: { address: { type: 'string', description: 'Sui address', }, network: { type: 'string', enum: ['mainnet', 'testnet'], description: 'Network type (defaults to mainnet)', }, }, required: ['address'], }, },
  • Core implementation of getBalance in SuiService: calls suix_getBalance RPC method and formats the response with human-readable SUI balance.
    async getBalance( address: string, network: 'mainnet' | 'testnet' = 'mainnet' ): Promise<EndpointResponse> { const service = this.blockchainService.getServiceByBlockchain('sui', network); if (!service) { return { success: false, error: `Sui service not found for ${network}`, }; } const result = await this.blockchainService.callRPCMethod( service.id, 'suix_getBalance', [address] ); if (result.success && result.data) { // Add human-readable balance (SUI has 9 decimals) const totalBalance = BigInt(result.data.totalBalance || '0'); const sui = Number(totalBalance) / 1e9; return { success: true, data: { address, totalBalance: result.data.totalBalance, sui, coinType: result.data.coinType || '0x2::sui::SUI', }, metadata: result.metadata, }; } return result; }

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/buildwithgrove/mcp-pocket'

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