update_program_status
Update loyalty program status in the database after on-chain activation or pause. Synchronize program state between blockchain and backend systems.
Instructions
Update program status in database after on-chain activation/pause
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| token_address | Yes | Token contract address | |
| status | Yes | New status: active, paused, or inactive |
Implementation Reference
- The 'update_program_status' tool is defined here. It updates the loyalty program status in the database, verifying the merchant's ownership of the token address and enforcing valid status values.
mcpServer.tool("update_program_status", { description: "Update program status in database after on-chain activation/pause", inputSchema: { type: "object" as const, properties: { token_address: { type: "string", description: "Token contract address" }, status: { type: "string", description: "New status: active, paused, or inactive" } }, required: ["token_address", "status"] }, handler: async ({ token_address, status }: any) => { const err = authGuard(["mint", "create_program"]); if (err) return T(err); const valid = ["active", "paused", "inactive"]; if (!valid.includes(status)) return T(`{"error":"Invalid status. Use: ${valid.join(", ")}"}`); const d = db(); const { data: prog } = await d.from("loyalty_programs").select("id,name,status").eq("token_address", token_address.toLowerCase()).eq("merchant_address", agent.ownerAddress).single(); if (!prog) return T('{"error":"Program not found"}'); const { error } = await d.from("loyalty_programs").update({ status, updated_at: new Date().toISOString() }).eq("token_address", token_address.toLowerCase()).eq("merchant_address", agent.ownerAddress); if (error) return T(JSON.stringify({ error: error.message })); return T(JSON.stringify({ message: `Status updated from '${prog.status}' to '${status}'`, program: { id: prog.id, name: prog.name, new_status: status } })); }, });