getWalletInfo
Retrieve detailed wallet information for any Binance Smart Chain address, including balances and transaction history, using the BSC MCP Server API.
Instructions
Get wallet info for an address
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| address | No |
Implementation Reference
- src/tools/getWalletInfo.ts:10-36 (handler)The core handler function for the 'Get_Wallet_Info' tool. Fetches balance for the provided or user's own wallet address using getBalance helper, formats native BNB balance, token balances, and address into text content, or returns error response.async ({ address }) => { try { if (address === '' || !address || address === 'null') { const account = await getAccount(); address = account.address } const balance = await getBalance(address); return { content: [ { type: "text", text: `Native Balance (BNB): ${balance.nativeBalance}\n\nToken Balances:\n${JSON.stringify(balance.tokenBalances)}\n\nWallet Address: ${address}`, }, ], }; } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to fetch balance: ${errorMessage}` }, ], isError: true, }; } }
- src/tools/getWalletInfo.ts:8-8 (schema)Zod input schema for the tool: optional 'address' string parameter for the wallet address to query.address: z.string().optional().describe("When querying the user's own wallet value, it is null"),
- src/tools/getWalletInfo.ts:6-38 (registration)Registration function for the 'Get_Wallet_Info' tool, called by main.ts. Registers the tool on the McpServer with name, description, input schema, and handler function.export function registerGetWalletInfo(server: McpServer) { server.tool("Get_Wallet_Info", "👛View detailed balance and holdings for any wallet address", { address: z.string().optional().describe("When querying the user's own wallet value, it is null"), }, async ({ address }) => { try { if (address === '' || !address || address === 'null') { const account = await getAccount(); address = account.address } const balance = await getBalance(address); return { content: [ { type: "text", text: `Native Balance (BNB): ${balance.nativeBalance}\n\nToken Balances:\n${JSON.stringify(balance.tokenBalances)}\n\nWallet Address: ${address}`, }, ], }; } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to fetch balance: ${errorMessage}` }, ], isError: true, }; } } ); }
- src/main.ts:30-30 (registration)Call to registerGetWalletInfo during MCP server initialization, integrating the tool into the server.registerGetWalletInfo(server);