get-token-balance
Retrieve token balances for specific blockchain addresses to verify holdings and monitor asset distribution.
Instructions
Get token balance of an address
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| address | Yes | ||
| token | Yes |
Implementation Reference
- The execute handler for the get-token-balance tool, which uses wagmi's getBalance to fetch the token balance for a given address and token contract.execute: async (args) => { const address = args.address as Address const token = args.token as Address const result = await getBalance(wagmiConfig, { address, token }) return { content: [ { type: "text", text: JSONStringify(result), }, ], } },
- Zod schema defining the input parameters for the get-token-balance tool: address (string) and token (string).parameters: z.object({ address: z.string(), token: z.string(), }),
- packages/metamask-mcp/src/tools/get-balance.ts:29-49 (registration)Registration of the get-token-balance tool via server.addTool within the registerGetBalanceTools function.server.addTool({ name: "get-token-balance", description: "Get token balance of an address", parameters: z.object({ address: z.string(), token: z.string(), }), execute: async (args) => { const address = args.address as Address const token = args.token as Address const result = await getBalance(wagmiConfig, { address, token }) return { content: [ { type: "text", text: JSONStringify(result), }, ], } }, });
- packages/metamask-mcp/src/index.ts:44-44 (registration)Top-level call to registerGetBalanceTools(server) in the main MCP server setup, which includes the get-token-balance tool.registerGetBalanceTools(server);