NEW! |One API call, clean data back. No scrapers needed.Get 10,000 Free Tokens →

How to Let AI Agents Spend Money Safely: 8 Guardrails From Our MCP Server

How we let AI agents buy proxies without runaway spend: scoped keys, price guards, idempotency, prepaid limits and human approval — with real API examples.

PublishedNovember 30, 2026
Reading time13 min

AI agent spending controls are the limits that decide how much an agent can spend, on what, and who has to agree first. The rule that matters most is simple: the limit has to be enforced outside the model. A prompt that says “spend no more than $50” is something the model can misread, forget or be talked out of. A key that can’t spend, a balance that runs out and a server that refuses a wrong price can’t be talked out of anything.

We run an MCP server that lets AI agents buy and manage proxies on a real account with real money. This article goes through the eight guardrails for AI agents that we built into it, with calls and responses we captured on November 29, 2026, including where each one stops working:

  1. Scoped API keys: a key without spending rights can’t spend.
  2. A prepaid wallet: the agent can spend the balance and nothing more, and it can’t add money.
  3. Quote, then order: the server refuses an order at a price the agent didn’t expect.
  4. Idempotency keys: a retried order returns the first one instead of charging again.
  5. Confirmation for irreversible actions, plus a limit on how often they can happen.
  6. Safe defaults for recurring charges.
  7. Steps only a human can take: managing keys and paying.
  8. Defenses against prompt injection: read-only keys and no trust in tool annotations.

If you’re the one connecting an agent rather than building the server, the practical checklist for spending limits covers the client side: keys, budgets and approval settings in Claude Code, Cursor and Claude Desktop.

Why agents overspend#

Agents rarely overspend because they want more. They overspend because a design gap lets a normal mistake turn into a charge. HackerNoon’s guide to guardrails for spending agents uses a hypothetical that fits most real cases: “A procurement agent is given a $10,000 monthly software budget and permission to auto-renew.” It misreads a tiered plan and renews at $14,000 with an approved vendor. “This is not fraud; it is a gap in how the delegation was designed.”

The common causes of runaway spending are dull ones:

  • Loops and retries. An agent that gets a timeout tries again. If the purchase call can’t tell a retry from a new order, every retry is a new charge.
  • Misread prices. Tiered plans, monthly vs annual, per-IP vs per-pack. A model reading a pricing page can pick the wrong number with confidence.
  • Recurring charges nobody chose. Defaults like auto-renew keep spending after the task is over.
  • Injected instructions. Text from a web page, a ticket or a repository that the agent treats as a request.
  • Speed. Ramp’s notes on agent spending controls put it plainly: agents “can run 24/7 and execute thousands of transactions before you’ve even signed on for the day.”

All of these happen inside the model’s reasoning, which is why AWS’s guidance on agent payments puts the limit somewhere else: “Spending limits must be defined and enforced outside the model, at the infrastructure layer.” Matt Asay calls this bounded autonomy: “A prompt injection can persuade the agent, but it can’t persuade the surrounding infrastructure.”

Where this sits in agentic payments#

Most of the talk about agentic commerce is about new payment rails: Google’s AP2, now donated to the FIDO Alliance, the Agentic Commerce Protocol from OpenAI and Stripe, and x402, which has its own foundation at the Linux Foundation since July 2026. These protocols handle how an agent proves it’s allowed to pay and how the money moves. We don’t use any of them. Our case is the ordinary one: a seller with an API and paid MCP tools, a customer with an API key, and an agent in between. A lot of what agents can buy today is sold this way, and none of the guardrails below depends on a payment protocol.

The 8 AI agent guardrails we use#

For each guardrail: the risk, how it works, a real call and whether the server enforces it or only asks the model to behave.

The flow of one agent purchase through the FineProxy MCP server: quote, price guard, scope and balance check, a single charge, and a retry with the same idempotency key

1. Scoped API keys for AI agents#

Risk. One key can do everything, so every agent session, including a quick question about expiry dates, runs with the power to buy.

