check_voucher_status
Verify the current status of loyalty program vouchers using either voucher codes or IDs. This public tool requires no authentication and works with the Loyal Spark Loyalty Protocol on Base L2.
Instructions
Check voucher status by code or ID. Public endpoint — no API key or authentication required.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | No | Voucher code (e.g. LOYAL-XXXX-XXXX-XXXX-XXXX) | |
| voucher_id | No | Voucher UUID (alternative to code) |
Implementation Reference
- The handler function for 'check_voucher_status' that fetches voucher details from the database based on either code or voucher_id.
handler: async ({ code, voucher_id }: any) => { if (!code && !voucher_id) return T(JSON.stringify({ error: "Provide code or voucher_id" })); const d = db(); let q = d.from("vouchers").select("id, code, reward_name, reward_description, cost, status, token_address, token_symbol, merchant_address, activated_at, used_at"); if (code) q = q.eq("code", code); else q = q.eq("id", voucher_id); const { data: v, error: e } = await q.maybeSingle(); if (e || !v) return T(JSON.stringify({ error: "Voucher not found" })); return T(JSON.stringify({ voucher: v })); }, - supabase/functions/loyalty-mcp/index.ts:309-330 (registration)The registration of the 'check_voucher_status' tool in the MCP server.
mcpServer.tool("check_voucher_status", { description: "Check voucher status by code or ID. Public endpoint — no API key or authentication required.", inputSchema: { type: "object" as const, properties: { 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 ({ code, voucher_id }: any) => { if (!code && !voucher_id) return T(JSON.stringify({ error: "Provide code or voucher_id" })); const d = db(); let q = d.from("vouchers").select("id, code, reward_name, reward_description, cost, status, token_address, token_symbol, merchant_address, activated_at, used_at"); if (code) q = q.eq("code", code); else q = q.eq("id", voucher_id); const { data: v, error: e } = await q.maybeSingle(); if (e || !v) return T(JSON.stringify({ error: "Voucher not found" })); return T(JSON.stringify({ voucher: v })); }, - The input schema for 'check_voucher_status' validating code and voucher_id.
inputSchema: { type: "object" as const, properties: { code: { type: "string", description: "Voucher code (e.g. LOYAL-XXXX-XXXX-XXXX-XXXX)" }, voucher_id: { type: "string", description: "Voucher UUID (alternative to code)" }, }, },