ATLAS Governance Gateway

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.

Category
访问服务器

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-v1 on 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:

  1. Gateway (gateway.py): A FastAPI application that serves as the entry point.

    • MCP Server: Mounted at /mcp/sse to serve Agent tools (check_status, request_extension, etc.).
    • Inngest Endpoint: Served at /api/inngest to handle workflow triggers and step execution.
    • Webhook: Listens at /webhook/approval for external human approval signals.
  2. Workflows (workflows.py): Defines the durable business logic.

    • handle_governance: The core workflow that:
      1. Calls Modal to assess risk.
      2. Auto-approves usage if Risk Score < 70.
      3. Pauses and waits for atlas/sarah.decision event if Risk Score >= 70.
  3. 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.

  1. Run the Setup Script:

    ./setup.sh
    
  2. 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 .env file automatically. DO NOT commit this file.

  3. Usage: The script will build the Docker image atlas-gateway and run it on port 8000.


🔌 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.

  1. Ensure the Gateway is running (via Docker or locally).

  2. Run the test script:

    python test_handshake.py
    
  3. 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.

🤖 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

  1. This environment is governed by the ATLAS Governance Gateway.
  2. When you call a payment or high-risk tool, the gateway may return a message starting with PENDING REVIEW (Ref: evt_...).
  3. DO NOT assume the action failed.
  4. DO inform the user that the request has been queued for human governance review and provide the Reference ID.
  5. 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:

    1. Sarah receives a notification via Inngest/Webhook.
    2. Sarah reviews the reason and beneficiary_id.
    3. 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-file or environment variables at runtime.
  • Inngest Signing: Production deployments MUST verify the INNGEST_SIGNING_KEY to prevent unauthorized workflow triggers. This is enforced in workflows.py.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选