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
Pick a minimum payment that covers several calls (e.g., 10× your tool’s per-call price) to reduce prompts without overcharging.
How it works
- You set
minimumPayment
in theatxpExpress
middleware. - Each tool still calls
requirePayment({ price })
for its per-call charge. - On the first call, the user pays the larger of
minimumPayment
andprice
. - Subsequent calls deduct
price
from 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
Ensure
minimumPayment
is a BigNumber
instance. If you pass a number, amounts may be imprecise.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
To persist balances across restarts or scale-out, configure an OAuth database in
atxpExpress
(SQLite or Redis).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.