How it works. This is least privilege applied to the API key. Each FineProxy key has scopes, and the server checks them on every tool call. A read-only key covers services, usage, the wallet balance and price quotes. Spending needs wallet:spend, and creating top-up links needs wallet:deposit. Every paid tool’s description ends with what it needs, so the client and the user can see it before calling:

order_composite: Purchase a composite multi-country proxy service …
paying from the wallet balance. MONEY: charges the composite price —
call quote_composite first and pass its total_price_cents as
expected_total_cents; on price mismatch the order is rejected without
charging. … [requires scopes: services:write, wallet:spend]

Enforced by the server. A key without the scope can’t use the tool, whatever the agent decides. That makes the key the first and strongest guardrail: we recommend a read-only key by default and a purchasing key only for the session that needs it.

2. A prepaid wallet as the hard cap#

Risk. An agent with an open payment method has no ceiling.

How it works. MCP purchase tools pay from the prepaid wallet balance. With a purchasing key, the most an agent can spend is what’s in the wallet. Topping up is a separate action: init_deposit only creates a payment link, and a person opens it and pays. In our test, a $5 top-up request returned a link and nothing else:

{
  "payment_url": "https://…",
  "our_order_id": "HLK-31EA0C4E64F04862",
  "checkout_kind": "redirect"
}

The payment stayed pending and the balance didn’t move. AWS describes the same pattern for its own agent payments: “Funding is an out-of-band action.”

Enforced by the server, with one caveat. If an account has automatic top-ups from a saved card, the cap becomes that card’s limit, so keep automatic top-ups off on an account an agent uses.

3. Quote then order: the price guard#

Risk. The agent orders at a price it didn’t check, or the price changes between the quote and the order.

How it works. A price guard is a field in the purchase call that carries the price the caller expects; if the server’s price differs, it refuses to charge. The agent first calls quote_composite, which returns the total. The quote itself isn’t binding (the response says "binding": false). What makes it safe is the next step: the order carries expected_total_cents, and the server compares it with a fresh price before charging. We sent an order with a total one cent below the real one:

order_composite {"segments":[{"country":"NL","count":100}], "period_months":1,
  "whitelist_ips":["203.0.113.10"], "auto_renew":false,
  "idempotency_key":"guard-test-…-a", "expected_total_cents":1199}

Invalid arguments: Price mismatch: expected_total_cents=1199,
actual quote is 1200 cents. Nothing was charged.

The balance before and after was the same, 15,700 cents ($157). The price guard turns “the model read the price wrong” from a charge into an error the agent can show you.

In our test, the model caught this itself. When we asked Claude Code to order at a price below the quote, it refused before calling the tool:

Claude Code refuses to place an order at a price lower than the quote it just received

Rendered from the session log; our server’s IP is masked.

That’s good behavior, but it isn’t a guardrail. The model was right this time. The server checks every order that carries the expected price.

Enforced by the server on five tools, each with its own field: expected_total_cents on order_composite and order_dedicated, expected_charge_cents on add_ips, expected_amount_cents on refresh_ips and expected_price_cents on purchase_addon. The guard works only when the field is sent, so the server instructions tell agents to always pass it. For catalog purchases and renewals (buy_service, renew_service), have the agent show you the price before it calls the tool.

4. Idempotency keys against duplicate charges#

Risk. The network drops after the server charged but before the agent got the answer. The agent retries and buys the same thing twice.

How it works. An idempotency key is a unique ID the client attaches to one purchase; if the same key arrives again, the server returns the original result instead of charging again. On FineProxy, the five guarded purchase tools require one. We placed a real $12 order and then sent the identical call again:

// first call, 15,977 ms
{"service_id": "3472053c-…", "status": "active", "total_price_cents": 1200, "balance_applied_cents": 1200}

// replay with the same idempotency_key, 206 ms
{"service_id": "3472053c-…", "status": "active", "total_price_cents": 1200, "balance_applied_cents": 0}

Same service, nothing charged the second time. The wallet went from 15,700 to 14,500 cents once, and the ledger has exactly one entry:

