Inspiration
AI agents are becoming capable of performing real-world tasks, including interacting with payment platforms and initiating financial transactions.
But what happens when an AI agent makes the wrong decision? What if it gets manipulated by a prompt injection, follows malicious instructions, or attempts to spend more than it should?
We believe AI agents should be able to perform financial operations, but they should never have unrestricted authority over money.
Inspired by the growing possibilities of agentic commerce and PayPal's AI ecosystem, we built Agent Guardian — a security layer that stands between AI agents and PayPal, ensuring every financial action follows defined policies and authorization rules.
Our guiding idea is simple: Let AI act, but never without guardrails.
What it does
Agent Guardian is a security and governance layer that protects PayPal operations initiated by AI agents.
It intercepts payment-related requests through a Model Context Protocol (MCP) server and evaluates each action before it reaches PayPal.
Its core capabilities include:
- Policy Engine: Converts plain-English spending policies into deterministic rules, such as transaction limits and restricted merchants.
- Risk Scoring: Evaluates transaction context using risk indicators, heuristics, and optional LLM assistance.
- Prompt Injection Defense: Detects suspicious instructions, manipulation attempts, and attempts to bypass established rules.
- Human-in-the-Loop Approval: Holds transactions that require authorization and allows a human to approve or reject them.
- Audit Trail: Records decisions and provides explanations for why an action was allowed, blocked, or held.
Agent Guardian also supports PayPal operations beyond payments, including invoicing, disputes, and transaction reporting, subject to the capabilities and permissions of the connected PayPal environment.
To demonstrate its protection capabilities, we built three scenarios:
- Rogue Agent: Simulates an agent attempting suspicious or unauthorized financial actions.
- Friendly Agent: Demonstrates a legitimate transaction that requires human approval before proceeding.
- Prompt Injection Agent: Simulates an agent manipulated by malicious instructions.
The goal is to make autonomous financial operations safer, controlled, and accountable.
How we built it
We built Agent Guardian using a layered architecture that separates AI decision-making from financial authorization.
At the center is a custom MCP server that acts as the controlled payment interface for AI agents. Instead of allowing agents to communicate directly with PayPal, requests pass through Guardian's security pipeline.
The pipeline consists of:
- Request interception: The MCP server receives payment-related actions from an AI agent.
- Policy evaluation: A deterministic rules engine checks spending limits and restrictions.
- Risk assessment: An LLM-assisted scorer and heuristic checks evaluate suspicious behavior, transaction context, and potential prompt injection.
- Authorization: The system allows, blocks, or holds an action for human approval.
- Execution and auditing: Approved actions proceed through the configured PayPal gateway, and decisions are recorded with explanations.
We also developed a dashboard with four main sections: Threat Lab, Approvals, Policies, and Audit.
For PayPal connectivity, we implemented both a deterministic mock gateway and a PayPal sandbox REST gateway. This allows the application to demonstrate its security pipeline without requiring every user to configure PayPal credentials.
Technology stack:
- Next.js 16
- TypeScript
- Tailwind CSS 4
- Model Context Protocol (MCP) SDK
- SQLite with better-sqlite3
- PayPal REST APIs and PayPal Agent Toolkit/MCP
- LLM integration through an OpenAI-compatible API, with heuristic fallback
An important design decision is that the LLM cannot override or weaken deterministic security policies. The policy engine always has the final authority.
Challenges we ran into
One of our biggest challenges was designing a system that allows AI agents to operate autonomously while maintaining strict financial controls.
We needed to ensure that security decisions would not depend entirely on AI-generated responses. This led us to separate deterministic policy enforcement from LLM-assisted risk assessment.
Another challenge was defending against prompt injection. An AI agent might receive malicious instructions disguised as legitimate requests, so we needed to evaluate not only the transaction itself but also the context behind the action.
We also faced the challenge of integrating MCP with PayPal operations while maintaining a consistent approval and audit workflow.
Finally, we wanted the project to remain demonstrable even without external API credentials, which is why we implemented a mock gateway alongside PayPal sandbox integration.
Accomplishments that we're proud of
We're proud to have built more than a payment interface. We created a working security pipeline that demonstrates how AI agents can interact with financial services under controlled conditions.
Some accomplishments we're particularly proud of:
- Built a custom MCP server that acts as the guarded interface between AI agents and PayPal.
- Implemented deterministic spending policies with LLM-assisted natural-language policy compilation.
- Developed contextual risk scoring and prompt-injection detection.
- Created a human approval workflow where Guardian executes the original held action after approval.
- Implemented both mock and PayPal sandbox gateways.
- Developed three demonstration agents that showcase legitimate, suspicious, and prompt-injection scenarios.
- Created a centralized dashboard for threat testing, policies, approvals, and audit records.
Most importantly, we demonstrated that AI autonomy and financial security do not have to be competing ideas.
What we learned
We learned that giving AI agents access to powerful tools requires more than good prompts or intelligent models. It requires a separate security architecture that controls what those agents are actually allowed to do.
We also learned the importance of deterministic enforcement. AI can help interpret context and identify potential risks, but critical financial restrictions should be enforced through rules that cannot be overridden by the model.
Working with MCP helped us understand how AI agents can interact with external services through structured tools and controlled interfaces.
Another important lesson was that transparency matters. Every financial action should have a clear decision, an understandable explanation, and an audit record.
Ultimately, we learned that the future of agentic commerce depends not only on what AI agents can do, but also on how responsibly we allow them to do it.
What's next for Agent Guardian
We envision Agent Guardian evolving into a more comprehensive security and governance platform for agentic commerce.
Our future plans include:
- Advanced Threat Intelligence: Improve detection of suspicious agents, malicious instructions, and unusual transaction behavior.
- More Granular Policies: Support per-agent spending limits, merchant restrictions, transaction categories, and time-based rules.
- Multi-Level Approvals: Introduce configurable approval chains for high-value or sensitive transactions.
- Improved Agent Identity and Trust: Introduce agent-specific permissions, identities, and trust levels.
- Real-Time Monitoring: Provide better visibility into ongoing agent activities and payment decisions.
- Expanded Payment Integrations: Explore additional payment providers and financial services.
- Production-Ready Audit Infrastructure: Improve persistent storage, monitoring, and traceability for real-world deployments.
Our long-term vision is to become the security layer that allows businesses and individuals to confidently adopt AI-powered financial agents.
Agent Guardian — Let AI act, but never without guardrails.
Built With
- agent-governance
- agentic-ai
- ai-agents
- ai-safety
- ai-security
- audit-trail
- autonomous-payments
- developer
- financial-technology
- fintech
- fraud-prevention
- human-in-the-loop
- mcp
- model-context-protocol
- next.js
- openai
- payment-automation
- payment-security
- paypal
- policy-engine
- prompt-injection-protection
- risk-assessment
- transaction-monitoring
- typescript