What you’ll build

A support-agent action: a customer asks to cancel and get their last month back. Done in one MCP call.

The call

Use refund_and_cancel (a composite tool).

{
  "name": "refund_and_cancel",
  "arguments": {
    "subscription_id": "6ba7b812-9dad-11d1-80b4-00c04fd430c8",
    "refund_amount": null,
    "refund_reason": "requested_by_customer",
    "at_period_end": false,
    "metadata": { "support_ticket": "ZD-4471" },
    "idempotency_key": "support-cancel-ZD-4471"
  }
}
ArgumentMeaning
subscription_idThe subscription to cancel.
refund_amountnull for full refund of the most recent order; integer for partial.
refund_reasonrequested_by_customer, duplicate, fraudulent, or your own free-form string.
at_period_endfalse revokes access immediately; true lets the customer keep access through the period.
idempotency_keyUse a stable id (e.g. ticket number) so a double-click doesn’t double-refund.

What happens internally

Find the most recent paid order

EPD locates the latest paid order for the subscription.

Refund it

Issues a refund equal to refund_amount (or full).

Cancel the subscription

Honors at_period_end.

Return a summary

Refund id, refund amount, subscription status, and any errors.

Need a billing summary too?

Use cancel_subscription_and_report instead — it cancels and returns lifetime billing totals (great for confirmation emails) but does not issue a refund. Compose with refund_and_cancel if you want both.

This tool has destructiveHint: true. A well-built MCP client should require human confirmation before calling it in live mode — refunds cannot be undone.