Skip to main content
Glama

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
NameRequiredDescriptionDefault
addressYes
tokenYes

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(), }),
  • 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), }, ], } }, });
  • Top-level call to registerGetBalanceTools during MetaMask MCP server initialization, which in turn registers the get-token-balance tool.
    registerGetBalanceTools(server);

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Xiawpohr/mcpilot'

If you have feedback or need assistance with the MCP directory API, please join our Discord server