loading…
Search for a command to run...
loading…
A secure middleware that intercepts AI agent tool calls to evaluate risks and manage human-in-the-loop approvals via durable Inngest workflows. It ensures compl
A secure middleware that intercepts AI agent tool calls to evaluate risks and manage human-in-the-loop approvals via durable Inngest workflows. It ensures compliance with standards like the EU AI Act by pausing high-risk actions until authorized by a human reviewer.
A Secure Middleware for AI Agents, powered by FastMCP, Inngest, and Modal.
The ATLAS Governance Gateway is a centralized hub that intercepts AI Agent tool calls, evaluates potential risks using a generic LLM/SLM (hosted on Modal.com), and manages "Human-in-the-Loop" (HITL) escalations via durable Inngest workflows.
Logic Attribution: The governance logic and dataset design are attributed to Anna Ko [email protected] (UC Berkeley). This implementation strictly follows the "approve -> auto_approve" deterministic flow for low-risk actions per project v3.0 findings.
atlas-welfare-v1 on Modal.sequenceDiagram
participant Agent as AI Agent (MCP Client)
participant GW as Governance Gateway (FastAPI)
participant Modal as Atlas Brain (Modal Evaluation)
participant Inngest as Inngest Workflow
participant Human as Sarah (Human-in-the-Loop)
Agent->>GW: Call Tool (e.g. request_payment_extension)
GW->>Inngest: Trigger Governance Event
GW-->>Agent: Returns "PENDING REVIEW"
Inngest->>Modal: Evaluate Risk (EU AI Act)
Modal-->>Inngest: Risk Score (0-100)
alt Risk Score < 70
Inngest->>Inngest: Auto-Approve Action
else Risk Score >= 70
Inngest->>Inngest: PAUSE & Wait for Human
Human->>GW: POST /webhook/approval (APPROVED)
GW->>Inngest: Send Approval Event
Inngest->>Inngest: Resume & Finalize
end
The system consists of three main components:
Gateway (gateway.py): A FastAPI application that serves as the entry point.
/mcp/sse to serve Agent tools (check_status, request_extension, etc.)./api/inngest to handle workflow triggers and step execution./webhook/approval for external human approval signals.Workflows (workflows.py): Defines the durable business logic.
handle_governance: The core workflow that:atlas/sarah.decision event if Risk Score >= 70.Agent Integration:
python 3.10+ if running locally without Docker.We provide a setup.sh script to automate the configuration and deployment.
Run the Setup Script:
./setup.sh
Configuration: The script will prompt you for:
nislam-mics/ATLAS-NIST-Measure) Note: The script creates a .env file automatically. DO NOT commit this file.
Usage:
The script will build the Docker image atlas-gateway and run it on port 8000.
Once running, the Gateway exposes the following endpoints on http://localhost:8000:
| Endpoint | Method | Description |
|---|---|---|
/ |
GET | Health check and status. |
/mcp/sse |
GET | MCP Endpoint. Connect your AI Agent here. |
/mcp/messages |
POST | MCP Protocol messages (handled by FastMCP). |
/api/inngest |
POST | Inngest Webhook. Connects to Inngest Cloud. |
/webhook/approval |
POST | Human Approval Webhook. Simulate approval signals. |
Check if the gateway is running:
curl http://localhost:8000/
# Expected: {"status": "ATLAS Governance Gateway Running", ...}
We included a script test_handshake.py that simulates the entire flow without needing an external Agent.
Ensure the Gateway is running (via Docker or locally).
Run the test script:
python test_handshake.py
Flow:
request_payment_extension (High Risk).PENDING REVIEW./webhook/approval.To ensure your AI Agent correctly uses the Governance Gateway, include the following instructions in the Agent's System Prompt:
🛑 Governance Protocol
- This environment is governed by the ATLAS Governance Gateway.
- When you call a payment or high-risk tool, the gateway may return a message starting with
PENDING REVIEW (Ref: evt_...).- DO NOT assume the action failed.
- DO inform the user that the request has been queued for human governance review and provide the Reference ID.
- DO NOT retry the call immediately; wait for the system to process the background workflow.
The following sequence occurs when a high-risk tool is invoked.
Endpoint: SSE /mcp/sse (Streamed)
Request (JSON-RPC):
{
"method": "tools/call",
"params": {
"name": "request_payment_extension",
"arguments": { "beneficiary_id": "BEN-123", "reason": "Hardship" }
}
}
Gateway Response:
PENDING REVIEW (Ref: evt_48f1fb4b). Action queued subject to governance checks.
Endpoint: Modal.com (Inference API)
Input: Tool name and arguments.
Assessment Result:
{ "risk_score": 85, "classification": "HIGH_RISK", "action": "PAUSE" }
If the Atlas Brain determines the action is high-risk, a notification is sent to the human reviewer (Sarah).
Sarah's Workflow:
reason and beneficiary_id.POST /webhook/approval{ "decision": "APPROVED", "event_id": "evt_48f1fb4b" }
Workflow Result: Workflow resumes and marks the tool execution as AUTHORIZED.
If the action is deemed low-risk (e.g., standard status check or well-documented low-value extension), the system skips human intervention.
The atlas/sarah.decision event resumes the workflow. The final authorization is logged in the Inngest dashboard.
gateway.py: Main server entry point (FastAPI + FastMCP).workflows.py: Inngest workflow definitions and client initialization.setup.sh: Automated setup and deployment script.Dockerfile: Container definition (Secure, no secrets baked in).requirements.txt: Python dependencies.test_handshake.py: Verification utility.--env-file or environment variables at runtime.INNGEST_SIGNING_KEY to prevent unauthorized workflow triggers. This is enforced in workflows.py.Добавь это в claude_desktop_config.json и перезапусти Claude Desktop.
{
"mcpServers": {
"atlas-governance-gateway": {
"command": "npx",
"args": []
}
}
}