Inspiration
AI agents can now spend money. PayPal's MCP server gives any MCP-capable agent (Claude Desktop, Cursor, a LangChain or Vercel AI SDK app) tools to create orders, send invoices and issue refunds. But nothing sits between the agent's decision and the money moving. An agent that misreads its instructions, gets talked into an upsell, or reads a web page with hidden instructions in it will simply pay, and nobody finds out until the statement arrives. We wanted the missing checkpoint: something that lets agents act, while every payment still answers to the person who authorised it.
What it does
Interlock is a transparent MCP proxy. The agent's MCP config points at Interlock instead of PayPal; Interlock re-exposes all 28 PayPal tools under their real names and schemas, so the agent is not modified and cannot tell it is being governed.
The person sets a mandate in plain words ("Book a hotel near the conference venue, under $200 a night") plus hard caps. Every money-moving call then passes three gates:
- Policy: deterministic code. Single and total caps, expiry, blocklists, plus rules we added after attacking our own system:
split_payment(one purchase split into smaller payments),after_refusal(a retry straight after a refusal),confusable_payee(lookalike or invisible characters in a payee) andamount_unknown(an unreadable amount is never treated as $0). - Intent: a model compares the actual items, amount and payee with the mandate's wording and explains any mismatch in one plain sentence.
- Injection: every page the agent read through Interlock is scanned for text aimed at the agent rather than a person.
Clear payments go through untouched. Suspicious ones are held mid-flight: the agent's tool call stays open while a person sees the payment in a console, with rule-specific evidence (the earlier payments in a split, the refusal just before a retry, the lookalike character highlighted in place) and a live countdown. Approve, and the original call resumes and returns PayPal's real response. Decline, and the agent gets a refusal it understands. Every decision lands in an audit trail.
How we built it
- TypeScript end to end. The
@modelcontextprotocol/sdkserver faces the agent, a client faces@paypal/mcp, and Node's built-innode:sqlitestores mandates, payments and an append-only trace table. - AI gates run on Groq (
openai/gpt-oss-120b) or Anthropic, chosen by one setting. A configured model that errors, times out or returns malformed JSON fails closed and holds the payment; mock heuristics only run when no key is set. - Payment parsing matches PayPal exactly. Order totals are computed the way the agent toolkit computes them (it ignores the agent-supplied
itemTotal, so an agent cannot understate it). Invoice totals follow PayPal's line-item rules: $$\text{total} = \sum_i (q_i u_i - d_i)\left(1 + \tfrac{t_i}{100}\right) + s$$send_invoicecarries no amount, so Interlock reads the invoice back from PayPal before policy runs. - Console: React + Vite, with the payment history and full traces in AG Grid.
- Benchmark suite: twelve realistic attack and control pages, and a runner that scores the scanner and policy together.
- 30 automated tests for the policy rules and invoice parsing. Verified live against the PayPal sandbox with two different MCP clients: Claude Desktop, and a generic Vercel AI SDK agent.
Challenges we ran into
- Agents worked around refusals. We tested the refusal path with live agents and a user pushing "just do whatever works". In 6 of 8 baseline runs the agent failed to stop cleanly: three acted on a workaround, two defeated the $200 cap by splitting $340 into $200 + $140 with real sandbox orders, and one switched to
create_invoiceafter a denial. The fix has two independent layers: rewritten refusal text (no workarounds attempted in 5 re-test trials), and deterministicsplit_payment/after_refusalrules that hold a split even if an agent ignores the text, validated live. - The model missed a homoglyph. A polite "our billing address changed" page, with a Cyrillic
оinnomad-cоffee.co, scored 0.99 clean with the scanner, because nothing in it addresses the agent. Code catches it trivially, so it became a policy rule. - Real API shapes differ from the docs we assumed.
create_ordertakes line items, not purchase units, so our first parser read every order as $0, and invoices had the same gap. We now compute totals exactly as PayPal does, and hold anything we cannot read. - Transport assumptions. The proxy first answered the agent's handshake only after PayPal's server had started, 10 or more seconds later. Claude Desktop waits; other clients probe with a 1-second timeout. We now answer immediately and connect upstream in the background.
Accomplishments that we're proud of
- Attack suite: the scanner caught 8 of 9 attacks with 0 false positives on 2 benign controls, consistent over three runs. With policy behind it, 9 of 9 were stopped.
- The hold-and-resume path works with a real agent: approve in the console and Claude Desktop's paused call completes with a real PayPal order. The agent never knows it was paused.
- No changes to the agent: a second, unrelated MCP client worked against the same proxy.
- An honest benchmark: we kept every page the scanner missed.
What we learned
- A refusal is a prompt. Its wording decides whether an agent stops or improvises, so it has to be tested like one, against live agents.
- Models and code catch different things. Models are good at intent; code is better at arithmetic and character-level tricks. The two layers cover for each other.
- Fail closed, everywhere. A gate that errors, a lookup that fails, an amount that cannot be read: each one must hold, never pass.
What's next for Interlock: a checkpoint between AI agents and PayPal
- Validate
send_invoicelookups live. They're covered by tests today, because our sandbox app could not get the Invoicing permission in time. - Keep holds alive for every client. Heartbeats only reach clients that request progress notifications.
- More clients: test Cursor.
- Refunds: design a mandate model they fit.
- More data: grow the agent test sample beyond two models.
- Hosted mode: so a team can share one console across many agents.
Built With
- ag-grid
- anthropic
- claude
- claude-desktop
- express.js
- gpt-oss-120b
- groq
- mcp-sdk
- model-context-protocol
- node.js
- paypal
- paypal-agent-toolkit
- paypal-mcp-server
- react
- sqlite
- typescript
- vercel-ai-sdk
- vite