list_wallets
View all managed wallets with ETH balances and optional token balances for coordinated multi-wallet trading on Base.
Instructions
List all managed wallets with ETH balances and optional token balances.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| token_address | No | Token contract address to check balances for (optional) |
Implementation Reference
- src/index.ts:233-285 (handler)The handler function that implements the logic for 'list_wallets', which fetches ETH and optional token balances for all managed wallets.
async function handleListWallets( args: z.infer<typeof ListWalletsSchema> ): Promise<string> { if (wallets.length === 0) { return JSON.stringify({ wallets: [], message: "No managed wallets. Use create_wallet or import_wallet first.", }); } const provider = getProvider(); const results: Array<{ address: string; label: string; eth_balance: string; token_balance?: string; token_symbol?: string; }> = []; let tokenInfo: { symbol: string; decimals: number } | null = null; if (args.token_address) { tokenInfo = await getTokenInfo(provider, args.token_address); } const balancePromises = wallets.map(async (w) => { const ethBal = await provider.getBalance(w.address); let tokenBal: bigint | undefined; if (args.token_address) { tokenBal = await getTokenBalance(provider, args.token_address, w.address); } return { wallet: w, ethBal, tokenBal }; }); const settled = await Promise.allSettled(balancePromises); for (const result of settled) { if (result.status === "fulfilled") { const { wallet, ethBal, tokenBal } = result.value; const entry: (typeof results)[0] = { address: wallet.address, label: wallet.label, eth_balance: formatEth(ethBal), }; if (tokenBal !== undefined && tokenInfo) { entry.token_balance = ethers.formatUnits(tokenBal, tokenInfo.decimals); entry.token_symbol = tokenInfo.symbol; } results.push(entry); } } return JSON.stringify({ wallets: results, total: results.length }, null, 2); } - src/index.ts:118-123 (schema)Input schema for 'list_wallets'.
const ListWalletsSchema = z.object({ token_address: z .string() .optional() .describe("Token contract address to check balances for (optional)"), }); - src/index.ts:795-807 (registration)Registration of the 'list_wallets' tool in the MCP server.
name: "list_wallets", description: "List all managed wallets with ETH balances and optional token balances.", inputSchema: { type: "object" as const, properties: { token_address: { type: "string", description: "Token contract address to check balances for (optional)", }, }, }, },