list_rewards
Retrieve available rewards for a loyalty program using its token contract address on Base L2.
Instructions
List rewards for a loyalty program by token_address
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| token_address | Yes | Token contract address (0x...) |
Implementation Reference
- The handler function that executes the "list_rewards" tool, querying the "rewards" table from Supabase.
handler: async ({ token_address }: any) => { const err = authGuard(["read"]); if (err) return T(err); const { data, error } = await db().from("rewards").select("id,name,description,cost,is_active,created_at").eq("token_address", token_address.toLowerCase()).eq("merchant_address", agent.ownerAddress); if (error) return T(JSON.stringify({ error: error.message })); return T(JSON.stringify({ rewards: data || [] })); }, - supabase/functions/loyalty-mcp/index.ts:117-127 (registration)Registration of the "list_rewards" tool within the MCP server definition.
mcpServer.tool("list_rewards", { description: "List rewards for a loyalty program by token_address", inputSchema: { type: "object" as const, properties: { token_address: { type: "string", description: "Token contract address (0x...)" } }, required: ["token_address"] }, handler: async ({ token_address }: any) => { const err = authGuard(["read"]); if (err) return T(err); const { data, error } = await db().from("rewards").select("id,name,description,cost,is_active,created_at").eq("token_address", token_address.toLowerCase()).eq("merchant_address", agent.ownerAddress); if (error) return T(JSON.stringify({ error: error.message })); return T(JSON.stringify({ rewards: data || [] })); }, });