Skip to main content
Glama
sudo-hrmn

MCP-Gatekeeper

by sudo-hrmn

🛡️ MCP-Gatekeeper

MCP(모델 컨텍스트 프로토콜) 클라이언트 및 업스트림 서버를 위한 런타임 보안 게이트웨이 및 FastMCP 서버.

MCP-Gatekeeper는 도구 목록 새로고침과 도구 응답의 100% 를 검사하는 심층 방어 프록시이자 FastMCP 서버로, 도구 중독, 응답 기반 프롬프트 인젝션(예: MCPoison / CurXecute 공격), 무단 도구 스키마 변조("rug pulls"), 그리고 승인되지 않은 고위험 작업을 방지합니다.

fastmcp.cloud 에 즉시 배포하거나 fastmcp CLI를 통해 로컬에서 실행할 수 있도록 설계되었습니다.


🚀 주요 기능 및 역량

  1. FastMCP Cloud 지원: 단일 파일 FastMCP 진입점(server.py)으로 fastmcp.cloud 에 SSE 및 HTTP 전송 방식으로 직접 배포 가능.

  2. Rug-Pull 스키마 보호: 연결 시 도구 스키마 기준선을 캡처하고, 승인된 기준선과 도구 목록 새로고침의 100%를 비교하여 승인되지 않은 도구 변경을 기본적으로 차단.

  3. 2단계 응답 인젝션 스캐너:

    • 1단계: 알려진 명령 하이재킹, 탈취 트랩, 셸 인젝션을 대상으로 하는 고성능 규칙 기반 사전 필터.

    • 2단계: OpenAI 호환 API(.envLLM_API_KEY, OpenAI, Grok, DeepSeek, Anthropic 또는 로컬 Ollama 지원)를 활용하는 심층 의미론적 LLM 분류.

  4. Fail-Closed 보안 설계: 분류기 오류, 네트워크 타임아웃 또는 처리되지 않은 예외는 모두 페이로드 차단 및 보안 인시던트 생성으로 기본 처리.

  5. 정책 엔진: 도구별 및 서버별 구성 가능한 규칙 평가(allow, block, confirm, rate_limit).

  6. 인간 확인 게이트: 고위험 작업을 관리자 승인 대기 상태로 보류하며, 구성 가능한 타임아웃 내에 응답이 없으면 fail-closed(거부) 처리.

  7. 변조 증거 감사 추적: 모든 호출, 응답, 정책 판정 및 관리자 결정이 SHA-256 해시 체이닝으로 저장.

  8. 클라우드 컨트롤 센터 대시보드: FastMCP를 통해 /dashboard에서 직접 제공되는 실시간 HTML 관리자 대시보드.


Related MCP server: guardrails-mcp-server

🛠️ 아키텍처 개요

시스템 수준 아키텍처

flowchart TD
    subgraph Clients["AI Clients & Interfaces"]
        C1["Claude Desktop"]
        C2["Claude Code CLI"]
        C3["Google Antigravity"]
        C4["ChatGPT / Custom App"]
    end

    subgraph Gateway["🛡️ MCP-Gatekeeper (FastMCP Cloud)"]
        direction TB
        S["FastMCP Server\nserver.py"]
        
        subgraph Engine["Security & Policy Engines"]
            B["Schema Baseline Manager\n(Rug-Pull Detector)"]
            POL["Policy Engine\n(Allow/Block/Confirm/Rate-Limit)"]
            CONF["Confirmation Manager\n(Human Approval Gate)"]
            
            subgraph Classifier["Two-Stage Response Classifier"]
                R1["Stage 1: Rule Prefilter\n(Fast Pattern Match)"]
                R2["Stage 2: LLM Classifier\n(OpenAI / Grok / DeepSeek / Ollama)"]
            end
        end

        UI["Admin Control Center UI\n/dashboard"]
    end

    subgraph External["Upstream Services & AI APIs"]
        UP["Upstream MCP Servers\n(GitHub, SQL, Web Search, APIs)"]
        LLM["LLM Classifier API\n(OpenAI / Grok / DeepSeek / Ollama)"]
    end

    subgraph Storage["Datastore & Audit"]
        DB[("PostgreSQL / SQLite DB")]
        AUDIT[("Tamper-Evident Audit Log\n(SHA-256 Hash Chained)")]
    end

    Clients -->|MCP SSE / stdio / JSON-RPC| S
    S --> B
    S --> POL
    POL -->|Held Action| CONF
    POL -->|Allowed| UP
    UP -->|Tool Response| Classifier
    Classifier --> R1
    R1 -->|Ambiguous / Suspicious| R2
    R2 -->|API Query| LLM
    Classifier -->|Clean / Safe| Clients
    Classifier -->|Malicious / Timeout| Block["Fail-Closed Block Response"]

    UI -->|Manage Policies & Baselines| DB
    Engine -->|Record Calls & Incidents| DB
    Engine -->|Write Chain Record| AUDIT

