Skip to main content
Glama

Create a coupon

wp_wc_create_coupon

WooCommerce: create a published coupon with a new, unused code, an amount, a discount type and an optional expiry date. Everything is checked before the coupon exists: a code already in use, an unknown discount type or an impossible date is refused. Returns created, id and the code as WooCommerce stores it (normally lower-cased). A repeated call with the same code after the first has finished is refused, since the code is then in use; two calls that overlap (a retry while the first still runs) are not guarded against and can create two coupons. wp_wc_list_coupons lists the existing coupons; changing or deleting one is done in WooCommerce. Needs manage_woocommerce. Requires WooCommerce. Forwarded by AlphaBridge Connect to the one site this connection reaches.

Input Schema

NameRequiredDescriptionDefault
codeYesCoupon code customers enter. WooCommerce normalises it (sanitised, lower-cased); a backslash is refused.
amountYesA number of at least 0: a percentage or an amount in shop currency, depending on discount_type. WooCommerce refuses a percentage over 100.
expiresNoExpiry date, YYYY-MM-DD. Omitted: the coupon does not expire.
discount_typeNopercent, fixed_cart or fixed_product. Default percent.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changed
    • changedInput schema / properties / amount / description
      Previous value: -"A number of at least 0: a percentage or an amount in shop currency, depending on discount_type."New value: +"A number of at least 0: a percentage or an amount in shop currency, depending on discount_type. WooCommerce refuses a percentage over 100."
    • addedInput schema / properties / code / description
      Added value: +"Coupon code customers enter. WooCommerce normalises it (sanitised, lower-cased); a backslash is refused."
    • changedInput schema / properties / expires / description
      Previous value: -"YYYY-MM-DD."New value: +"Expiry date, YYYY-MM-DD. Omitted: the coupon does not expire."
  2. Added

TDQS

A4.4/5.0
Behavior5/5

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

Goes well beyond the annotations: pre-flight validation (duplicate code, unknown discount type, impossible date all refused), the returned fields, that the code comes back lower-cased, and an unusually precise disclosure of the idempotency gap (a sequential retry is refused, an overlapping retry can create two coupons) — which sharpens rather than contradicts idempotentHint=false. Auth requirement (manage_woocommerce) is also stated.

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 purpose, then validation, then return values, then the concurrency caveat, then routing and prerequisites — a sensible information order with no filler sentences. It is on the long side for a four-parameter tool, but every clause carries distinct information.

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 mutation tool with no output schema, the description supplies the return shape, the failure modes, the auth prerequisite and the concurrency risk. Nothing an agent needs to call this correctly and interpret the result is missing.

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 coverage is 100% and every parameter already carries a description covering format, defaults and constraints, so the schema does the heavy lifting. The description restates the parameter set ('an amount, a discount type and an optional expiry date') without adding syntax or edge-case meaning beyond the schema. Baseline 3 applies.

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?

Opens with a specific verb and resource plus the exact scope: 'create a published coupon with a new, unused code, an amount, a discount type and an optional expiry date'. It is unambiguously distinguished from the read-side sibling wp_wc_list_coupons, which it names.

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?

Explicitly routes reads to wp_wc_list_coupons and states that changing or deleting a coupon happens in WooCommerce (i.e. there is no sibling update/delete tool), and lists prerequisites (manage_woocommerce, WooCommerce). It stops short of a full when-to-use/when-not decision matrix, but the alternatives are named.

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