Try it
- Live demo: https://agentpass-nnrn.onrender.com
- PayPal sandbox buyer: [email protected] / yry16Bh&
- Video: https://youtu.be/r8jQft4Wnxg
- Code (MIT): https://gitlab.com/aralroca/agentpass
- MCP for any agent:
claude mcp add --transport http agentpass https://agentpass-nnrn.onrender.com/mcp --header "Authorization: Bearer ap_live_…"(the token is shown once, at the end of onboarding)
The hosted demo uses the PayPal sandbox and a sandbox identity verification app, so identity checks are simulated and no real money moves. It runs on a free host: the first load after a quiet spell can take up to a minute.
Inspiration
AI agents can already find what we want to buy. Paying is where it breaks. Today you either hand the agent your whole wallet, or you approve every single click, which defeats the point of having an agent. Merchants have the opposite problem: when an order comes from a bot, they can't tell whether a real person authorized it, and when a chargeback arrives they have nothing to show.
Google's open AP2 protocol describes the missing piece, a signed mandate a human gives an agent, but it assumes someone issues that credential and someone enforces it where the money moves. We wanted to build that layer on top of PayPal.
What it does
AgentPass lets a verified human give an AI agent a spending mandate that PayPal enforces.
- Verify once. The person completes an identity verification (document, liveness and face).
- Link PayPal without paying. PayPal Vault v3 saves their account; nothing is charged.
- Grant a mandate. Per-purchase cap, total budget, allowed stores, blocked categories, expiry, and what happens over the limit. AgentPass issues it as a signed AP2 v0.2 open payment mandate (an SD-JWT verifiable credential) and gives the agent a token.
Then the agent shops, in our built-in chat with Claude or from any MCP client such as Claude Code, and every purchase lands in one of three outcomes:
- Paid. Inside the mandate, AgentPass charges the saved PayPal straight away, with nobody present.
- Held for your face. Over the cap or past the budget, PayPal holds the funds with an authorization. The chat shows a QR code; the human scans it on their phone and approves with a face check matched to their original verification. Approved means PayPal captures; denied, failed or 72 hours of silence means PayPal voids the hold.
- Denied. A blocked category, a store outside the mandate, an expired or revoked mandate. No PayPal call, and nothing the agent says can unlock it.
On the merchant side, each order carries a presentation the merchant verifies against our public keys: "a verified human, 18 or older, granted this mandate, and this exact payment fits it". The merchant sees no name, no birth date and no document. They can download the signed chain as an evidence pack for disputes. Revoking the mandate releases held funds, deletes the vaulted PayPal token and turns every later request into a denial.
How we built it
- One Next.js 16 app (TypeScript, React 19, Tailwind 4) serves the pages, the JSON API, the MCP server and the issuer's JWKS. It runs on a free Render web service with SQLite (
node:sqlite). - A pure policy function (
lib/policy.ts) decidesallow,step_upordeny, and collects every reason. A purchase orchestrator (lib/purchase/*) prices the cart from our own catalog, runs the policy, then calls PayPal, and records each state change and event. - PayPal through the official server SDK (
@paypal/paypal-server-sdk): Vault v3 setup tokens and payment tokens to save the wallet without a purchase; Orders v2 withintent: CAPTUREand thevault_idplusstored_credential(merchant-initiated, subsequent, unscheduled) for in-mandate buys; Orders v2intent: AUTHORIZEto hold over-limit buys; Payments v2 capture and void to settle them; aPayPal-Request-Idon every write. - Real AP2 credentials. The open mandate (
mandate.payment.open.1) carries AP2 constraints (amount_range,budget,allowed_payees,execution_date,payment_reference) and the agent's key incnf, signed ES256 with@sd-jwt/sd-jwt-vcandjose. Each purchase is closed with amandate.payment.1key-binding JWT signed by the agent's key, bound to a hash of the exact cart. Identity facts (verified_human,age_over_18,country,identity_check) are selectively disclosable claims; the credential holds no personal data at all. - Identity behind an adapter.
lib/identity.tsis the only provider-specific code. It reduces the provider's decision to status, an over-18 flag, a country and a salted hash before anything else sees it. The step-up is accepted only when liveness and face match both pass against the same user's original verification. - The agent. Claude Sonnet 5.5 through the Vercel AI SDK 7 with four tools (
search_products,get_mandate,request_purchase,get_purchase). The same four tools are served over MCP (Streamable HTTP,@modelcontextprotocol/server), so any agent can shop under the mandate. - Tests. 211 Vitest tests mock PayPal and identity at the HTTP boundary and cover the policy, the credentials (including tampering), the state machine, idempotency, MCP and the routes; 27 Playwright checks render every page at desktop and phone width and exercise revoke, the merchant verifier and the chat cards; a golden end-to-end test drives the live sandboxes (identity, PayPal, Claude) against the deployed app.
Challenges we ran into
- Charging a saved PayPal without the buyer present. This needs Vault v3 enabled on the sandbox app and a
stored_credentialblock on every order. Some sandbox accounts refuse to vault, so we designed a fallback (authorize the whole budget once, then partial captures) behind the same module interface. - The PayPal Agent Toolkit couldn't move money the way we needed. Its
create_orderalways captures and doesn't accept avault_id, and it pulls in older AI SDK versions. We kept all money movement in the official server SDK and never let the agent call PayPal directly. - Approval that an agent can't fake. In-chat approval buttons and MCP form elicitation both live inside the agent's channel. We moved approval out of band: a QR code to the human's phone, and a face check compared against the original verification.
- Keeping personal data out by construction. Identity providers return full personal data. We normalize it at the adapter boundary and store only derived claims, and every API and tool response is an explicit allowlist.
- Making money exact everywhere. Integer cents from the catalog to the policy, the credential and PayPal's amount strings, with no floating point at any step.
Accomplishments that we're proud of
- An open implementation of AP2's mandate issuer on top of PayPal: real SD-JWT VCs with key binding, a public JWKS, and a merchant verifier that rejects a proof if a single character changes.
- One set of agent tools that works in our chat and in any MCP client, with the same guarantees.
- Three clear outcomes a non-technical person understands at a glance: paid, held for your face, denied.
- Limits that hold under prompt injection, because they are enforced where the money moves, not in the prompt.
- 211 unit tests and 27 browser checks that run without any PayPal, identity or AI credentials, plus a golden end-to-end run against the live sandboxes.
What we learned
- PayPal's authorize-then-capture flow is a natural fit for "the agent asked, the human decides": the funds are really held, and voiding is clean.
- AP2's split between an open mandate and a closed, cart-bound mandate maps neatly to SD-JWT VC plus a key-binding JWT.
- The safest place for an agent's limits is the payment layer. Prompts and tool descriptions only explain the rules; the server enforces them.
- Merchants need less personal data than they think: "a verified human, 18+, authorized this exact payment" is enough to trust an agent's order.
What's next for AgentPass
- Let agents hold their own keys (today AgentPass keeps one per connection) and publish a revocation status list so merchants can check revocation themselves.
- Plug into PayPal's agentic commerce services, and support many merchants with their own payee ids instead of one sandbox merchant.
- Implement the budget-hold fallback mode, add PayPal webhooks, and support refunds and disputes with the evidence pack attached.
- Push notifications for held purchases, and spending mandates shared across a family or a team.
Built With
- anthropic
- ap2
- claude
- model-context-protocol
- next.js
- paypal
- paypal-orders-api
- paypal-vault
- playwright
- react
- render
- sd-jwt
- sqlite
- tailwindcss
- typescript
- vercel-ai-sdk
- vitest