상세 실행 흐름 및 보안 파이프라인

sequenceDiagram
    autonumber
    actor Client as AI Agent Client
    participant FastMCP as FastMCP Server (server.py)
    participant Base as Schema Baseline Manager
    participant Policy as Policy Engine
    participant Gate as Human Confirmation Gate
    participant Admin as Admin Dashboard (/dashboard)
    participant Upstream as Upstream MCP Server
    participant Stage1 as Stage 1: Rule Prefilter
    participant Stage2 as Stage 2: LLM Classifier
    participant Audit as SHA-256 Audit Log

    Client->>FastMCP: 1. Request check_tool_security (tool_name, payload)
    
    FastMCP->>Base: 2. Check tool baseline schema status
    alt Schema modified or unapproved (Rug-Pull)
        Base-->>FastMCP: Flagged schema mismatch
        FastMCP->>Audit: Log Rug-Pull Incident
        FastMCP-->>Client: Return Error: Tool schema unapproved
    else Approved Baseline
        Base-->>FastMCP: Baseline OK
    end

    FastMCP->>Policy: 3. Evaluate Call Policy
    alt Policy = Blocked / Rate-Limited
        Policy-->>FastMCP: Action Blocked
        FastMCP-->>Client: Return Error: Blocked by security policy
    else Policy = Held for Confirmation
        Policy->>Gate: 4. Create Pending Approval Request
        Gate->>Admin: Notify Admin on Dashboard
        Admin->>Gate: 5. Admin Approves / Denies (or Timeout)
        alt Denied or Timed Out (Fail-Closed)
            Gate-->>FastMCP: Action Denied
            FastMCP-->>Client: Return Error: High-risk action denied
        else Approved
            Gate-->>FastMCP: Action Approved
        end
    end

    FastMCP->>Stage1: 6. Scan Response (Stage 1 Rule Prefilter)
    alt Stage 1 Matches Known Attack Vector
        Stage1-->>FastMCP: Verdict: Malicious
        FastMCP->>Audit: Record Security Incident & Audit Log
        FastMCP-->>Client: Return Safe Error: Response blocked
    else Stage 1 Suspicious / Ambiguous
        FastMCP->>Stage2: 7. Escalate to Stage 2 LLM Classifier
        Stage2-->>FastMCP: Verdict & Reason (or Fail-Closed on Error)
        alt Verdict = Malicious / Error
            FastMCP->>Audit: Record Security Incident & Audit Log
            FastMCP-->>Client: Return Safe Error: Response blocked
        else Verdict = Clean
            FastMCP->>Audit: Write Hash-Chained Audit Entry
            FastMCP-->>Client: 8. Return Verified Clean Response
        end
    else Stage 1 Clean
        FastMCP->>Audit: Write Hash-Chained Audit Entry
        FastMCP-->>Client: 8. Return Verified Clean Response
    end

🔑 환경 구성 (.env)

게이트웨이는 .env에서 일반 LLM 환경 구성을 읽습니다:

# LLM Security Classifier API Key (Supports OpenAI, DeepSeek, Grok, Ollama)
LLM_API_KEY="your-llm-api-key-here"
LLM_API_URL="https://api.openai.com/v1/chat/completions" # or https://api.x.ai/v1/chat/completions, https://api.deepseek.com/v1/chat/completions
LLM_MODEL="gpt-4o-mini" # or grok-2-latest, deepseek-chat, llama3, etc.

