Universal Commerce Protocol (UCP)
How guardrail-sim integrates with the UCP standard for agentic commerce
Universal Commerce Protocol (UCP)
The Universal Commerce Protocol is an open standard for agentic commerce, announced on 11 January 2026 at NRF by Google, Shopify, Etsy, Wayfair, Target and Walmart, with 20+ endorsing partners including Adyen, American Express, Mastercard, Stripe and Visa. It defines how AI agents interact with e-commerce platforms in a standardized, secure way.
Guardrail-sim is UCP-ready, meaning it produces responses that conform to UCP specifications and can integrate directly into UCP-compliant checkout flows.
Why UCP Matters
As AI agents increasingly handle commerce tasks—from comparison shopping to discount negotiation—there needs to be a common language for:
- Validating discount codes with standard error codes
- Allocating discounts across line items consistently
- Managing checkout sessions with predictable state flows
Guardrail-sim provides the policy enforcement layer that sits between AI agents and your commerce backend.
UCP Discount Extension
The UCP Discount Extension defines how discounts are applied and communicated. Guardrail-sim supports:
Error Codes
When a discount is rejected, we return UCP-standard error codes:
| Error Code | Meaning | Example Violation |
|---|---|---|
discount_code_invalid | Code doesn't exist or is malformed | max_discount, margin_floor |
discount_code_expired | Code is past its validity window | discount_expired |
discount_code_user_ineligible | User doesn't qualify | volume_tier, customer_segment_mismatch |
discount_code_combination_disallowed | Can't stack with other codes | stacking_not_allowed |
discount_code_user_not_logged_in | Requires authentication | login_required |
Allocations
Discounts can be distributed across line items using two methods:
across: Proportional allocation based on item subtotalseach: Even split across all items
import { calculateAllocations } from '@guardrail-sim/ucp-types';
const allocations = calculateAllocations(1000, lineItems, 'across');
// [
// { target: '$.line_items[0]', amount: 750 },
// { target: '$.line_items[1]', amount: 250 },
// ]MCP Tools for UCP
The guardrail-sim MCP server exposes UCP-aligned tools:
validate_discount_code
Pre-validate a discount code before applying it to a checkout:
// Input
{
code: 'SUMMER20',
order: { order_value: 5000, quantity: 50, product_margin: 0.4 },
proposed_discount: 0.2
}
// Output
{
valid: false,
error_code: 'discount_code_user_ineligible',
message: 'Discount exceeds tier limit (10% base, 15% for qty >= 100)'
}simulate_checkout_discount
Simulate a full checkout with discounts:
// Input
{
codes: ['SUMMER20'],
line_items: [
{ item_id: 'SKU-001', quantity: 2, subtotal: 5000, product_margin: 0.4 }
],
proposed_discount: 0.1
}
// Output
{
applied: [{
code: 'SUMMER20',
amount: 500,
method: 'across',
allocations: [{ target: '$.line_items[0]', amount: 500 }]
}],
rejected: [],
messages: []
}UCP Types Package
For TypeScript users, import UCP types directly:
import type {
DiscountErrorCode,
AppliedDiscount,
DiscountAllocation,
CheckoutStatus,
} from '@guardrail-sim/ucp-types';
import {
toUCPErrorCode,
buildDiscountExtensionResponse,
calculateAllocations,
} from '@guardrail-sim/ucp-types/converters';Platform Compatibility
Guardrail-sim's UCP implementation is compatible with:
| Platform | Integration | Notes |
|---|---|---|
| Shopify | Types + Error Codes | Types follow the published UCP schemas |
| Google (Gemini) | MCP Transport | MCP server follows the UCP MCP binding |
| Generic UCP | Types + MCP | Targets spec revision 2026-04-08 |
Not conformance-tested
This table describes what the types and the MCP server are written against. The project does not run the UCP conformance suite in CI, so nothing here is a certification claim.