Skip to main content
Glama

register_loyalty_program

Register deployed tokens as loyalty programs in the database to manage on-chain rewards, balances, tiers, and marketplace offers.

Instructions

Register a deployed token as a loyalty program in the database

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesProgram name
symbolYesToken symbol
token_addressYesDeployed token contract address (0x...)
expiration_daysNoDuration in days (default: 365)

Implementation Reference

  • The handler function for 'register_loyalty_program' that performs input validation, checks for existing registrations in the database, and inserts a new loyalty program record.
    handler: async ({ name, symbol, token_address, expiration_days }: any) => {
      const err = authGuard(["mint", "create_program"]);
      if (err) return T(err);
      if (!/^0x[a-fA-F0-9]{40}$/.test(token_address)) return T('{"error":"Invalid token_address"}');
      const d = db();
      const { data: existing } = await d.from("loyalty_programs").select("id").eq("token_address", token_address.toLowerCase()).single();
      if (existing) return T('{"error":"Program already registered"}');
      const days = expiration_days || 365;
      const expDate = new Date(Date.now() + days * 24 * 60 * 60 * 1000).toISOString();
      const { data: program, error } = await d.from("loyalty_programs").insert({ name: name.trim(), symbol: symbol.toUpperCase().trim(), token_address: token_address.toLowerCase(), merchant_address: agent.ownerAddress, status: "inactive", expiration_date: expDate }).select("id,name,symbol,token_address,status,expiration_date,created_at").single();
      if (error) return T(JSON.stringify({ error: error.message }));
      return T(JSON.stringify({ program, message: "Program registered as inactive. Call activate_loyalty_program next." }));
    },
  • Registration of the 'register_loyalty_program' tool within the MCP server implementation.
    mcpServer.tool("register_loyalty_program", {
      description: "Register a deployed token as a loyalty program in the database",
      inputSchema: { type: "object" as const, properties: { name: { type: "string", description: "Program name" }, symbol: { type: "string", description: "Token symbol" }, token_address: { type: "string", description: "Deployed token contract address (0x...)" }, expiration_days: { type: "number", description: "Duration in days (default: 365)" } }, required: ["name", "symbol", "token_address"] },
      handler: async ({ name, symbol, token_address, expiration_days }: any) => {
        const err = authGuard(["mint", "create_program"]);
        if (err) return T(err);
        if (!/^0x[a-fA-F0-9]{40}$/.test(token_address)) return T('{"error":"Invalid token_address"}');
        const d = db();
        const { data: existing } = await d.from("loyalty_programs").select("id").eq("token_address", token_address.toLowerCase()).single();
        if (existing) return T('{"error":"Program already registered"}');
        const days = expiration_days || 365;
        const expDate = new Date(Date.now() + days * 24 * 60 * 60 * 1000).toISOString();
        const { data: program, error } = await d.from("loyalty_programs").insert({ name: name.trim(), symbol: symbol.toUpperCase().trim(), token_address: token_address.toLowerCase(), merchant_address: agent.ownerAddress, status: "inactive", expiration_date: expDate }).select("id,name,symbol,token_address,status,expiration_date,created_at").single();
        if (error) return T(JSON.stringify({ error: error.message }));
        return T(JSON.stringify({ program, message: "Program registered as inactive. Call activate_loyalty_program next." }));
      },
Behavior2/5

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

No annotations are provided, so the description carries the full disclosure burden. It mentions persistence ('in the database') but fails to clarify critical behavioral traits: whether this is idempotent, what gets returned (no output schema exists), error conditions (e.g., duplicate registration), or side effects. For a database mutation operation, this is insufficient behavioral coverage.

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?

Single sentence is efficient and front-loaded with the core action. However, given the absence of annotations and output schema, the description is arguably too brief—conciseness becomes under-specification when critical behavioral and sibling-differentiation context is missing.

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

Completeness2/5

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

With zero annotations, no output schema, and a confusingly similar sibling tool ('create_loyalty_program'), the description is incomplete. It should explicitly clarify the distinction between creating new programs versus registering existing deployed tokens, and disclose return values or success indicators.

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?

Input schema has 100% description coverage, establishing a baseline of 3. The description reinforces 'token_address' by mentioning 'deployed token' but adds no additional semantic context (e.g., address format validation, default behavior when expiration_days is omitted) beyond what the schema already provides.

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 states a specific action ('Register') and resource ('deployed token' as 'loyalty program'), clarifying this handles existing tokens. However, it lacks explicit differentiation from the sibling 'create_loyalty_program', which could confuse agents about whether to deploy new tokens or register existing ones.

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?

No explicit guidance on when to use this tool versus 'create_loyalty_program' or other alternatives. While 'deployed token' implies prior token deployment, there are no 'when-to-use' or 'when-not-to-use' instructions, nor prerequisites stated (e.g., token ownership verification).

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