ADMIN_API_KEY="trust-gateway-admin-key-secret"
DATABASE_URL="sqlite+aiosqlite:///mcp_trust_gateway.db"
FAIL_CLOSED=true
CLASSIFIER_TIMEOUT_SECONDS=3.0
CONFIRMATION_TIMEOUT_SECONDS=60

☁️ 배포 및 클라이언트 통합

1. FastMCP Cloud에 배포

  1. 이 저장소를 GitHub에 푸시합니다.

  2. fastmcp.cloud 로 이동하여 새 서버를 생성합니다:

    • 진입점: server.py

    • 환경 변수: LLM_API_KEY = your-api-key-here

  3. Deploy를 클릭합니다. FastMCP Cloud가 엔드포인트를 제공합니다:

    • MCP SSE 서버: https://mcp.fastmcp.cloud/your-username/mcp-trust-gateway/sse

    • 관리자 대시보드: https://mcp.fastmcp.cloud/your-username/mcp-trust-gateway/dashboard


2. 클라이언트 구성

🤖 Google Antigravity 및 Claude Desktop (mcp_config.json)

{
  "mcpServers": {
    "mcp-trust-gateway": {
      "url": "https://mcp.fastmcp.cloud/your-username/mcp-trust-gateway/sse"
    }
  }
}

💻 Claude Code (CLI)

claude mcp add mcp-trust-gateway --transport sse \
  https://mcp.fastmcp.cloud/your-username/mcp-trust-gateway/sse

🧪 테스트 및 적대적 회귀 테스트 스위트

적대적 회귀 테스트 스위트를 포함한 전체 pytest 스위트 실행:

pytest -v

달성 지표

  • 📊 적대적 탐지율: 100% (목표: ≥95%)

  • 📊 오탐률: 0% (목표: <2%)


📝 설계 결정 사항

  1. Fail-Closed 기본값: 모든 모호한 응답, 분류기 타임아웃, 네트워크 문제 또는 승인되지 않은 스키마 수정은 fail-closed 처리(작업 차단 및 관리자 경고)됩니다.

  2. 자격 증명 삭제: 민감한 키와 일치하는 비밀, API 토큰 및 비밀번호는 감사 저장 전에 자동으로 삭제됩니다.

  3. 1단계 고속 필터 + LLM 에스컬레이션: 알려진 악성 패턴은 1단계에서 즉시 차단되어 명백한 공격에 대한 지연 시간과 API 오버헤드를 제거하고, 복잡한 의미론적 분석에는 LLM을 활용합니다.

  4. 변조 증거 해시 체이닝: 모든 로그 항목은 SHA256(actor | action | target | details | prev_hash | timestamp)를 계산하여 부인 방지와 로그 변조 탐지를 보장합니다.

F
license - not found
Not graded
quality - not tested
B
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • A
    license
    Not graded
    quality
    A
    maintenance
    Security gateway for MCP tool calls. Sits between your LLM client and MCP servers, enforcing per-tool policies (allow/block/approve/read-only), logging every call, and pausing dangerous operations for human approval in terminal or Slack.
    2
    1
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    MCP server for AI agent security guardrails. Provides input validation, prompt injection detection, PII redaction, output filtering, policy enforcement, rate limiting, and comprehensive audit logging.
    45
    1
    MIT
  • A
    license
    Not graded
    quality
    A
    maintenance
    A zero-trust security gateway for MCP tool calls, inspecting tool identity, arguments, execution decisions, and returned content before risk reaches your coding agent.
    Apache 2.0
  • A
    license
    Not graded
    quality
    D
    maintenance
    A defensive gateway and firewall for AI agents using MCP servers, scanning tool calls, responses, and manifests for prompt injection, secrets, dangerous commands, and drift before allowing execution.
    MIT

View all related MCP servers

Related MCP Connectors

  • Security firewall for AI agents — scans MCP calls for injection, secrets, and risks.

  • Security scanner for MCP servers. Detect vulnerabilities, prompt injection, and tool poisoning.

  • Scans MCP servers for tool poisoning, prompt injection and supply chain risks.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/sudo-hrmn/MCP-Gatekeeper'

If you have feedback or need assistance with the MCP directory API, please join our Discord server