Skip to content
Ahmad Raza
Menu
All posts

4 min read

Confirm-Then-Execute for Purchases, Refunds, and Cancels

A practical confirm-then-execute pattern for MCP purchases, refunds, and cancels: human approval for money moves, tied to tool scoping and clear audit trails.

Confirm-Then-Execute for Purchases, Refunds, and Cancels
On this page

Confirm-then-execute is the pattern I use whenever an AI agent wants to move money through an MCP server. The agent prepares the action, a human confirms it, and only then does the server execute. It sounds simple, and it is, but the details decide whether it actually protects you or just adds a click.

In this post I will cover how to split money tools into prepare and execute steps, what a good confirmation looks like, and how this ties into tool scoping.

Why money moves need a human step

Purchases, refunds, and cancellations share three traits: they affect real money, they are hard or impossible to undo cleanly, and mistakes reach customers directly.

Agents are good at gathering details and filling forms. They are also capable of misreading a request, acting on stale information, or being steered by text in a product page or email. A confirmation step puts a person between the agent's plan and the irreversible action. It is the single most effective control for high stakes tools.

Split every money tool in two

Instead of one tool that does everything, expose two:

  1. Prepare. The agent calls something like checkout_prepare, refund_prepare, or cancel_prepare. The server validates the arguments, calculates totals, checks caps, and stores a pending action. It returns a summary and a confirmation id. Nothing is charged or changed.
  2. Execute. The action runs only when *_execute is called with that confirmation id and a valid approval from a human.
const pending = await refund_prepare({
  orderId: "ORD-10422",
  lineItems: [{ sku: "SKU-88231", qty: 1 }],
  reason: "damaged_on_arrival"
});
// pending.summary -> shown to a person
// pending.confirmationId -> used after approval

The key detail: the agent alone cannot satisfy the execute step. Approval comes through a channel the agent does not control, such as a button in your admin, a push notification to the shopper, or a signed approval token issued after the human clicks confirm.

What a good confirmation shows

A confirmation is only useful if the person can actually judge it. I include:

  • Exactly what will happen, in plain words: "Refund 1 x Trail Boot, size 42, to the original card."
  • The amount and currency, including tax and shipping adjustments.
  • Who requested it, meaning the agent name and the shopper or staff member involved.
  • What it is based on, such as the order id and the reason code.
  • An expiry, so stale confirmations cannot be approved hours later.

Avoid showing raw JSON or internal ids only. If a person cannot understand the summary in a few seconds, they will approve without reading, and the control is gone.

Bind the approval to the exact action

The approval must match the prepared action precisely. If anything changes between prepare and execute, the approval should be void.

  • Store a hash of the prepared parameters with the pending action.
  • Execute only if the stored parameters still match and the approval references that hash.
  • Expire pending actions after a short window.
  • Allow each confirmation id to execute once.

This stops a subtle attack where an agent gets approval for a small refund and then executes a larger one using the same id.

Who confirms what

Not every action needs the same approver. A simple matrix works well:

Action Typical approver
Shopper purchase via their own agent The shopper
Refund below a set threshold Support staff member
Refund above threshold Senior staff or manager
Order cancellation before fulfillment Shopper or staff
Bulk actions Always a staff member, never automatic

Thresholds come from your business, not from me. The point is to write them down and enforce them in the server.

Tie it to tool scoping

Confirm-then-execute works best when combined with least privilege tool scopes:

  • Most agents get prepare scopes only. They can propose but never execute.
  • Execute scopes are held by your approval service, not by the agent integration.
  • Read tools stay separate from write tools, so a catalog agent never even sees refund tools.

With this split, a compromised or confused agent can at worst create pending actions that a person will reject. It cannot move money on its own.

Combine this with caps from the previous post. Below a small threshold, you might allow auto approval for low risk actions like cancelling an unpaid order. Above it, a person always confirms. Make those thresholds per integration so you can trust established agents more over time.

Log both halves

Every prepare and every execute should produce a log entry with the agent id, the shopper or staff id, the arguments, the decision, and the result. When someone asks why a refund happened, you want to answer with the full story: which agent proposed it, who approved it, when, and what was returned.

Common pitfalls

  • Letting the agent relay the approval. If the agent can say "the user approved" and the server believes it, there is no real confirmation.
  • Vague summaries. "Process refund?" tells the approver nothing.
  • No expiry. Old pending actions become a quiet backlog of risk.
  • Approving parameters loosely. Always bind approval to exact values.
  • One giant tool. If prepare and execute are the same call, you cannot insert a human step.

Wrapping up

Confirm-then-execute turns agent money moves into proposals that people approve. Split tools into prepare and execute, show clear summaries, bind approvals to exact parameters, and keep execute scopes away from agents. It adds little friction for legitimate work and removes a whole category of expensive mistakes.

If you want this pattern built into your Next.js eCommerce checkout, MCP server, or AI support agent, I would be glad to help. Reach me through my contact section or at ahmadraza365pro@gmail.com.

  • 5 min read

    A 30-Day Agentic Commerce Rollout for a Next.js Store

    A practical, week by week plan to make a Next.js store ready for AI shopping agents: clean the data, ship a read only catalog MCP server, add carts, hand off to confirmed checkout, then log and cap everything.

  • 5 min read

    Fraud and Abuse When Agents Shop Your Checkout

    AI shopping agents look a lot like bots, and bots look a lot like agents. Here is how to tell them apart, where to put bot challenges, and why hosted checkout like Shop Pay is your best trust boundary.

  • 4 min read

    Hydrogen SDK vs Calling Storefront API Yourself in 2026

    Shopify's Hydrogen SDK now reaches beyond Remix and React Router into other frameworks. Here is what it gives you for agent ready storefronts, what a thin Next.js client gives you, and when each one pays off.