Skip to main content
Glama

Apply promo code

apply_promo
Idempotent

Validates a promo code provided by the human and attaches it to the cart, returning the updated subtotal, discount, shipping, and total or a clear rejection reason.

Instructions

Validate a promo code the human gave you and attach it to the cart. Returns applied=true with the new subtotal, discount, shipping and total, or applied=false with a reason — an invalid or expired code, or a bundle price in the cart that beats it (codes don't stack with bundle pricing). Codes are case-insensitive and a cart holds one: a valid new code replaces the current one, a rejected one leaves it in place; remove_promo just drops it. Needs at least one item in the cart. Never guess or try codes the human didn't give. The code is re-checked in get_order_preview and prepare_order.

Input Schema

NameRequiredDescriptionDefault
codeYesPromo code exactly as the human gave it (case-insensitive).

Output Schema

NameRequiredDescriptionDefault
codeNoNormalized promo code (when applied).
errorNoPresent when the cart is empty or code is missing.
totalNo
bundleNoBundle price that beats the code (when applied=false for that reason).
reasonNoWhy the code was rejected (when applied=false).
appliedNo
currencyNo
discountNo
shippingNo
subtotalNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv1.2.0
    • changedInput schema / properties / code / description
      Previous value: -"Promo code to validate and apply."New value: +"Promo code exactly as the human gave it (case-insensitive)."
    • addedOutput schema / properties / bundle
      Added value: +{
      +  "description": "Bundle price that beats the code (when applied=false for that reason).",
      +  "type": "string"
      +}
  2. First observed

TDQS

A4.6/5.0
Behavior5/5

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

Annotations already declare this is a non-read-only, idempotent, non-destructive closed-world operation. The description adds substantial behavioral context beyond that: applied=true/false outcomes, new totals, rejection reasons including bundle pricing conflicts, case-insensitivity, one-code-per-cart replacement semantics, and re-validation in later steps. There is no contradiction with the annotations.

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 description is front-loaded with the primary action and return behavior, and every sentence provides useful operational context. It is dense with semicolon-separated clauses, but the density is justified by the number of behaviors an agent needs to know for correct use.

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?

Although an output schema exists and the description need not explain return values, it still covers the meaningful result states and failure reasons. It also includes preconditions, replacement behavior, alternatives, and downstream re-validation, making the definition complete for correct invocation.

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?

Schema description coverage is 100%, and the single parameter is already documented as the promo code exactly as provided by the human, case-insensitive. The description reinforces that the code must come from the human and should not be guessed, but it does not add new syntax or format details beyond the schema.

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 gives a specific verb and resource: validate a promo code and attach it to the cart. It also distinguishes the tool from remove_promo and clarifies that the code is re-checked later in get_order_preview and prepare_order.

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

Usage Guidelines5/5

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

It states the precondition (at least one item in the cart), the source constraint (only codes the human gave, never guess), and the alternative for removal (remove_promo). It also explains when a code will be rejected versus when a valid code replaces the existing one.

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