Cancel and refund
Cancel a subscription and refund the most recent payment in one tool call.
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"
}
}
| Argument | Meaning |
|---|---|
subscription_id | The subscription to cancel. |
refund_amount | null for full refund of the most recent order; integer for partial. |
refund_reason | requested_by_customer, duplicate, fraudulent, or your own free-form string. |
at_period_end | false revokes access immediately; true lets the customer keep access through the period. |
idempotency_key | Use a stable id (e.g. ticket number) so a double-click doesn’t double-refund. |
What happens internally
EPD locates the latest paid order for the subscription.
Issues a refund equal to refund_amount (or full).
Honors at_period_end.
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.