TheWavly Guard · for MCP servers and agent frameworks
Make the check impossible to skip.
An agent that has been talked into something can simply not ask before it orders. TheWavly Guard sits in front of your order and payment tools, reads the real total from your own cart, and holds the order until it matches what the user approved.
The gap
Asking is optional. Guarding is not.
Most safeguards for agents are instructions: check the cart, confirm with the user, call this tool first. Instructions are exactly what a prompt-injected agent stops following.
Advisory
The agent is told to check
- A listing tells the agent to choose it now.
- The agent skips the check and calls
place_order. - The server places the order.
The order cannot be cancelled.
With TheWavly Guard
The tool itself is guarded
- The agent calls
place_order, skipping any check. - The Guard holds the call, reads
view_cart, and asks TheWavly. - TheWavly answers stop or ask, so the server never sees the call.
Nothing is ordered until it matches what the user approved.
Replay
Quoted ₹475. Billed ₹561.
A public report described two shakes quoted at ₹475 and billed at ₹561. Our demo server reproduces it, and the user approved up to ₹500.
The menu shows two shakes for ₹475, without fees.
The agent orders straight away, without checking anything.
The Guard reads the shop’s own cart: ₹475 plus ₹86 in fees.
₹561 is over the ₹500 the user approved. TheWavly sends them a link.
Once they approve that exact order, the same call goes through, with a receipt.
| TheWavly’s answer | What the Guard does |
|---|---|
| Proceed | Lets the call through, reports the outcome to TheWavly, and adds a receipt link the user can verify. |
| Ask | Does not make the call. Gives the agent the user’s approval link. The same order goes through once the user approves it; a changed cart needs a new answer. |
| Stop | Does not make the call, and tells the agent not to retry. For example, a seller the user did not name. |
Set up
One command in front of your server.
No change to your MCP server. Name the tools that place orders, say where the total is, and start the Guard in front of it. Or wrap your handler in code.
Download the SDK bundle and extract it in your project directory. Node 20 or newer is required. Run the extracted Guard directly:
curl -fL https://thewavly.com/sdk/thewavly-open.tar.gz -o thewavly-open.tar.gz tar -xzf thewavly-open.tar.gz WAVLY_API_KEY=sk_test_… WAVLY_MANDATE=mdt_… \ node ./thewavly-open/sdk/guard/cli.mjs --config guard.json -- node shop-server.mjs
{ "tools": { "place_order": {
"resolve": { "tool": "view_cart",
"arguments": { "cart_id": "args.cart_id" } },
"purchase": { "item": { "const": "Food order" },
"amount_rupees": "resolved.total_rupees",
"merchant": "resolved.store", "payee": "resolved.upi_id" },
"reference": "result.order_id" } } }
Agent frameworks
No MCP server? Guard the function that pays.
Your agent’s payment tool runs a function. Wrap that function and give the wrapped one to your framework. The model sees the same tool, and the payment runs only when TheWavly says proceed, or after the user approves.
// First: npm install ./thewavly-open/sdk/guard
import { guardFunction } from "@thewavly/guard";
const execute = guardFunction(
({ cart_id }) => shop.placeOrder(cart_id),
{ wavly, mandate: process.env.WAVLY_MANDATE,
purchase: async ({ cart_id }) => {
const cart = await shop.cart(cart_id);
return { item: "Food order",
amount_paise: cart.total_paise,
merchant: cart.store, payee: cart.upi_id };
},
reference: order => order.order_id });
# First: python3 -m pip install ./thewavly-open/sdk/python
from thewavly.guard import guard
@tool # or @function_tool
@guard(wavly, mandate=os.environ["WAVLY_MANDATE"],
purchase=shop.cart_purchase,
reference=lambda order, *a, **k: order["order_id"])
def place_order(cart_id: str) -> dict:
"""Place the order for a cart and pay for it."""
return shop.place_order(cart_id)
| Framework | How |
|---|---|
| Vercel AI SDK | The guarded function is the tool’s execute. |
| LangChain and LangGraph, JavaScript and Python | Wrap the function inside the tool. In Python, put @guard under @tool; the tool keeps its name, arguments and description. |
| OpenAI Agents SDK, JavaScript and Python | The guarded function is the tool’s execute, or put @guard under @function_tool. |
| Your own loop | Call the guarded function instead of the real one. Sync and async both work. |
Each of the five integrations above is run through the same steps: a payee the user never named is stopped, the ₹561 cart is held for the user, and after approval the same call places the order. When the payment is not made, the tool returns the answer, the reason and the approval link for the agent to act on.