check_balance
Verify wallet balances on the Base network using the MCP server by providing the wallet name or address. Simplifies blockchain operations through natural language commands.
Instructions
Check wallet balance
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| wallet | No | Wallet name or address (defaults to primary wallet) |
Implementation Reference
- src/mcp/tools.ts:89-104 (handler)The core handler function that implements the check_balance tool logic: retrieves the balance of a specified wallet (defaulting to the primary wallet) using getWalletBalance and returns a formatted response.async function handleCheckBalance(args: CheckBalanceArgs): Promise<any> { try { const walletName = args.wallet || (getDefaultWallet()?.name || 'default'); const balance = await getWalletBalance(walletName); return { success: true, message: `Balance of wallet "${walletName}": ${balance} ETH`, balance, wallet: walletName }; } catch (error) { console.error('Error checking balance:', error); throw error; } }
- src/mcp/server.ts:227-239 (registration)MCP server registration of the check_balance tool in the standard ListToolsRequestSchema handler, defining name, description, and input schema.{ name: 'check_balance', description: 'Check wallet balance', inputSchema: { type: 'object', properties: { wallet: { type: 'string', description: 'Wallet name or address (defaults to primary wallet)', }, }, }, },
- src/types.ts:57-60 (schema)TypeScript interface defining the input parameters for the check_balance tool.export interface CheckBalanceArgs { wallet?: string; // Wallet name or address, defaults to primary wallet asset?: string; // Asset type, defaults to ETH }
- src/mcp/server.ts:83-95 (registration)Additional registration of the check_balance tool in the custom listTools method handler.{ name: 'check_balance', description: 'Check wallet balance', inputSchema: { type: 'object', properties: { wallet: { type: 'string', description: 'Wallet name or address (defaults to primary wallet)', }, }, }, },
- src/mcp/server.ts:294-307 (handler)Dispatch handler in the MCP server's CallToolRequestSchema that invokes the check_balance tool handler with validated arguments and formats the response.case 'check_balance': { const result = await toolHandlers.handleCheckBalance({ wallet: typeof args.wallet === 'string' ? args.wallet : undefined, }); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; }