MCP-Gatekeeper
🛡️ MCP-Gatekeeper
Model Context Protocol(MCP)クライアントとアップストリームサーバーのためのランタイムセキュリティゲートウェイ&FastMCPサーバー。
MCP-Gatekeeper は多層防御プロキシおよび FastMCP サーバーであり、**ツールリストの更新とツール応答の100%**を検査して、ツールポイズニング、応答由来のプロンプトインジェクション(例:MCPoison / CurXecute 攻撃)、ツールスキーマのサイレント改ざん(「ラグプル」)、および不正な高リスク操作を防ぎます。
fastmcp.cloud への即時デプロイ、または fastmcp CLI によるローカル実行を想定して設計されています。
🚀 主要な機能と特長
FastMCP Cloud 対応:単一ファイルの FastMCP エントリポイント(
server.py)であり、SSE および HTTP トランスポートを使用して fastmcp.cloud に直接デプロイできます。ラグプルスキーマ保護:接続時にツールスキーマのベースラインを取得し、ツールリストの更新の100%を承認済みベースラインと差分比較して、承認されていないツール変更をデフォルトでブロックします。
2段階応答インジェクションスキャナー:
ステージ1:既知の命令ハイジャック、データ持ち出しトラップ、シェルインジェクションを対象とする高性能なルールベースの事前フィルター。
ステージ2:OpenAI 互換の任意の API(
.envのLLM_API_KEY。OpenAI、Grok、DeepSeek、Anthropic、またはローカル Ollama に対応)を利用する深層セマンティック LLM 分類。
フェイルクローズのセキュリティ設計:分類器の障害、ネットワークタイムアウト、または未処理の例外はすべて、デフォルトでペイロードをブロックし、セキュリティインシデントを生成します。
ポリシーエンジン:ツール単位・サーバー単位で設定可能なルール評価(
allow、block、confirm、rate_limit)。人間による確認ゲート:高リスク操作を管理者の承認待ちとして保留し、設定可能なタイムアウト内に回答がない場合はフェイルクローズ(拒否)します。
改ざん検知可能な監査証跡:すべての呼び出し、応答、ポリシー判定、管理者の決定が SHA-256 ハッシュチェーンとともに保存されます。
クラウドコントロールセンターのダッシュボード: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 へのデプロイ
このリポジトリを GitHub にプッシュします。
fastmcp.cloud にアクセスし、新しいサーバーを作成します:
エントリポイント:
server.py環境変数:
LLM_API_KEY=your-api-key-here
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%)
📝 設計上の決定
フェイルクローズのデフォルト:あいまいな応答、分類器のタイムアウト、ネットワーク障害、または未承認のスキーマ変更はすべてフェイルクローズ(アクションをブロックして管理者に警告)します。
資格情報の秘匿化(レダクション):機密キーに一致するシークレット、API トークン、パスワードは、監査ストレージに保存される前に自動的に秘匿化されます。
ステージ1の高速フィルター+LLM エスカレーション:既知の悪意のあるパターンはステージ1で即座に遮断され、明白な攻撃に対するレイテンシーと API オーバーヘッドを排除しつつ、複雑なセマンティック分析には LLM を活用します。
改ざん検知可能なハッシュチェーン:すべてのログエントリは
SHA256(actor | action | target | details | prev_hash | timestamp)を計算し、否認防止とログ改ざんの検出を保証します。
This server cannot be installed
Maintenance
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
- AlicenseNot gradedqualityAmaintenanceSecurity 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.21MIT
- AlicenseNot gradedqualityCmaintenanceMCP server for AI agent security guardrails. Provides input validation, prompt injection detection, PII redaction, output filtering, policy enforcement, rate limiting, and comprehensive audit logging.451MIT
- AlicenseNot gradedqualityAmaintenanceA 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
- AlicenseNot gradedqualityDmaintenanceA 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
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.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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