Skip to main content
Glama
trhonpavel
by trhonpavel

Create promotion

create_promotion

Create percentage or fixed-amount discount codes and automatic promotions in Medusa for orders, products, or shipping, including free shipping and category restrictions.

Instructions

Creates a discount code (or an automatic promotion): percentage or fixed amount off the order, specific products, or shipping. Free shipping = applies_to 'shipping', percentage 100. Restricting to products/categories/collections makes it apply to those items only. Plain dates are interpreted in the reporting timezone.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYesThe code customers enter, e.g. AUTUMN20
valueYesPercent (20 = 20 %) or amount in major units
statusNoactive
ends_atNoInclusive, e.g. 2026-11-30
starts_atNoE.g. 2026-11-01
allocationNo'across' (default) splits the discount over the eligible items; 'each' applies it to every unit up to max_quantity
applies_toNoDefaults to 'items' when restricted to products/categories/collections, otherwise 'order'
extra_rulesNoAdvanced eligibility conditions
product_idsNo
usage_limitNoTotal number of uses (not for automatic promotions)
category_idsNo
is_automaticNoApplies without entering the code
max_quantityNoRequired with allocation 'each'
currency_codeNoRequired for a fixed amount, e.g. czk
discount_typeYes
collection_idsNo
customer_group_idsNoOnly for customers in these groups

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv0.3.0

TDQS

A4.1/5.0
Behavior4/5

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

Annotations already disclose write/non-idempotent/open-world behavior, so the bar is lower. The description adds genuinely useful context the annotations don't: plain dates are interpreted in the reporting timezone, and restriction arrays change the discount's scope. It stops short of covering duplicate-code handling or failure modes.

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?

Front-loaded with the core purpose, then four tight sentences covering the main configuration axes. Dense but every clause carries information; no filler.

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

Completeness4/5

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

For a 17-parameter write tool with no output schema, the description covers the high-risk semantics (scope, dates/timezone, free-shipping, automatic vs code). Remaining gaps are advanced fields like extra_rules, which the schema documents adequately.

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

Parameters4/5

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

Schema coverage is 71%, and the description compensates on the ambiguous parts: it explains the applies_to default logic, the free-shipping recipe, and the timezone interpretation of starts_at/ends_at, none of which appear in the schema. Parameters like extra_rules and customer_group_ids are left to the schema, so it isn't exhaustive.

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?

States a specific verb and resource ('Creates a discount code (or an automatic promotion)') and immediately enumerates the discount forms it produces (percentage/fixed, order/products/shipping). This clearly distinguishes it from the sibling list_promotions, update_promotion and delete_promotion.

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

Usage Guidelines3/5

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

Provides concrete configuration recipes ('Free shipping = applies_to "shipping", percentage 100') and states that restricting to products/categories/collections scopes the discount, which implies when to use each mode. However, it never names an alternative tool or an explicit when-not condition, so usage is only implied.

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