get-token-balance
Retrieve the token balance of a specific blockchain address using 'get-token-balance' in the MCPilot environment, enabling secure and simplified AI-powered blockchain interactions.
Instructions
Get token balance of an address
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| address | Yes | ||
| token | Yes |
Implementation Reference
- The execute handler implementing the get-token-balance tool: casts arguments to Address, calls wagmi's getBalance with wagmiConfig, address, and token, then returns formatted result as text.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 input schema for get-token-balance tool: requires 'address' and 'token' as strings.parameters: z.object({ address: z.string(), token: z.string(), }),
- packages/metamask-mcp/src/tools/get-balance.ts:29-49 (registration)Direct registration of the get-token-balance tool on the FastMCP server instance, including name, description, schema, and handler.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 during MetaMask MCP server initialization, which in turn registers the get-token-balance tool.registerGetBalanceTools(server);