Skip to main content
Glama

apply_discount

Idempotent

Apply a discount or promo code to the cart.

SKYFIRE TOKEN (optional): Pass a kya or kya-pay token in the skyfire-pay-id header to boost trust score. No token required — request proceeds normally if omitted. PAYMENT MANDATE: this tool also requires one. Send it as the payment_mandate argument if your client cannot set headers, or as an X-Payment-Mandate header. It must carry mandate_id, max_amount_cents, currency, exp, sub, aud, and its currency must match the cart's currency or the call is denied outright. The cap in max_amount_cents is enforced against the cart total. CREDENTIAL: this store needs one. Call the create_sandbox_key tool first (it is in this tool list and needs no credential), then pass the key you get back as the agent_key argument — or as an Authorization: Bearer header if your client can set headers. Do not ask a person to log in: there is no human login for this store.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sourceNoSet to 'ucp_identity' to apply a loyalty discount derived from a UCP identity token instead of a promo code.
cart_idYesCart session ID
agent_keyNoSandbox credential from `create_sandbox_key`. Use this when your client cannot set an `Authorization: Bearer` header.
discount_codeNoDiscount or promo code to apply (required unless source is ucp_identity)
identity_tokenNoUCP identity bearer token (required when source is ucp_identity).
payment_mandateNoPayment mandate with `mandate_id`, `max_amount_cents`, `currency`, `exp`, `sub`, `aud`. Its `currency` must match the cart's. Use this when your client cannot set an `X-Payment-Mandate` header.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
cart_idYes
currencyYes
discount_codeYes
discount_centsYes
new_total_centsYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changed
    • addedInput schema / properties / agent_key
      Added value: +{
      +  "description": "Sandbox credential from `create_sandbox_key`. Use this when your client cannot set an `Authorization: Bearer` header.",
      +  "type": "string"
      +}
    • addedInput schema / properties / payment_mandate
      Added value: +{
      +  "anyOf": [
      +    {
      +      "additionalProperties": {},
      +      "type": "object"
      +    },
      +    {
      +      "type": "string"
      +    }
      +  ],
      +  "description": "Payment mandate with `mandate_id`, `max_amount_cents`, `currency`, `exp`, `sub`, `aud`. Its `currency` must match the cart's. Use this when your client cannot set an `X-Payment-Mandate` header."
      +}
  2. Changed2 schema fields changed
    • changedInput schema / additionalProperties
      Previous value: -falseNew value: +true
    • changedOutput schema / additionalProperties
      Previous value: -falseNew value: +true
  3. Changed1 schema field changed
    • changedOutput schema / (root)
      Previous value: -nullNew value: +{
      +  "$schema": "http://json-schema.org/draft-07/schema#",
      +  "additionalProperties": false,
      +  "properties": {
      +    "cart_id": {
      +      "type": "string"
      +    },
      +    "currency": {
      +      "type": "string"
      +    },
      +    "discount_cents": {
      +      "type": "number"
      +    },
      +    "discount_code": {
      +      "type": "string"
      +    },
      +    "new_total_cents": {
      +      "type": "number"
      +    }
      +  },
      +  "required": [
      +    "cart_id",
      +    "discount_code",
      +    "discount_cents",
      +    "new_total_cents",
      +    "currency"
      +  ],
      +  "type": "object"
      +}
  4. Changed4 schema fields changed
    • addedInput schema / $schema
      Added value: +"http://json-schema.org/draft-07/schema#"
    • addedInput schema / additionalProperties
      Added value: +false
    • addedInput schema / properties
      Added value: +{
      +  "cart_id": {
      +    "description": "Cart session ID",
      +    "type": "string"
      +  },
      +  "discount_code": {
      +    "description": "Discount or promo code to apply (required unless source is ucp_identity)",
      +    "maxLength": 50,
      +    "minLength": 1,
      +    "type": "string"
      +  },
      +  "identity_token": {
      +    "description": "UCP identity bearer token (required when source is ucp_identity).",
      +    "maxLength": 4096,
      +    "minLength": 1,
      +    "type": "string"
      +  },
      +  "source": {
      +    "const": "ucp_identity",
      +    "description": "Set to 'ucp_identity' to apply a loyalty discount derived from a UCP identity token instead of a promo code.",
      +    "type": "string"
      +  }
      +}
    • addedInput schema / required
      Added value: +[
      +  "cart_id"
      +]
  5. Changed5 schema fields changed
    • removedInput schema / $schema
      Removed value: -"http://json-schema.org/draft-07/schema#"
    • removedInput schema / additionalProperties
      Removed value: -false
    • removedInput schema / properties
      Removed value: -{
      -  "cart_id": {
      -    "description": "Cart session ID",
      -    "type": "string"
      -  },
      -  "discount_code": {
      -    "description": "Discount or promo code to apply",
      -    "maxLength": 50,
      -    "minLength": 1,
      -    "type": "string"
      -  }
      -}
    • removedInput schema / required
      Removed value: -[
      -  "cart_id",
      -  "discount_code"
      -]
    • changedOutput schema / (root)
      Previous value: -{
      -  "$schema": "http://json-schema.org/draft-07/schema#",
      -  "additionalProperties": false,
      -  "properties": {
      -    "cart_id": {
      -      "type": "string"
      -    },
      -    "currency": {
      -      "type": "string"
      -    },
      -    "discount_cents": {
      -      "type": "number"
      -    },
      -    "discount_code": {
      -      "type": "string"
      -    },
      -    "new_total_cents": {
      -      "type": "number"
      -    }
      -  },
      -  "required": [
      -    "cart_id",
      -    "discount_code",
      -    "discount_cents",
      -    "new_total_cents",
      -    "currency"
      -  ],
      -  "type": "object"
      -}New value: +null
  6. First observed