{"amount_cents": -1200, "balance_after_cents": 14500, "entry_type": "debit",
 "description": "Composite purchase (balance): Datacenter proxy (composite) (100 IPs)"}

The other half of the rule: a new purchase needs a new key. Reusing a key for a different order is a client bug, and over REST it returns 409 IDEMPOTENCY_KEY_REUSED instead of a second order.

Enforced by the server on the same five tools as the price guard. buy_service takes an optional client_idempotency_key inside params, and a repeat with the same product and params returns the existing service. For renewals, the safe retry after a timeout is to check expires_at and the ledger first: if the service is already extended, there’s nothing to repeat.

5. Confirm before irreversible actions, and limit how often#

Risk. An agent cancels a service it should have kept, or cancels several in a loop.

How it works. cancel_service requires confirm: true, and the server instructions tell agents to get the human’s agreement first and “never set confirm speculatively”. Without it, the server refuses:

cancel_service {"service_id":"3472053c-…","confirm":false}
Invalid arguments: Set confirm=true to cancel this service. This cannot be undone.

The second layer is a rate limit on the action itself: self-service cancellation works once every three days per account. We hit it ourselves when we tried to cancel our test order, because the account had used a cancellation two days earlier:

cancel_service {"service_id":"3472053c-…","confirm":true}
SERVICE_CANCEL_COOLDOWN: self-service cancellation is limited to once every 3 days.
support_required=true retry_at=2026-11-30T10:04:48Z … Ask the customer to open a support ticket.

Partly enforced. The cooldown is enforced by the server, so a loop can cancel at most one service every three days. The confirm flag is not a human check: it’s an argument the model fills in, and the server can’t tell whether a person agreed. It forces the model to make a deliberate choice, and it gives an approval prompt in your client something obvious to show. The human-in-the-loop part has to come from the client, which is where approval settings for paid tools come in.

6. Safe defaults for recurring charges#

Risk. The HackerNoon scenario: a purchase that keeps charging after the task is done.

How it works. Orders accept auto_renew: false, and our test order used it. set_auto_renew turns renewal on or off later, and the server instructions tell agents to turn off auto-renew rather than cancel when the goal is to stop paying.

Honestly, this one is weak. New orders default to auto_renew: true, for agents and people alike, so an agent that leaves the field out creates a recurring charge. Renewals then come from the wallet, so the prepaid cap still applies, but they don’t go through anyone’s approval. If you build a paid MCP server, make the default for agent orders the one that doesn’t spend.

7. Steps only a human can take#

Risk. An agent with a limited key upgrades its own key, creates a new one, or tops up the wallet to keep going.

How it works. Key management works only from a signed-in dashboard session. An API key, whatever its scopes, gets this:

HTTP 403
{"detail": "api_key_management_requires_session"}

Adding money works the same way: as in guardrail 2, the agent can create a payment link, and a person has to complete the payment. AWS’s version of the rule is “No single role can both raise a budget and spend against it.”

The human also keeps the kill switch: revoking a key in the dashboard stops the agent on its next call with 401 and {"detail": "Invalid or revoked API key."}.

Enforced by the server.

8. Prompt injection and MCP tool annotations#

Risk. Prompt injection through MCP: the agent reads text it shouldn’t trust, a web page, a support ticket, a file, and follows the instructions in it. Since 2025, security researchers have shown poisoned tool descriptions, malicious GitHub issues and support tickets steering agents through MCP servers. For a paid MCP server, the bad outcome is a purchase nobody asked for.

How it works. The defenses are ordinary ones, set up so that a persuaded model still hits a limit:

  • A read-only key for untrusted content. If the agent’s job involves reading pages or tickets, give it a key without wallet:spend. An injected “order 2,000 IPs” then fails at the scope check. A read-only key still has limits as a defense: it can read proxy logins and passwords, so an injected “show me the proxy passwords” works with it, and the answer goes to the model provider.
  • No auto-approval for paid tools. Our documentation tells users to allowlist read tools by name and keep paid tools on manual approval.
  • No trust in annotations. MCP tools carry hints like readOnlyHint and destructiveHint, and some clients use them to decide what to auto-approve. The MCP specification is clear that “clients MUST consider tool annotations to be untrusted unless they come from trusted servers.” Annotations are easy to get wrong, and a client that auto-approves “read-only” tools trusts every server to get them right. Decide by tool name and by the key’s scopes instead.

