ATLAS Governance Gateway
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.
README
ATLAS Governance Gateway (Phase 2)
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 anna_ko@berkeley.edu (UC Berkeley). This implementation strictly follows the "approve -> auto_approve" deterministic flow for low-risk actions per project v3.0 findings.
๐ Key Features
- Durable Governance: Uses Inngest to manage long-running human review workflows that survive server restarts.
- FastMCP + FastAPI: Exposes Model Context Protocol (MCP) tools via a robust generic web server.
- Risk Evaluation: Real-time checking against EU AI Act standards via
atlas-welfare-v1on Modal. - Compliance: Enforces Article 14 by pausing high-risk actions until human approval is received.
- Secure Deployment: Dockerized environment with secure credential management.
๐ ๏ธ Architecture
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 Server: Mounted at
/mcp/sseto serve Agent tools (check_status,request_extension, etc.). - Inngest Endpoint: Served at
/api/inngestto handle workflow triggers and step execution. - Webhook: Listens at
/webhook/approvalfor external human approval signals.
- MCP Server: Mounted at
-
Workflows (
workflows.py): Defines the durable business logic.handle_governance: The core workflow that:- Calls Modal to assess risk.
- Auto-approves usage if Risk Score < 70.
- Pauses and waits for
atlas/sarah.decisionevent if Risk Score >= 70.
-
Agent Integration:
- Any MCP-compliant agent (Claude Desktop, cursor, or custom scripts) can connect to the Gateway.
๐ฆ Installation & Setup
Prerequisites
- Docker Desktop installed and running.
- (Optional)
python 3.10+if running locally without Docker.
Quick Start (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:
- Modal Function Name: (Default:
nislam-mics/ATLAS-NIST-Measure) - AI Backend: Choose OpenAI or Local LLM (Ollama).
- Inngest Keys: Event Key and Signing Key (Required for Production).
- Modal Credentials: Token ID and Secret.
Note: The script creates a
.envfile automatically. DO NOT commit this file. - Modal Function Name: (Default:
-
Usage: The script will build the Docker image
atlas-gatewayand run it on port8000.
๐ Endpoints
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. |
๐งช Testing the Governance Flow
1. Manual Verification
Check if the gateway is running:
curl http://localhost:8000/
# Expected: {"status": "ATLAS Governance Gateway Running", ...}
2. End-to-End Simulation
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:
- Script simulates an Agent calling
request_payment_extension(High Risk). - Gateway returns
PENDING REVIEW. - Inngest triggers a workflow run (check Inngest Dashboard).
- Script waits... then sends an Approval signal to
/webhook/approval. - Workflow completes.
- Script simulates an Agent calling
๐ค AI Agent Prompt Instructions
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.
๐ Detailed Governance Procedure Call
The following sequence occurs when a high-risk tool is invoked.
1. Initial Tool Request (Agent -> Gateway)
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.
2. Risk Assessment (Inngest -> Modal)
Endpoint: Modal.com (Inference API)
-
Input: Tool name and arguments.
-
Assessment Result:
{ "risk_score": 85, "classification": "HIGH_RISK", "action": "PAUSE" }
3. Case A: HITL Required (Risk >= 70)
If the Atlas Brain determines the action is high-risk, a notification is sent to the human reviewer (Sarah).
-
Sarah's Workflow:
- Sarah receives a notification via Inngest/Webhook.
- Sarah reviews the
reasonandbeneficiary_id. - Sarah approves:
POST /webhook/approval
{ "decision": "APPROVED", "event_id": "evt_48f1fb4b" } -
Workflow Result: Workflow resumes and marks the tool execution as
AUTHORIZED.
4. Case B: Auto-Approval (Risk < 70)
If the action is deemed low-risk (e.g., standard status check or well-documented low-value extension), the system skips human intervention.
- Workflow Result: The workflow proceeds immediately to completion without waiting for an external signal.
- Audit Log: "Auto-approved based on Risk Score [X] per Article 14 Compliance."
5. Workflow Resolution (Inngest)
The atlas/sarah.decision event resumes the workflow. The final authorization is logged in the Inngest dashboard.
๐ Project Structure
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.
๐ Security Notes
- Secrets: Never bake API keys into the Docker image. Always pass them via
--env-fileor environment variables at runtime. - Inngest Signing: Production deployments MUST verify the
INNGEST_SIGNING_KEYto prevent unauthorized workflow triggers. This is enforced inworkflows.py.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.