Inspiration

Giving an AI agent access to a payments account today is all or nothing. PayPal's MCP server lets an agent issue refunds, cancel subscriptions and settle disputes, and an agent that can refund $5 can equally refund $5,000. In platform engineering we never hand a powerful system out without a policy, an approval path, an audit trail and a kill switch. Agents that move money deserve the same.

What it does

PayPal Payment Firewall is a financial control layer delivered as a drop-in MCP proxy. It sits between any AI agent and PayPal's official MCP server and exposes PayPal's tools unchanged, so the agent needs no modification. Every tool call is evaluated against a policy file and is:

  • Allowed and forwarded to PayPal,
  • Held for the account owner's approval, or
  • Denied, with the reason returned to the agent.

Policies cover per-action limits, approval thresholds, daily budgets, always-approve and always-deny tools, and a kill switch that freezes every money-moving action. Every attempt is recorded with its reason, and an owner-only dashboard handles approvals.

Design principles

  • Deterministic enforcement. Rules are evaluated in code. Asking a language model whether a language model may move money would defeat the purpose; no prompt can change what the policy allows.
  • Authority separated from reasoning. The agent decides what to attempt; it never holds the power to approve. Approval exists only on a separate, password-protected channel, and each approval is single-use and bound to one payment and one amount.
  • Judge what was sent, not what was meant. The firewall evaluates the actual request. It reads amounts however they are written, forwards the request in the exact form it checked, and treats anything it cannot read as a possible worst case.
  • Zero integration cost. Because it speaks MCP on both sides, adopting it is a configuration change, not a rewrite.

How I built it

A FastMCP proxy wraps PayPal's @paypal/mcp server, with the policy engine running as middleware on every tool call. Policies are YAML, re-read on each call so changes apply live. Decisions, approvals and the kill switch are stored in SQLite, and a FastAPI dashboard provides the owner's view. A tool-calling support agent, built on an OpenAI-compatible API and run with Llama 3.2 through Ollama, exercises the system against the PayPal sandbox, including completed refunds.

Challenges

  • Malformed requests are a security problem, not a formatting problem. The test agent sent a $500 refund with the amount in the wrong structure, and an early version classified it as "amount unknown" and held it instead of denying it. That led to tolerant parsing, canonical re-encoding before forwarding, and the rule that an unreadable amount is treated as a potential full refund.
  • Binding an approval to intent. Matching approvals on exact request text broke as soon as the agent rephrased a retry; matching too loosely would let one approval cover a different payment. Approvals now bind to the capture and the amount, and are returned if PayPal rejects the call.
  • Budgets as an anti-evasion control. A per-action limit alone invites splitting one large refund into many small ones; the daily budget closes that gap.

Accomplishments

Under test the agent hallucinated calls nobody asked for, including a subscription cancellation, and repeated and rewrote requests. Nothing reached PayPal outside policy.

What I learned

Agents fail untidily: wrong structures, repeated calls, invented arguments. Guardrails for them have to be built like any other security boundary, assuming hostile or broken input, rather than as a convenience wrapper.

What's next

  • Firewall-side execution of approved requests, with the result returned to the agent.
  • Per-agent identities and budgets, and role-based approvers.
  • Coverage for more PayPal capabilities, such as payouts.
  • Approval alerts through Zapier, and a hosted version on Render.

Built With

Share this project:

Updates

Submission history