Skip to main content
Glama
RWAValueRouter

ValueRouter MCP Server

get_user_balance

Retrieve token balances for specific users on designated blockchain networks to monitor holdings and verify transaction eligibility.

Instructions

Get user token balance on a specific chain

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
chainIdYesChain ID to check balance on
tokenAddressYesToken contract address
userAddressYesUser address to check balance for

Implementation Reference

  • src/index.ts:265-290 (registration)
    Registration of the 'get_user_balance' tool including name, description, and input schema definition.
    {
      name: 'get_user_balance',
      description: 'Get user token balance on a specific chain',
      inputSchema: {
        type: 'object',
        properties: {
          chainId: {
            oneOf: [
              { type: 'number' },
              { type: 'string' },
            ],
            description: 'Chain ID to check balance on',
          },
          tokenAddress: {
            type: 'string',
            description: 'Token contract address',
          },
          userAddress: {
            type: 'string',
            description: 'User address to check balance for',
          },
        },
        required: ['chainId', 'tokenAddress', 'userAddress'],
        additionalProperties: false,
      },
    },
  • Zod input schema (BalanceQuerySchema) used for validating get_user_balance tool arguments.
    export const BalanceQuerySchema = z.object({
      chainId: z.union([z.number(), z.string()]),
      tokenAddress: z.string(),
      userAddress: z.string(),
    });
    
    export type BalanceQuery = z.infer<typeof BalanceQuerySchema>;
  • Main tool handler 'getUserBalance' that parses input schema and calls BalanceService for execution.
    private async getUserBalance(args: any): Promise<MCPToolResult> {
      try {
        const request = BalanceQuerySchema.parse(args);
        const result = await this.balanceService.getBalance(request);
        return createSuccessResponse(result);
      } catch (error) {
        return createErrorResponse(
          error instanceof Error ? error.message : String(error),
          'BALANCE_ERROR'
        );
      }
    }
  • Core balance fetching logic in BalanceService.getBalance, dispatching to chain-specific balance retrievers.
    async getBalance(query: BalanceQuery): Promise<BalanceResponse> {
      const { chainId, tokenAddress, userAddress } = query;
      const chainIdTyped = chainId as SupportedChainId;
    
      try {
        if (isEVMChain(chainIdTyped)) {
          return await this.getEVMBalance(chainIdTyped, tokenAddress, userAddress);
        } else if (isSolanaChain(chainIdTyped)) {
          return await this.getSolanaBalance(chainIdTyped, tokenAddress, userAddress);
        } else if (isSuiChain(chainIdTyped)) {
          return await this.getSuiBalance(chainIdTyped, tokenAddress, userAddress);
        } else if (isCosmosChain(chainIdTyped)) {
          return await this.getCosmosBalance(chainIdTyped, tokenAddress, userAddress);
        } else {
          throw new Error(`Unsupported chain: ${chainId}`);
        }
      } catch (error) {
        throw new Error(`Failed to get balance: ${error instanceof Error ? error.message : String(error)}`);
      }
    }
  • Zod output schema (BalanceResponseSchema) defining the structure of balance query results.
    export const BalanceResponseSchema = z.object({
      chainId: z.union([z.number(), z.string()]),
      tokenAddress: z.string(),
      balance: z.string(),
      decimals: z.number(),
      symbol: z.string(),
      formattedBalance: z.string(),
    });
    
    export type BalanceResponse = z.infer<typeof BalanceResponseSchema>;
Behavior2/5

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

No annotations are provided, so the description carries full burden. While 'Get' implies a read operation, the description doesn't disclose important behavioral aspects like whether this requires authentication, rate limits, error conditions, or what format the balance returns in. For a financial tool with zero annotation coverage, this is insufficient.

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 wasted words. It's appropriately sized for a straightforward tool and front-loads the essential information.

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?

For a financial balance-checking tool with no annotations and no output schema, the description is incomplete. It doesn't explain what the return value looks like (numeric balance, formatted string, etc.), error handling, or authentication requirements. The context signals indicate this is a non-trivial tool requiring more behavioral disclosure.

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 all three parameters thoroughly. The description adds no additional parameter semantics beyond what's in the schema descriptions. This meets the baseline expectation when schema coverage is complete.

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 tool's purpose with a specific verb ('Get') and resource ('user token balance'), and specifies the scope ('on a specific chain'). It doesn't explicitly distinguish from sibling tools, but the purpose is unambiguous for this domain.

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. With sibling tools like 'get_supported_tokens' and 'get_transaction_status' available, there's no indication of when this balance-checking tool is appropriate versus other read operations.

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

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/RWAValueRouter/MCP'

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