Skip to main content
Glama
5ajaki

Veri5ight MCP Server

by 5ajaki

ethereum_getTokenBalance

Retrieve the ERC20 token balance for a specified Ethereum address and token contract. Use the Veri5ight MCP Server to query token balances easily.

Instructions

Get ERC20 token balance for an address

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressYesEthereum address or ENS name
tokenYesToken contract address or ENS name

Implementation Reference

  • The core handler function that implements the ethereum_getTokenBalance tool logic. It extracts parameters, creates an ERC20 contract instance using ethers.js, fetches balance, decimals, and symbol in parallel, formats the balance, and returns the result in MCP format. Handles errors gracefully.
    private async handleGetTokenBalance(request: any) {
      try {
        const address = request.params.arguments?.address;
        const tokenAddress = request.params.arguments?.token;
    
        if (!address || !tokenAddress) {
          throw new Error("Address and token address are required");
        }
    
        // Create contract instance
        const tokenContract = new ethers.Contract(
          tokenAddress,
          ERC20_ABI,
          this.provider
        );
    
        // Get decimals and balance
        const [decimals, balance, symbol] = await Promise.all([
          tokenContract.decimals(),
          tokenContract.balanceOf(address),
          tokenContract.symbol(),
        ]);
    
        const formattedBalance = ethers.formatUnits(balance, decimals);
    
        return {
          content: [
            {
              type: "text",
              text: `Token Balance for ${address}: ${formattedBalance} ${symbol}`,
            },
          ],
        };
      } catch (error: unknown) {
        console.error("Error getting token balance:", error);
        const errorMessage =
          error instanceof Error ? error.message : "Unknown error occurred";
        return {
          content: [
            {
              type: "text",
              text: `Error getting token balance: ${errorMessage}`,
            },
          ],
        };
      }
    }
  • Input schema validation for the ethereum_getTokenBalance tool, defining required 'address' and 'token' string parameters.
    inputSchema: {
      type: "object",
      properties: {
        address: {
          type: "string",
          description: "Ethereum address or ENS name",
        },
        token: {
          type: "string",
          description: "Token contract address or ENS name",
        },
      },
      required: ["address", "token"],
    },
  • src/index.ts:79-96 (registration)
    Tool registration in the ListToolsRequestSchema handler, defining name, description, and input schema for ethereum_getTokenBalance.
    {
      name: "ethereum_getTokenBalance",
      description: "Get ERC20 token balance for an address",
      inputSchema: {
        type: "object",
        properties: {
          address: {
            type: "string",
            description: "Ethereum address or ENS name",
          },
          token: {
            type: "string",
            description: "Token contract address or ENS name",
          },
        },
        required: ["address", "token"],
      },
    },
  • src/index.ts:154-155 (registration)
    Dispatch registration in the CallToolRequestSchema switch statement, routing ethereum_getTokenBalance calls to the handler method.
    case "ethereum_getTokenBalance":
      return await this.handleGetTokenBalance(request);
  • ERC20 ABI fragment used by the ethereum_getTokenBalance handler for contract interactions (balanceOf, decimals, symbol).
    const ERC20_ABI = [
      "function name() view returns (string)",
      "function symbol() view returns (string)",
      "function decimals() view returns (uint8)",
      "function totalSupply() view returns (uint256)",
      "function balanceOf(address) view returns (uint256)",
    ];
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the action ('Get') but doesn't describe traits like read-only nature, potential rate limits, error conditions, or response format. This is a significant gap for a tool with zero annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero waste. It's front-loaded with the core purpose and uses clear terminology, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the lack of annotations and output schema, the description is incomplete. It doesn't address behavioral traits, return values, or error handling, which are crucial for a tool interacting with blockchain data. The high schema coverage doesn't compensate for these gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents both parameters ('address' and 'token') with their types and descriptions. The description adds no additional parameter semantics beyond what the schema provides, meeting the baseline for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Get') and resource ('ERC20 token balance for an address'), making the purpose immediately understandable. It doesn't explicitly differentiate from sibling tools like 'ethereum_getContractInfo' or 'ethereum_getTokenDelegation', but the specificity of 'ERC20 token balance' helps distinguish it from general balance queries.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools, prerequisites, or contextual constraints, leaving the agent to infer usage based on the tool name alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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/5ajaki/veri5ight'

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