Overview
Batch payments let your users pre-pay a larger amount once and draw down across multiple tool calls. You configure a minimum upfront charge and continue to require a per-call price; the middleware handles balance tracking so users are not prompted on every call.When to use batch payments
- If your tool is called repeatedly in a workflow and per-call prompts are disruptive
- If you want to reduce payment-approval friction while keeping per-call pricing
- If you want to amortize network fees over several calls
How it works
- You set
minimumPaymentin theatxpExpressmiddleware. - Each tool still calls
requirePayment({ price })for its per-call charge. - On the first call, the user pays the larger of
minimumPaymentandprice. - Subsequent calls deduct
pricefrom the remaining balance until depleted.
Prerequisites
- ATXP account and connection string
- Existing Express-based MCP server using the ATXP Express SDK.
1
Install dependencies
2
Configure server with minimumPayment
Add
minimumPayment to your ATXP middleware and keep per-call pricing with requirePayment.server.ts
3
Client behavior and approval
The first tool call will request the larger amount. You can implement approval logic to auto‑approve reasonable prepayments.
client.ts
4
Verify batch behavior
- First call prompts for the larger
minimumPayment(e.g., $0.50) - Next several calls are not prompted until the prepaid balance is depleted
- Once depleted, the next call will prompt again for at least
minimumPayment
You should see only a single payment approval across multiple calls, then another prompt once the balance runs out.