TDQS

A4.7/5.0
Behavior5/5

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

Beyond the annotations, the description reveals that a payment mandate is required even though the schema lists only cart_id as required, and that mismatched currency or over-cap mandates are denied. It also documents credential setup, optional skyfire-token behavior, and the absence of human login. These details significantly exceed what the annotations provide, and there is no contradiction with readOnlyHint=false, destructiveHint=false, or idempotentHint=true.

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?

The first sentence front-loads the core purpose, and the labeled paragraphs (SKYFIRE TOKEN, PAYMENT MANDATE, CREDENTIAL) are scannable and mostly non-redundant. It is long, but the tool has unusually complex auth prerequisites. Some header/argument alternatives are repeated from the parameter descriptions, so it is not perfectly concise, but every block earns its place.

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

Completeness5/5

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

For a tool with 6 parameters and hidden requirements, the description covers setup order, mandatory mandate fields, currency-matching and cap-enforcement failure conditions, header fallbacks, and the no-human-login policy. Since an output schema exists, return-value details do not need to be spelled out. The only omissions are minor edge cases such as discount conflicts, which are not needed to invoke the tool correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Although the schema already describes every parameter, the description adds crucial meaning: payment_mandate is actually mandatory and must match the cart currency with cap enforcement; agent_key is a create_sandbox_key credential; discount_code is required unless source is ucp_identity; and identity_token pairs with source='ucp_identity'. It also introduces the skyfire-pay-id header option, going beyond the schema's field descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a specific verb and resource: 'Apply a discount or promo code to the cart.' This clearly distinguishes it from checkout/payment siblings like complete_checkout and preview_checkout, and the later mention of UCP identity discounts clarifies the alternative input mode. An agent can understand exactly what the tool does without inspecting the schema.

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 gives strong operational guidance: it explicitly tells the agent to call create_sandbox_key first, to pass the key as agent_key or Authorization header, and not to attempt human login. It also explains when to use the payment_mandate argument versus the X-Payment-Mandate header. It does not formally state exclusions like 'use complete_checkout instead,' but the preconditions and alternative paths are clear.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources