AgentGuard MCP
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@AgentGuard MCPshow pending approval requests for sensitive actions"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
AgentGuard MCP
Identity-Aware Authorization for AI Agents
AgentGuard MCP is the protected Model Context Protocol authorization backend for AgentGuard.
It gives AI runtimes distinct machine identities, enforces least-privilege OAuth permissions, evaluates contextual security policy, pauses high-risk actions for authenticated human approval, binds approvals back to the requesting identity, prevents approval replay, and records security decisions in Supabase.
Frontend Repository:
https://github.com/haisamar/agentguard
Live Product:
https://agentguard-eight.vercel.app
Public Demo:
https://agentguard-eight.vercel.app/demo
Why AgentGuard MCP?
Giving an AI agent access to a tool is easy.
Controlling:
which agent can use which tool, under what conditions, and when a human must intervene
is harder.
AgentGuard separates that problem into distinct security layers.
Auth0 establishes machine and human identities.
OAuth scopes define which classes of operations each machine identity may request.
AgentGuard policy evaluates the context of the specific action.
Human approval creates a separate authority boundary for sensitive operations.
Approval-bound execution ensures approval can only be used by the original requesting identity.
Replay protection prevents an executed approval from being reused.
Supabase persists approval state and audit events.
MCP exposes protected tools to agent runtimes.
The design principle is:
An AI agent being authenticated should not mean it has unlimited authority.
Architecture
flowchart LR
A["AI Agent"]
B["Auth0<br/>Machine Identity"]
C["OAuth Access Token"]
D["AgentGuard MCP Server"]
E{"Required Scope?"}
G{"Contextual Policy"}
F["DENY"]
H["ALLOW"]
I["APPROVAL_REQUIRED"]
J[("Supabase Approval")]
K["Auth0<br/>Human Login"]
L{"Human Decision"}
M["APPROVED"]
N["DENIED"]
O["Original Agent<br/>Requests Execution"]
P["Identity + Approval<br/>Verification"]
Q["Execute Once"]
R[("Audit Events")]
A --> B
B --> C
C --> D
D --> E
E -->|"Missing"| F
E -->|"Granted"| G
G -->|"Low Risk"| H
G -->|"Sensitive"| I
G -->|"Forbidden"| F
I --> J
J --> K
K --> L
L -->|"Approve"| M
L -->|"Deny"| N
M --> O
O --> P
P --> Q
F --> R
H --> R
I --> R
N --> R
Q --> RSecurity Model
AgentGuard uses distinct machine and human security principals.
Machine Identities
Each autonomous runtime receives a separate Auth0 Machine-to-Machine identity.
Example roles:
Runtime | Purpose | Granted Scopes |
Sales Agent | Revenue Operations |
|
Finance Agent | Finance Operations |
|
Admin Runtime | Security Administration |
|
This means a Sales Agent cannot issue refunds simply because another agent can.
The caller's OAuth access token determines which permissions belong to that identity.
Related MCP server: gov-mcp
Human Identities
Human administrators authenticate separately through an Auth0 Regular Web Application.
Machine identity and human identity are intentionally separate.
Example:
Finance Agent
↓
Authenticated Machine Identity
↓
finance:refund
↓
Contextual Policy
↓
APPROVAL_REQUIRED
↓
Human Administrator
↓
Authenticated Human Identity
↓
APPROVED
↓
Original Finance Agent ExecutesThis creates a separation of duties between:
request authorityand:
approval authorityAuthorization Layers
AgentGuard applies multiple authorization layers before sensitive execution occurs.
1. Authentication
The MCP server validates the Auth0 access token and establishes the caller identity.
Authentication answers:
Who is this runtime?It does not automatically answer:
What is this runtime allowed to do?2. OAuth Scope Authorization
Protected MCP tools declare which OAuth permissions are required.
Example:
@require_scopes(["finance:refund"])If the caller does not possess:
finance:refundthe action is denied immediately.
Example:
Sales Agent
↓
Authenticated
↓
issue_refund
↓
Missing finance:refund
↓
DENYContextual policy is not evaluated.
Human review is not reached.
3. Contextual Policy
Passing the OAuth scope boundary does not guarantee autonomous execution.
AgentGuard evaluates the specific context of the requested action.
Current demonstration rules include:
Refund <= $500
→ ALLOW
Refund > $500
→ APPROVAL_REQUIRED
Customer data export
→ APPROVAL_REQUIRED
Customer deletion
→ DENYThis allows AgentGuard to distinguish:
Can this identity request refunds?from:
Should this particular refund execute autonomously?4. Human Approval
Sensitive operations are persisted in the approval store.
The operation pauses with:
APPROVAL_REQUIREDA separately authenticated human can then approve or deny the request through the AgentGuard dashboard.
5. Approval-Bound Execution
An approved action may only be executed by the machine identity that originally requested it.
Before execution, AgentGuard verifies:
approval existsstatus == APPROVEDrequesting identity matches current identityapproval action matches requested actionapproval has not already executedOnly after those checks can the protected action continue.
6. Replay Protection
After successful execution:
APPROVED
↓
EXECUTEDA second execution attempt is denied.
This prevents the same approval from authorizing the same protected action multiple times.
MCP Tools
The AgentGuard prototype exposes five protected MCP tools.
search_accounts
Search CRM account data.
Required permission:
crm:readExample:
Sales Agent
crm:read
↓
search_accounts
↓
ALLOWissue_refund
Request a refund.
Required permission:
finance:refundPolicy:
amount <= $500
→ ALLOW
amount > $500
→ APPROVAL_REQUIREDExample low-risk request:
Finance Agent
finance:refund
↓
issue_refund($100)
↓
ALLOWExample sensitive request:
Finance Agent
finance:refund
↓
issue_refund($750)
↓
APPROVAL_REQUIREDExample scope failure:
Sales Agent
no finance:refund
↓
issue_refund($750)
↓
DENYlist_pending_approvals
Lists approval requests waiting for review.
Required permission:
agent:manageapprove_action
Administrative MCP approval path used during machine-runtime testing.
Required permission:
agent:manageThe portfolio application also contains a preferred human approval workflow through the separately authenticated Next.js administrator dashboard.
execute_approved_refund
Executes an already approved refund.
Required permission:
finance:refundAgentGuard verifies that the approval belongs to the current machine identity before allowing execution.
Approval Lifecycle
Approval records use four states:
PENDING
APPROVED
DENIED
EXECUTEDSuccessful flow:
PENDING
↓
APPROVED
↓
EXECUTEDDenied flow:
PENDING
↓
DENIEDReview information and approval information are represented separately.
This allows a denied request to correctly represent:
status = DENIED
reviewed_by = Human Administrator
approved_by = nullwithout incorrectly treating the reviewer as an approver.
Demo Simulator
The repository includes:
src/demo_simulator.pyThe simulator creates deterministic security records for the protected AgentGuard administrator dashboard.
It is separate from the public browser simulation.
Scenario 1 — OAuth Scope Denial
Sales Agent
↓
Attempts $750 refund
↓
Missing finance:refund
↓
DENYThe generated event includes authorization-failure metadata.
Scenario 2 — Autonomous Allow
Finance Agent
↓
Requests $100 refund
↓
finance:refund granted
↓
Policy satisfied
↓
ALLOWScenario 3 — Approval Required
Finance Agent
↓
Requests $750 refund
↓
finance:refund granted
↓
Refund > $500
↓
APPROVAL_REQUIREDScenario 4 — Human Approved Execution
Human Administrator
↓
Approves Request
↓
APPROVEDThe original Finance Agent then executes:
Finance Agent
↓
execute_approved_refund
↓
Approval verified
↓
ALLOW
↓
EXECUTEDScenario 5 — Pending Review
The simulator also creates a $900 refund request and intentionally leaves it pending.
Finance Agent
↓
$900 refund
↓
APPROVAL_REQUIRED
↓
PENDINGThis gives the administrator dashboard an active request that can be reviewed interactively.
Run the Simulator
Activate the virtual environment:
.\.venv\Scripts\Activate.ps1Then:
python -m src.demo_simulatorAudit Events
AgentGuard records security decisions in Supabase.
Important event decisions include:
ALLOW
DENY
APPROVAL_REQUIRED
APPROVEDAudit metadata may include:
granted scopes
missing scopes
authorization failures
approval IDs
requesting identity
action context
human reviewer
resource identifiers
replay attempts
Example authorization failure:
{
"action": "issue_refund",
"decision": "DENY",
"required_scope": "finance:refund",
"reason": "Missing required OAuth scope: finance:refund",
"metadata": {
"granted_scopes": [
"crm:read",
"crm:write",
"support:read"
],
"missing_scopes": [
"finance:refund"
],
"security_event": "authorization_failure"
}
}OAuth access tokens, client secrets, and credentials should never be written into the audit log.
Database
AgentGuard uses Supabase/PostgreSQL.
The two primary tables are:
approvals
audit_eventsapprovals
Stores sensitive operations and their review lifecycle.
Important fields include:
id
requesting_identity
action
payload
reason
status
reviewed_by
reviewed_at
approved_by
approved_at
created_at
executed_ataudit_events
Stores security decisions and execution context.
Important fields include:
id
identity
action
decision
required_scope
reason
approval_id
metadata
created_atRow Level Security is enabled.
No public browser policies are intentionally created for sensitive AgentGuard records.
Trusted server-side components use protected server credentials.
Repository Structure
agentguard-mcp/
│
├── database/
│ └── schema.sql
│
├── src/
│ │
│ ├── auth0/
│ │ ├── __init__.py
│ │ ├── authz.py
│ │ ├── errors.py
│ │ └── middleware.py
│ │
│ ├── approvals.py
│ ├── audit.py
│ ├── config.py
│ ├── database.py
│ ├── demo_simulator.py
│ ├── policy.py
│ ├── server.py
│ ├── tools.py
│ └── __init__.py
│
├── .env.example
├── .gitignore
├── pyproject.toml
└── README.mdEnvironment Configuration
AgentGuard MCP reads environment variables from .env.
Example:
AUTH0_DOMAIN=
AUTH0_AUDIENCE=http://localhost:3001/
MCP_SERVER_URL=http://localhost:3001/
PORT=3001
SALES_AGENT_CLIENT_ID=
SALES_AGENT_CLIENT_SECRET=
FINANCE_AGENT_CLIENT_ID=
FINANCE_AGENT_CLIENT_SECRET=
ADMIN_AGENT_CLIENT_ID=
ADMIN_AGENT_CLIENT_SECRET=
SUPABASE_URL=
SUPABASE_SECRET_KEY=Never commit .env.
Auth0 API Permissions
The AgentGuard Auth0 API defines permissions including:
crm:read
crm:write
support:read
support:write
finance:read
finance:refund
customer:export
agent:manageEach Machine-to-Machine application should receive only the permissions needed for its role.
Local Setup
Requirements
Python 3.10+
Auth0 tenant
Auth0 Machine-to-Machine applications
Auth0 API configured for AgentGuard
Supabase project
Clone:
git clone https://github.com/haisamar/agentguard-mcp.git
cd agentguard-mcpCreate Virtual Environment
Windows PowerShell
python -m venv .venv
.\.venv\Scripts\Activate.ps1macOS / Linux
python -m venv .venv
source .venv/bin/activateInstall Dependencies
Using Poetry:
pip install poetry
poetry installConfigure:
.envusing:
.env.exampleas the template.
Run the MCP Server
From the repository root:
.\.venv\Scripts\Activate.ps1
python -m src.serverDefault server:
http://localhost:3001MCP endpoint:
http://localhost:3001/mcpOAuth protected-resource metadata:
http://localhost:3001/.well-known/oauth-protected-resourceKeep this terminal running while testing the MCP backend.
Auth0 OAuth Metadata
AgentGuard publishes protected-resource metadata for the MCP resource.
The server integrates with the configured Auth0 issuer and audience.
Machine clients obtain OAuth access tokens from Auth0 and send them to AgentGuard MCP as bearer tokens.
The authorization middleware validates the identity and exposes the granted scopes to protected MCP tools.
MCP Inspector Note
Some MCP Inspector OAuth workflows attempt Dynamic Client Registration.
The Auth0 tenant used for this prototype does not enable Dynamic Client Registration.
Because of that, the Inspector's automatic registration workflow is not the primary validation path for this project.
The MCP server itself still exposes OAuth protected-resource metadata and validates Auth0 access tokens.
AgentGuard's recruiter-facing demonstration is provided through:
Public deterministic simulation
+
Protected administrator console
+
Real MCP authorization implementationFrontend
The companion AgentGuard frontend is:
https://github.com/haisamar/agentguard
Live product:
https://agentguard-eight.vercel.app
Public demo:
https://agentguard-eight.vercel.app/demo
The frontend provides:
public product experience
deterministic security simulation
technical trace explorer
Auth0-protected administrator console
machine identity inventory
human operator identity
approval controls
persisted authorization trace explorer
security activity feed
audit-event inspection
approval history
Public Demo vs Backend Records
These are intentionally different systems.
Public Demo
Deterministic
Client-side
Read-only
No sensitive identifiers
No Supabase security records exposedProtected Administrator Dashboard
Persisted Supabase approvals
Persisted audit events
Real administrator authentication
Human approve / deny controls
Sensitive identity contextThis separation makes the project publicly reviewable without exposing privileged security data.
Security Principles Demonstrated
Authentication ≠ Authorization
An authenticated machine can still be denied.
Least Privilege
Every runtime receives only the OAuth scopes needed for its role.
Contextual Authorization
A valid permission does not always mean immediate execution.
Separation of Duties
Machines request sensitive actions while humans independently approve them.
Human-in-the-Loop Authorization
Autonomous authority stops at defined policy thresholds.
Approval-Bound Execution
Approval belongs to a specific requesting identity and action.
Replay Protection
An executed approval cannot be reused.
Auditability
Security decisions are persisted with identity and authorization context.
Design Principle
AgentGuard is based on one core idea:
An AI agent being authenticated should not mean it has unlimited authority.
Authentication proves:
who the agent isOAuth scopes determine:
what category of operations it may requestContextual policy determines:
whether that exact operation should execute autonomouslyHuman approval creates:
a separate authority boundary for sensitive decisionsCurrent Scope
AgentGuard MCP is a security portfolio prototype rather than a production IAM platform.
Intentional boundaries currently include:
demonstration policies are defined in application code
machine identities are mapped to demonstration roles
human administrator authorization uses an application-level allowlist
policy management is not exposed through a dedicated control plane
audit events are not cryptographically immutable
distributed locking for production concurrency is outside the prototype scope
approval expiration is not implemented
backend deployment is designed primarily for controlled testing
These limitations are documented rather than hidden.
Possible Extensions
Future versions could add:
Auth0 role-based administrator access
policy-as-code
policy versioning
centralized agent identity registry
workload identity federation
delegated authorization
resource-level authorization
approval expiration
time-limited privileges
organization isolation
step-up authentication
signed audit records
SIEM export
policy simulation
dynamic risk scoring
additional MCP tools
production MCP deployment
distributed execution locking
Project Motivation
AgentGuard explores a question:
What does identity security look like when the user is not always a human?
Autonomous AI runtimes can increasingly:
call APIs
use tools
change records
trigger workflows
take financial actionsThat makes identity and authorization critical at the agent layer.
AgentGuard applies familiar IAM concepts such as:
machine identity
OAuth scopes
least privilege
separation of duties
human approval
auditabilityto autonomous agent execution.
Related Project
AgentGuard Frontend
https://github.com/haisamar/agentguard
Live Product
https://agentguard-eight.vercel.app
Interactive Demo
This server cannot be deployed
Maintenance
Related MCP Connectors
Give AI agents identity, scoped access, trusted context, and verifiable actions through MCP.
Zero-secret MCP gateway for AI agents: risk-scored, audited calls with human-in-the-loop approval.
Identity, authorization, audit trails, and revocable permissions for AI agents accessing MCP tools.
MCP server connecting AI agents to 100+ apps (Gmail, Slack, Notion, GitHub) via one-click OAuth.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceProvides a secure gRPC transport layer for the Model Context Protocol (MCP) with mutual TLS, token-based authentication, and fine-grained authorization. Includes comprehensive telemetry and a real-time visualization dashboard for monitoring AI model interactions and security events.1Apache 2.0
- AlicenseNot gradedqualityCmaintenanceAn MCP server that enforces runtime governance on AI agent actions — file access, command execution, delegation chains, and permission escalation.MIT
- AlicenseNot gradedqualityDmaintenanceA governed, audited Model Context Protocol server that provides AI agents with secure, read-only access to a clinical knowledge base through least-privilege tools, policy validation, and append-only audit logging.MIT
- FlicenseNot gradedqualityCmaintenanceMCP server that provides a security gateway for AI agents, enforcing allow/confirm/deny policies on tool calls and requiring human approval for risky operations, with full audit logging.-