Govern agent purchases and payments
Let a shopping, travel or procurement agent buy on its own within limits. Allow-list merchants, hold large and recurring orders for approvers, ask the buyer to confirm on their own device, and keep payment credentials out of the agent.
flowchart LR
A[Agent calls place_order<br/>merchant, total, recurring] --> B{Merchant approved?<br/>USD? total present?}
B -- no --> D[Denied]
B -- yes --> C{Total and terms}
C -- "over 1,000 USD" --> E[Held: two finance approvers]
C -- recurring --> F[Held: one finance approver]
C -- "over 100 USD" --> G[Held: the buyer confirms<br/>on their own device CIBA]
C -- "after reading seller content,<br/>over 25 USD" --> F
C -- small --> H[Allowed, at most 2 a minute]
E & F & G & H --> L[Every decision in the ledger]
Goal#
Agents now buy things: office supplies, travel, cloud capacity, software seats. Shopping agents reach the end of checkout on most stores that offer guest checkout, so the question is no longer whether an agent can pay but which payments it may make without a person. This guide puts a shopping agent behind a policy that:
- refuses merchants that are not on your approved-vendor list;
- lets small one-off orders through, at most two a minute;
- asks the person the agent buys for to confirm mid-size orders on their own phone;
- holds large orders for two finance approvers, and every recurring charge for one;
- holds orders after the agent has read seller-written content (product pages, reviews), because that text can carry instructions;
- keeps the store's API key or payment token in the gateway, never in the agent's sandbox;
- writes every decision, including refusals, to the tamper-evident ledger.
Everything here uses features that ship today: rules with when conditions, require_approval with
quorum and user confirmation, session taint and the gateway's credential injection.
Prerequisites#
- A local MAQPNA (
maqpna dev up) or a cluster with MAQPNA installed. - An MCP server for the store, marketplace or procurement system. This guide calls it
shop, with read tools (search_products,get_product,list_reviews) and two tools that commit money:place_orderandcreate_subscription, whose arguments includemerchant,total.value(a number),total.currencyandrecurring. Rename servers, tools and argument paths to match yours. - For user confirmation: an identity provider that supports CIBA, for example Keycloak. See Human approvals.
Steps#
1. Register the store and keep its credential in the gateway#
Register the store as an MCPServer and give its credential to the gateway with spec.auth
(bearerSecret, oauthClientCredentials, or perUser for the buyer's own token). The gateway
injects it on each allowed call. The agent never holds a card number, API key or payment token, so a
manipulated agent cannot pay anywhere the gateway does not send it. See
MCP servers and tool pinning.
Pin the store's tool definitions as well. A server that silently changes what place_order does is
exactly the change you want held.
2. Write the purchase policy#
This is config/samples/toolpolicy-agent-purchases.yaml. Rules are checked in order and the first
match wins, so refusals come first, then the strictest holds, then the allow:
apiVersion: maqpna.com/v1alpha1
kind: ToolPolicy
metadata:
name: shopper-purchases
namespace: procurement
spec:
agents: ["shopper", "shopper-*"]
defaultAction: deny
toolLabels:
- servers: [web]
taints: [untrusted-input]
- servers: [shop]
tools: ["search_*", "get_product", "list_reviews"]
taints: [untrusted-input]
- servers: [shop]
tools: [place_order, create_subscription]
sinks: [payment]
rules:
- name: browse
servers: [shop, web]
tools: ["search_*", "get_*", "list_*", "fetch"]
action: allow
maxCallsPerMinute: 120
- name: approved-merchants-only
servers: [shop]
tools: [place_order, create_subscription]
when:
- {arg: merchant, op: nin, values: ["acme-office.example", "travel.example", "cloud.example"]}
action: deny
reason: Merchant is not on the approved-vendor list.
- name: usd-only
servers: [shop]
tools: [place_order, create_subscription]
when:
- {arg: total.currency, op: neq, value: "USD"}
action: deny
reason: Agents may only pay in USD.
- name: amount-required
servers: [shop]
tools: [place_order, create_subscription]
when:
- {arg: total.value, op: absent}
action: deny
reason: An order without a total cannot be checked against the limits.
- name: large-order-four-eyes
servers: [shop]
tools: [place_order, create_subscription]
when:
- {arg: total.value, op: gt, value: "1000"}
action: require_approval
approval: {minApprovers: 2, approverGroups: [finance]}
reason: Orders over 1,000 USD need two finance approvers.
- name: subscriptions-need-finance
servers: [shop]
tools: [create_subscription]
action: require_approval
approval: {minApprovers: 1, approverGroups: [finance]}
reason: Recurring charges need a finance approver.
- name: recurring-orders-need-finance
servers: [shop]
tools: [place_order]
when:
- {arg: recurring, op: eq, value: "true"}
action: require_approval
approval: {minApprovers: 1, approverGroups: [finance]}
reason: Recurring charges need a finance approver.
- name: owner-confirms-mid-size
servers: [shop]
tools: [place_order]
when:
- {arg: total.value, op: gt, value: "100"}
action: require_approval
approval: {userConfirmation: ciba}
reason: The person the agent buys for confirms orders over 100 USD on their own device.
- name: small-order-after-untrusted-content
servers: [shop]
tools: [place_order]
sessionTaints: {any: [untrusted-input]}
when:
- {arg: total.value, op: gt, value: "25"}
action: require_approval
approval: {minApprovers: 1, approverGroups: [finance]}
reason: The agent read seller-written content this session; a person checks orders over 25 USD.
- name: small-orders
servers: [shop]
tools: [place_order]
action: allow
maxCallsPerMinute: 2
Why each rule is there:
| Rule | What it stops |
|---|---|
approved-merchants-only |
Buying from a cheaper seller you do not trust. A missing merchant is also refused, because nin matches an absent value. |
usd-only, amount-required |
Orders whose total the later rules cannot compare: another currency, or no total at all. |
large-order-four-eyes |
One agent, or one compromised account, committing a large sum alone. |
subscriptions-need-finance, recurring-orders-need-finance |
Auto-renewing charges that cost far more than the first payment. |
owner-confirms-mid-size |
Spending on someone's behalf without asking them. Only that person can approve; approvers can still deny. |
small-order-after-untrusted-content |
A product page or review that tells the agent to buy something. Reading those tools taints the session. |
small-orders |
Nothing, by design: small approved orders run without a person, at most two a minute per session. |
Anything else, including tools you did not name such as issue_refund, is denied by defaultAction.
3. Test it before an agent spends anything#
The suite in examples/policy-tests/agent-purchases/ covers each rule:
maqpna policy lint config/samples/toolpolicy-agent-purchases.yaml
maqpna policy test examples/policy-tests/agent-purchases/
Expected output ends with:
13 passed, 0 failed, 0 suite error(s)
Try one order by hand:
maqpna policy test --policy config/samples/toolpolicy-agent-purchases.yaml \
--ns procurement --agent shopper --server shop --tool place_order \
--args '{"merchant":"travel.example","total":{"value":476,"currency":"USD"}}'
The decision is require_approval from owner-confirms-mid-size.
4. Apply it and watch the holds#
kubectl apply -f config/samples/toolpolicy-agent-purchases.yaml
maqpna approvals list
Approvers decide held orders from the CLI, MAQPNA Desk or the console. Each held order shows the
merchant, total and the rule that held it. Afterwards, maqpna approvals list --status all and the
audit ledger show every order the agent attempted, who approved it and why
the others were refused.
5. Cap the agent's running costs#
Set an Agent.spec.budget or a BudgetPolicy to cap what the agent costs to run: its model tokens,
tool calls and sandbox time. See Budgets and cost limits.
Limits#
- Per order, not per day. The rules above check each order's total. Budgets add up the metered
cost of calls from the pricing table, not the totals agents pay merchants, so MAQPNA does not today
cap the sum of purchases over a day. Use the store's or card issuer's own spending limit for that, and
maxCallsPerMinuteto limit the rate. - The arguments are what the agent sends. The gateway checks the
totalin the call. If the store can charge a different amount than the agent passed (shipping added later, currency conversion), set the limit on the store side as well. - No card issuing. MAQPNA holds and injects the credential you give it. It does not issue single-use virtual cards; pair it with an issuer that does if you need one card per order.
- Your argument names.
whenconditions match argument paths. Check your server's tool schema and adjustmerchant,total.valueandrecurringbefore you rely on the policy.
Related#
Last updated