Examples
MCP gateway example
An ordinary MCP tool server for a fake payments API (payments-server.ts),
with the Riskbound gateway in front of it. The tool server has no Riskbound
code. The only change is in the MCP client's config: it starts the gateway,
and the gateway starts the tool server.
MCP client --stdio--> gateway --stdio--> payments-server.ts
|
+--> Riskbound: allow, ask a human, or blockgateway.json says how:
upstreamstarts the tool server and hands itPAYMENTS_API_KEY. The agent never holds that credential.readOnlyToolsletslist_ordersthrough without a check.tools.refund_paymentchecks the tool under the policy namerefundand copiesamount_centsinto theamount_minorparam the policy reads.
Run it#
Start the local stack and get a gateway key first: see ../README.md.
Build the SDK and the gateway once, from the repo root:
cd sdk && npm install && npm run build && cd ..
cd gateway && npm install && npm run build && cd ..Then, from this folder. client.ts plays the part of the agent's MCP
client:
cd examples/mcp-gateway
npm install
PAYMENTS_API_KEY=demo RISKBOUND_API_KEY=$RISKBOUND_GATEWAY_KEY npm startYou see:
[riskbound-gateway] ready: agent "support-bot", upstream "node"
Tools the agent sees: [ 'list_orders', 'refund_payment' ]
Lookup (read-only, not checked): cus_42: ord_1001, ord_1002, ord_1003
$40 refund: Refunded 40.00 USD on ord_1001
$900 refund: refused - Riskbound blocked this action (refund-hard-cap). The tool was not called.To see a refund wait for a person, run this and approve it as
../README.md shows:
ASK_FOR_APPROVAL=1 PAYMENTS_API_KEY=demo RISKBOUND_API_KEY=$RISKBOUND_GATEWAY_KEY npm startUse it from a real MCP client#
Point the client at the gateway instead of the tool server. For Claude Desktop, Cursor and most clients, the server entry looks like this. Use absolute paths:
{
"mcpServers": {
"payments": {
"command": "node",
"args": [
"/path/to/riskbound/gateway/dist/main.js",
"--config",
"/path/to/riskbound/examples/mcp-gateway/gateway.json"
],
"env": { "RISKBOUND_API_KEY": "rb_gateway_...", "PAYMENTS_API_KEY": "demo" }
}
}
}gateway.json starts the tool server with a relative path, which works when
the gateway runs from this folder, as client.ts does. A client may start it
from anywhere, so in a copy for a real client add
"cwd": "/path/to/riskbound/examples/mcp-gateway" to upstream.
More about the gateway, including HTTP mode for remote agents, is in
../../gateway/README.md.