Skip to main content
Glama

update_loyalty_points

Add or redeem customer loyalty points based on store spending - earn 1 point per $1 spent, redeem 100 points for $10 off purchases.

Instructions

Add or redeem loyalty points for a customer. Store policy: 1 point per $1 spent, 100 points = $10 off.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
customerIdYesCustomer ID
pointsYesPoints to add (positive) or redeem (negative)
reasonYesReason for point adjustment

Implementation Reference

  • The handler function for the 'update_loyalty_points' tool. It retrieves the customer by ID from the mock store data, updates their loyalty points by adding the specified amount, handles the case where the customer is not found, and returns a formatted confirmation message with the old and new point balances.
    case 'update_loyalty_points': { const customerId = String(args?.customerId || ''); const points = Number(args?.points || 0); const reason = String(args?.reason || 'adjustment'); const customer = storeData.customers.find(c => c.id === customerId); if (!customer) { return { content: [{ type: 'text', text: `❌ Customer ${customerId} not found` }] }; } const oldPoints = customer.loyaltyPoints; customer.loyaltyPoints += points; return { content: [{ type: 'text', text: `✅ Loyalty points updated for ${customer.name}\n- Previous: ${oldPoints} points\n- Change: ${points > 0 ? '+' : ''}${points} points\n- New Balance: ${customer.loyaltyPoints} points (≈ $${(customer.loyaltyPoints / 10).toFixed(2)} credit)\n- Reason: ${reason}` }] }; }
  • The input schema definition for the 'update_loyalty_points' tool, specifying required parameters: customerId (string), points (number, positive to add, negative to redeem), and reason (string).
    { name: 'update_loyalty_points', description: 'Add or redeem loyalty points for a customer. Store policy: 1 point per $1 spent, 100 points = $10 off.', inputSchema: { type: 'object', properties: { customerId: { type: 'string', description: 'Customer ID' }, points: { type: 'number', description: 'Points to add (positive) or redeem (negative)' }, reason: { type: 'string', description: 'Reason for point adjustment' }, }, required: ['customerId', 'points', 'reason'], }, },
  • src/index.ts:516-518 (registration)
    Registration of the tool list handler. The 'update_loyalty_points' tool is included in the 'tools' array returned by this handler, making it discoverable via the MCP ListTools request. This is where all tools, including this one, are registered for listing.
    server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools }; });
  • src/index.ts:520-521 (registration)
    Registration of the general tool call handler via CallToolRequestSchema. The specific logic for 'update_loyalty_points' is handled in the switch statement within this handler function.
    // Handle tool calls server.setRequestHandler(CallToolRequestSchema, async (request) => {

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/wspotter/mcpart'

If you have feedback or need assistance with the MCP directory API, please join our Discord server