Skip to main content
Glama

scp_get_loyalty

Retrieve customer loyalty status and points from authorized merchants using the Shopper Context Protocol to access e-commerce data securely.

Instructions

Get loyalty status and points from a merchant. Domain must be authorized first.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
domainYesMerchant domain

Implementation Reference

  • Primary handler function for the scp_get_loyalty tool. Validates authorization, retrieves the access token, calls the HTTP client to fetch loyalty data from the merchant's SCP endpoint, and returns the result as formatted JSON.
     * Tool handler: scp_get_loyalty
     */
    async function handleGetLoyalty(domain: string) {
      const { auth, accessToken } = await checkAuthorizationOrThrow(domain);
      const token = await accessToken;
    
      const data = await scpClient.getLoyalty(auth.scp_endpoint, token);
    
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(data, null, 2)
          }
        ]
      };
    }
  • Input schema definition registered for the scp_get_loyalty tool, requiring a 'domain' parameter.
    {
      name: 'scp_get_loyalty',
      description: 'Get loyalty status and points from a merchant. Domain must be authorized first.',
      inputSchema: {
        type: 'object',
        properties: {
          domain: {
            type: 'string',
            description: 'Merchant domain'
          }
        },
        required: ['domain']
      }
    },
  • src/server.ts:303-538 (registration)
    Tool registration within the ListToolsRequestSchema handler, where scp_get_loyalty is included in the list of available tools with its schema.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: [
        {
          name: 'scp_authorize',
          description: 'BEFORE USING THIS ENSURE THE DOMAIN SUPPORTS SCP BY CALLING scp_discover FIRST. Authorize access to a merchant\'s customer context via SCP. Must be called before accessing any customer data. IMPORTANT: You must ask the user for their REAL email address - never use placeholder emails like user@example.com. Ask: "What email address do you use with [Merchant]?" and wait for their response.',
          inputSchema: {
            type: 'object',
            properties: {
              domain: {
                type: 'string',
                description: 'Merchant domain (e.g., \'acmestore.com\')'
              },
              email: {
                type: 'string',
                description: 'Customer\'s REAL email address (must ask user for this - never use example.com or placeholder emails)'
              },
              scopes: {
                type: 'array',
                items: { type: 'string' },
                description: 'Requested scopes (e.g., [\'orders\', \'loyalty\', \'intent:read\']). Best practice: request all needed scopes upfront.'
              }
            },
            required: ['domain', 'email', 'scopes']
          }
        },
        {
          name: 'scp_check_authorization',
          description: 'Check if authorized with a merchant domain',
          inputSchema: {
            type: 'object',
            properties: {
              domain: {
                type: 'string',
                description: 'Merchant domain'
              }
            },
            required: ['domain']
          }
        },
        {
          name: 'scp_revoke_authorization',
          description: 'Revoke authorization with a merchant domain',
          inputSchema: {
            type: 'object',
            properties: {
              domain: {
                type: 'string',
                description: 'Merchant domain'
              }
            },
            required: ['domain']
          }
        },
        {
          name: 'scp_discover',
          description: 'Discover SCP endpoint for a merchant domain via DNS',
          inputSchema: {
            type: 'object',
            properties: {
              domain: {
                type: 'string',
                description: 'Merchant domain'
              }
            },
            required: ['domain']
          }
        },
        {
          name: 'scp_get_orders',
          description: 'Get order history from a merchant. Domain must be authorized first.',
          inputSchema: {
            type: 'object',
            properties: {
              domain: {
                type: 'string',
                description: 'Merchant domain'
              },
              limit: {
                type: 'number',
                description: 'Maximum number of orders to return',
                default: 10
              },
              offset: {
                type: 'number',
                description: 'Number of orders to skip',
                default: 0
              },
              status: {
                type: 'array',
                items: { type: 'string' },
                description: 'Filter by order status (e.g., [\'delivered\', \'shipped\'])'
              }
            },
            required: ['domain']
          }
        },
        {
          name: 'scp_get_loyalty',
          description: 'Get loyalty status and points from a merchant. Domain must be authorized first.',
          inputSchema: {
            type: 'object',
            properties: {
              domain: {
                type: 'string',
                description: 'Merchant domain'
              }
            },
            required: ['domain']
          }
        },
        {
          name: 'scp_get_offers',
          description: 'Get active personalized offers from a merchant. Domain must be authorized first.',
          inputSchema: {
            type: 'object',
            properties: {
              domain: {
                type: 'string',
                description: 'Merchant domain'
              },
              active_only: {
                type: 'boolean',
                description: 'Only return active offers',
                default: true
              }
            },
            required: ['domain']
          }
        },
        {
          name: 'scp_get_preferences',
          description: 'Get saved customer preferences (sizes, styles, addresses) from a merchant. Domain must be authorized first.',
          inputSchema: {
            type: 'object',
            properties: {
              domain: {
                type: 'string',
                description: 'Merchant domain'
              }
            },
            required: ['domain']
          }
        },
        {
          name: 'scp_get_intents',
          description: 'Get shopping intents from a merchant. Domain must be authorized first.',
          inputSchema: {
            type: 'object',
            properties: {
              domain: {
                type: 'string',
                description: 'Merchant domain'
              },
              status: {
                type: 'array',
                items: { type: 'string' },
                description: 'Filter by status (e.g., [\'active\', \'in_progress\'])'
              },
              limit: {
                type: 'number',
                description: 'Maximum number of intents to return',
                default: 10
              }
            },
            required: ['domain']
          }
        },
        {
          name: 'scp_create_intent',
          description: 'Create a new shopping intent with a merchant. Domain must be authorized with intent:create scope.',
          inputSchema: {
            type: 'object',
            properties: {
              domain: {
                type: 'string',
                description: 'Merchant domain'
              },
              base_intent: {
                type: 'string',
                description: 'Natural language description of the shopping goal'
              },
              context: {
                type: 'object',
                description: 'Additional context about the intent'
              },
              mechanism: {
                type: 'string',
                description: 'How the intent was created',
                default: 'conversational_ai'
              },
              ai_assistant: {
                type: 'string',
                description: 'Name of the AI assistant'
              },
              visibility: {
                type: 'string',
                description: 'Who can see this intent',
                enum: ['merchant_only', 'shared_with_customer'],
                default: 'merchant_only'
              }
            },
            required: ['domain', 'base_intent']
          }
        },
        {
          name: 'scp_update_intent',
          description: 'Update an existing shopping intent. Domain must be authorized with intent:write scope.',
          inputSchema: {
            type: 'object',
            properties: {
              domain: {
                type: 'string',
                description: 'Merchant domain'
              },
              intent_id: {
                type: 'string',
                description: 'Intent ID to update'
              },
              status: {
                type: 'string',
                description: 'New status'
              },
              context: {
                type: 'object',
                description: 'Updated context'
              },
              add_milestone: {
                type: 'string',
                description: 'Add a milestone note'
              }
            },
            required: ['domain', 'intent_id']
          }
        }
      ]
    }));
  • Helper function in the HTTP client that performs the actual JSON-RPC call to the merchant's SCP endpoint for retrieving loyalty information.
    export async function getLoyalty(
      endpoint: string,
      accessToken: string
    ): Promise<any> {
      return makeRPCRequest(endpoint, accessToken, 'scp.get_loyalty');
    }
  • Shared helper function used by scp_get_loyalty and other data-access tools to check authorization and retrieve the access token, throwing a helpful error if not authorized.
    async function checkAuthorizationOrThrow(domain: string): Promise<{ auth: any; accessToken: Promise<string> }> {
      const auth = await getAuthorization(domain);
    
      if (!auth) {
        const errorMessage = `❌ Not authorized with ${domain}.\n\n` +
          `Please authorize first by calling:\n` +
          `scp_authorize with domain="${domain}", email="your@email.com", and scopes=["orders", "loyalty", "preferences", "intent:read", "intent:create"]`;
        throw new Error(errorMessage);
      }
    
      return {
        auth,
        accessToken: getValidAccessToken(domain)
      };
    }
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 burden of behavioral disclosure. It mentions the authorization prerequisite, which adds some context, but it does not describe other behavioral traits such as what data is returned (e.g., format of loyalty status/points), error handling, rate limits, or authentication needs beyond the implied authorization. For a tool with zero annotation coverage, this is a significant gap in transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded with two concise sentences: the first states the purpose, and the second provides the key usage guideline. Every sentence earns its place by delivering essential information without waste, making it highly efficient and well-structured.

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

