Skip to main content
Glama

create_reward

Create redeemable rewards for loyalty programs by defining token costs, names, and descriptions to incentivize customer engagement.

Instructions

Create a new reward redeemable with loyalty tokens

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
token_addressYesToken contract address
nameYesReward name
descriptionNoReward description
costYesToken cost to redeem

Implementation Reference

  • Implementation of the 'create_reward' MCP tool which validates authorization, verifies the loyalty program ownership, and inserts the new reward into the database.
    mcpServer.tool("create_reward", {
      description: "Create a new reward redeemable with loyalty tokens",
      inputSchema: { type: "object" as const, properties: { token_address: { type: "string", description: "Token contract address" }, name: { type: "string", description: "Reward name" }, description: { type: "string", description: "Reward description" }, cost: { type: "number", description: "Token cost to redeem" } }, required: ["token_address", "name", "cost"] },
      handler: async ({ token_address, name, description, cost }: any) => {
        const err = authGuard(["manage_rewards"]);
        if (err) return T(err);
        const d = db();
        const { data: prog } = await d.from("loyalty_programs").select("id").eq("token_address", token_address.toLowerCase()).eq("merchant_address", agent.ownerAddress).single();
        if (!prog) return T('{"error":"Program not found or not owned by you"}');
        const { data: reward, error } = await d.from("rewards").insert({ name: name.trim(), description: description?.trim() || null, cost, token_address: token_address.toLowerCase(), merchant_address: agent.ownerAddress, is_active: true }).select("id,name,description,cost,is_active,created_at").single();
        if (error) return T(JSON.stringify({ error: error.message }));
        return T(JSON.stringify({ reward, message: "Reward created" }));
      },
    });

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