Skip to main content
Glama

use_voucher

Mark loyalty vouchers as redeemed when customers use them at merchants. This merchant-only operation updates voucher status in on-chain loyalty programs.

Instructions

Mark a voucher as used (redeemed by customer at merchant). Merchant-only operation.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
voucher_codeNoVoucher code (e.g. LOYAL-XXXX-XXXX-XXXX-XXXX)
voucher_idNoVoucher UUID (alternative to code)

Implementation Reference

  • Tool implementation for 'use_voucher'. This handler authenticates the request, verifies if the voucher is active and belongs to the merchant, and updates its status to 'used'.
    mcpServer.tool("use_voucher", {
      description: "Mark a voucher as used (redeemed by customer at merchant). Merchant-only operation.",
      inputSchema: {
        type: "object" as const,
        properties: {
          voucher_code: { type: "string", description: "Voucher code (e.g. LOYAL-XXXX-XXXX-XXXX-XXXX)" },
          voucher_id: { type: "string", description: "Voucher UUID (alternative to code)" },
        },
      },
      handler: async ({ voucher_code, voucher_id }: any) => {
        const err = authGuard(["manage_rewards"]);
        if (err) return T(err);
        if (!voucher_code && !voucher_id) return T(JSON.stringify({ error: "Provide voucher_code or voucher_id" }));
    
        const d = db();
        let q = d.from("vouchers").select("*").eq("merchant_address", agent.ownerAddress.toLowerCase());
        if (voucher_code) q = q.eq("code", voucher_code);
        else q = q.eq("id", voucher_id);
    
        const { data: v } = await q.maybeSingle();
        if (!v) return T(JSON.stringify({ error: "Voucher not found" }));
        if (v.status === "used") return T(JSON.stringify({ error: "Already used", used_at: v.used_at }));
        if (v.status !== "active") return T(JSON.stringify({ error: `Not active (status: ${v.status})` }));
    
        const { error: ue } = await d.from("vouchers").update({ status: "used", used_at: new Date().toISOString() }).eq("id", v.id);
        if (ue) return T(JSON.stringify({ error: ue.message }));
    
        return T(JSON.stringify({ success: true, voucher: { id: v.id, code: v.code, reward_name: v.reward_name, customer_address: v.customer_address, status: "used" } }));
      },
    });
Behavior3/5

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

With no annotations provided, the description carries the full disclosure burden. It explains the business scenario (customer redemption at merchant) and implies a state mutation, but omits technical behavioral details such as idempotency, error conditions (e.g., already-used vouchers), or authentication requirements beyond the merchant scope.

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?

Two sentences with zero waste: the first establishes the action and business context, the second establishes the authorization boundary. Information is front-loaded and every word earns its place.

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

Completeness4/5

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

For a simple two-parameter state-change tool without an output schema, the description adequately covers the essential context: what it does, who performs it, and the business scenario. Minor gap: it could clarify the mutual exclusivity requirement of the two parameters (use code OR id).

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%, documenting both voucher_code and voucher_id. The description adds no specific parameter guidance beyond what the schema already provides (e.g., it doesn't clarify that exactly one identifier is required despite both being technically optional in the schema).

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

Purpose5/5

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

The description clearly states the specific action ('Mark a voucher as used'), the resource (voucher), and the context ('redeemed by customer at merchant'). The 'Merchant-only operation' clause effectively distinguishes this from customer-facing redemption tools like 'redeem_reward' in the sibling list.

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

Usage Guidelines4/5

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

The 'Merchant-only operation' text provides clear guidance on the required authorization context and actor role. However, it lacks explicit prerequisites (e.g., suggesting to use 'check_voucher_status' first) or exclusion conditions (when not to use it).

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