Skip to main content
Glama

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

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(), }),
  • 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), }, ], } }, });
  • Top-level call to registerGetBalanceTools(server) in the main MCP server setup, which includes 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