Skip to main content
Glama

get_token_balance

Retrieve loyalty token balance and tier information for a customer wallet to manage on-chain loyalty programs.

Instructions

Get loyalty token balance and tier info for a customer

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
token_addressYesToken contract address
customer_addressYesCustomer wallet

Implementation Reference

  • The tool "get_token_balance" is registered and handled directly within the `loyalty-mcp` function index file. It fetches the customer's token balance and associated tier information from the `customer_tier_status` and `customer_tiers` tables.
    mcpServer.tool("get_token_balance", {
      description: "Get loyalty token balance and tier info for a customer",
      inputSchema: { type: "object" as const, properties: { token_address: { type: "string", description: "Token contract address" }, customer_address: { type: "string", description: "Customer wallet" } }, required: ["token_address", "customer_address"] },
      handler: async ({ token_address, customer_address }: any) => {
        const err = authGuard(["read"]);
        if (err) return T(err);
        const d = db();
        const { data: ts } = await d.from("customer_tier_status").select("current_balance,tokens_earned_total,current_tier_id,last_calculated_at").eq("token_address", token_address.toLowerCase()).eq("customer_address", customer_address.toLowerCase()).single();
        let tier = null;
        if (ts?.current_tier_id) { const { data } = await d.from("customer_tiers").select("tier_name,tier_level,badge_color,cashback_multiplier").eq("id", ts.current_tier_id).single(); tier = data; }
        return T(JSON.stringify({ balance: { current: ts?.current_balance || 0, total_earned: ts?.tokens_earned_total || 0, tier } }));
      },
    });
Behavior3/5

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

With no annotations provided, the description carries the full burden. It discloses that the tool returns both balance and tier information (not just a numeric balance), but fails to mention read-only safety, idempotency, error cases (e.g., invalid addresses), or rate limits.

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

Conciseness4/5

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

The single sentence is front-loaded with the verb 'Get' and contains no redundant words. However, extreme brevity comes at the cost of omitting important contextual details about behavior and return values.

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

Completeness3/5

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

For a two-parameter read operation with complete input schema coverage, the description minimally suffices by mentioning the two data points returned (balance and tier). However, without an output schema, it should ideally describe the return structure or format, which it omits.

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%, establishing a baseline of 3. The description maps 'loyalty token' to token_address and 'customer' to customer_address implicitly, but adds no semantic details about address formats, validation rules, or the relationship between the two addresses.

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 retrieves 'loyalty token balance and tier info' using specific verbs and resources. However, it lacks explicit differentiation from sibling read tools like check_voucher_status or get_program_analytics.

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 like check_voucher_status or get_program_analytics, nor does it specify prerequisites (e.g., whether the customer must be registered first).

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/aspekt19/unboxed-loyalty-spark'

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