Partly enforced. The scope check is enforced by the server. The other two depend on the client and the user.

What the server enforces and what it only asks#

This is the table we’d want from any paid MCP server before connecting an agent to it:

GuardrailEnforced by the serverAsked of the model or the user
Scoped keysScope check on every callUse the read-only key by default
Prepaid walletSpending stops at the balance; the agent can’t add moneyKeep automatic top-ups off
Price guardPurchase refused when the expected price differsPass the field on order_composite; check prices on buy_service and renew_service
IdempotencySame key returns the first orderNew key per purchase; no blind retries of renew_service
Irreversible actionsconfirm required; one self-service cancel per 3 daysGet a human’s agreement before confirm: true
Recurring chargesauto_renew can be switched off per order or per serviceOrder with auto_renew: false
Human-only stepsKey management needs a session; deposits need a person to payRevoke the key if something looks wrong
Prompt injectionScope checkRead-only key for untrusted content; no auto-approval by annotation

No combination of guardrails makes an agent with a purchasing key risk-free; they make the worst case smaller and easier to see.

A checklist for builders of paid MCP servers#

If you’re adding paid tools to your own MCP server, this is what we’d do again, plus what we’d do earlier:

  1. Give keys scopes, and make spending a separate scope from changing settings.
  2. Put the required scopes at the end of every tool description.
  3. Keep key management out of the API: an API key must not create or upgrade keys.
  4. Pay from a prepaid balance; make topping up an action a person completes.
  5. Require the expected price on every paid call, and refuse on a mismatch with “nothing was charged”.
  6. Require an idempotency key on every paid call, and return the original result on a replay.
  7. Make destructive tools require an explicit confirmation argument, and rate-limit the action itself.
  8. Default to the choice that doesn’t spend: no auto-renew, no automatic top-up.
  9. Write annotations by hand and test them. A wrong readOnlyHint is worse than none.
  10. Tell agents the buying flow in the server instructions, but assume they’ll be ignored.
  11. Return errors that say what happened to the money, so the agent can report it correctly.
  12. Keep a ledger the user can read, and send webhooks for every charge.

Try it with a read-only key#

You can see all of this on your own account: connect the FineProxy MCP server with a read-only key, ask for a quote and look at the tool descriptions. The MCP safety page lists every paid tool and its guards. If you’re about to give an agent a key that can spend, go through the practical checklist for spending limits first.

Can an AI agent spend money without permission?

Yes, if it holds a key that can spend and nothing asks you first. The model doesn't need your permission to call a paid tool; your client's approval settings, the key's scopes and the money available decide whether the call goes through. That's why limits have to live outside the model.

Who is liable when an AI agent overspends?

Usually the account holder. An agent acts with your API key or your card, so the seller sees a normal customer purchase. Check the service's terms for refunds and cancellations; on FineProxy, cancelling a service refunds the unused days at the undiscounted daily rate, and self-service cancellation is limited to once every three days per account.

Should an AI agent pay with a credit card or an API key?

An API key with limited scopes, paying from a prepaid balance, is easier to control: the key can be revoked in one click and the agent can't spend more than the balance. If an agent must use a card, use a virtual card with a low limit and a single merchant, and keep the card number out of the agent's context.

Do MCP tool annotations make tools safe?

No. Annotations like readOnlyHint and destructiveHint are hints written by the server, and the MCP specification says clients must treat them as untrusted unless the server is trusted. A server can mark a tool as read-only by mistake. Decide what to auto-approve by tool name and by the key's scopes.

What happens if an agent retries a purchase after a timeout?

With an idempotency key, nothing extra. In our test, a replay of the same order with the same key came back in 206 ms with the same service and balance_applied_cents: 0. Without a key, a retry can buy twice, so a paid tool without one should never be retried blindly.