Completeness3/5

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

Given the tool's complexity (simple retrieval with one parameter), no annotations, and no output schema, the description is partially complete. It covers the purpose and a key prerequisite, but it lacks details on return values, error cases, or behavioral nuances. Without an output schema, the description should ideally explain what 'loyalty status and points' entails, but it does not, leaving gaps in completeness.

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?

The input schema has 100% description coverage, with the 'domain' parameter documented as 'Merchant domain.' The description does not add any additional meaning beyond this, as it only references 'domain' in the context of authorization. Since the schema already fully describes the parameter, the baseline score of 3 is appropriate, as the description does not compensate but also does not detract.

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 clearly states the tool's purpose: 'Get loyalty status and points from a merchant.' It specifies the action ('Get'), resource ('loyalty status and points'), and target ('merchant'), which is specific and informative. However, it does not explicitly differentiate this tool from sibling tools like 'scp_get_offers' or 'scp_get_orders', which might also retrieve merchant-related data, so it falls short of a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context for usage with the statement: 'Domain must be authorized first.' This implies a prerequisite (authorization via tools like 'scp_authorize') and helps guide when to use this tool. However, it does not explicitly mention when not to use it or name alternatives (e.g., vs. 'scp_get_offers'), so it lacks full explicit guidance.

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/shopper-context-protocol/scp-mcp-wrapper'

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