mcp-gateway
MCP Gateway
MCP エコシステムのセキュリティ中間層 — LLM とツールサーバーの間に防護バリアを構築
何を解決するのか?
LLM Agent が MCP プロトコルを通じて外部ツールを呼び出す際、3つの主要なリスクがあります:
認証情報の漏洩 — ツールが返すレスポンスに API Key、Token などの機密情報が含まれ、そのまま LLM コンテキストに露出する可能性があります
プライバシーデータの外部流出 — ユーザーの個人情報(氏名、身分証番号、銀行カード番号)がツール呼び出しの連鎖の中で送信される可能性があります
悪意のあるツール注入 — ツールの説明に prompt injection 命令が隠され、Agent に危険な操作を実行させてしまう可能性があります
MCP Gateway はプロキシレイヤーとしてすべてのトラフィックを傍受し、リクエスト/レスポンスが Agent に到達する前にセキュリティフィルタリングを実行します。
Related MCP server: arc-gate-mcp
アーキテクチャ概要
┌─────────────┐ ┌──────────────────────────────────┐ ┌─────────────┐
│ │ │ MCP Gateway │ │ │
│ LLM Agent │ ───► │ ┌──────────┐ ┌──────────────┐ │ ───► │ MCP Server │
│ │ │ │ Sanitize │ │ Plugin │ │ │ (tools) │
│ │ ◄─── │ │ Request │ │ Pipeline │ │ ◄─── │ │
└─────────────┘ │ └──────────┘ └──────────────┘ │ └─────────────┘
│ ▲ │ │
│ │ ┌──────────▼──┐ │
│ │ │ Sanitize │ │
│ │ │ Response │ │
│ │ └─────────────┘ │
└──────────────────────────────────┘コアフロー:
リクエスト方向:Plugin Pipeline がパラメータをマスキング処理(PII の除去、注入命令のフィルタリングなど)します
レスポンス方向:ツールの戻り値に対して Token マスキング、機密情報のフィルタリングを行います
起動段階:Security Scanner が設定済みのすべての MCP Server に対してレピュテーション評価を実施します
クイックスタート
インストール
git clone <your-repo-url>
cd mcp-gateway
pip install -e .任意の依存関係:
pip install -e .[presidio] # 启用 PII 检测(基于 Microsoft Presidio)最小構成
プロジェクトルートに mcp.json を作成します:
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "."]
}
}
}起動
# 启用基础 Token 掩码
mcp-gateway -p basic
# 启用 Token 掩码 + PII 检测
mcp-gateway -p basic -p presidio
# 调试模式
LOGLEVEL=DEBUG mcp-gateway -p basicCursor / Claude Desktop への統合
{
"mcpServers": {
"mcp-gateway": {
"command": "mcp-gateway",
"args": [
"--mcp-json-path", "~/.cursor/mcp.json",
"-p", "basic",
"-p", "xetrack"
],
"servers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "."]
}
}
}
}
}{
"mcpServers": {
"mcp-gateway": {
"command": "<python-path>",
"args": [
"-m", "mcp_gateway.server",
"--mcp-json-path", "<path-to-config>",
"-p", "basic"
],
"servers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "."]
}
}
}
}
}セキュリティ保護機能
Token マスキング(basic プラグイン)
レスポンス内の機密認証情報を自動識別して置換します。主要なクラウドプラットフォームおよび開発ツールの12種類のキー形式に対応しています:
タイプ | 例の形式 |
AWS Access Key |
|
GitHub Token |
|
Azure Client Secret |
|
GCP API Key |
|
JWT Token |
|
HuggingFace Token |
|
GitLab Session Cookie |
|
Slack App Token |
|
Microsoft Teams Webhook |
|
mcp-gateway -p basicPII 検出(presidio プラグイン)
Microsoft Presidio エンジンに基づき、テキスト内の個人特定情報を自動認識して匿名化します:
クレジットカード番号、IP アドレス、電子メール
電話番号、社会保障番号(SSN)
その他のエンティティタイプについては Presidio ドキュメント を参照してください
pip install -e .[presidio]
mcp-gateway -p presidioセキュリティスキャナー(--scan)
起動前にすべての MCP Server に対してレ誉为評価とツール説明を分析します:
mcp-gateway --scan -p basicスキャンの指標:
レピュテーション評価 — GitHub データ(Star、Fork、Issue のアクティビティ)と NPM ダウンロード数に基づいて総合スコアを計算します
ツール説明のスキャン — 隠された prompt injection 命令、機密ファイルパスへの参照、危険な操作命令を検出します
自動ブロック — レピュテーションスコアが基準値(デフォルト 30 点)未満の Server は
blockedとマークされ、ロードがブロックされます
スキャン結果は設定ファイルに書き込まれます:
{
"servers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "."],
"blocked": "passed"
}
}
}ステータス値:"passed"(安全)| "blocked"(ブロック)| "skipped"(手動スキップ)| null(未スキャン)
呼び出しトレーシング
Xetrack トレーシングプラグイン
すべてのツール呼び出しの完全なコンテキストを記録し、SQLite と DuckDB でのクエリをサポートします:
pip install xetrack
mcp-gateway -p xetrack環境変数の設定:
XETRACK_DB_PATH— SQLite データベースのパスXETRACK_LOGS_PATH— ログファイルのディレクトリ
{
"mcpServers": {
"mcp-gateway": {
"command": "mcp-gateway",
"args": ["--mcp-json-path", "~/.cursor/mcp.json", "-p", "xetrack"],
"env": {
"XETRACK_DB_PATH": "tracing.db",
"XETRACK_LOGS_PATH": "logs/"
}
}
}
}クエリ例:
from xetrack import Reader
df = Reader("tracing.db").to_df()-- DuckDB
INSTALL sqlite; LOAD sqlite; ATTACH 'tracing.db' (TYPE sqlite);
SELECT server_name, capability_name, content_text FROM db.events LIMIT 10;プロキシツール
Gateway は LLM に以下の2つの標準化ツールを公開します:
ツール | 機能 |
| 登録済みのすべての MCP Server の能力リストを取得し、LLM が適切なツールを選択するのを支援します |
| Gateway を介して任意の MCP ツール呼び出しを実行し、リクエスト/レスポンスのセキュリティ処理を自動的に行います |
プラグイン開発
プラグインシステムはABC ベースクラス + デコレータ登録パターンに基づいています:
from mcp_gateway.plugins.base import GuardrailPlugin
from mcp_gateway.plugins.manager import register_plugin
@register_plugin
class MyPlugin(GuardrailPlugin):
@property
def name(self) -> str:
return "my-plugin"
def process_request(self, context):
# 请求方向的处理逻辑
return context.arguments
def process_response(self, context, response):
# 响应方向的处理逻辑
return responseプラグインは PluginManager によって自動検出・ロードされ、リクエスト/レスポンスの双方向インターセプトをサポートします。
プロジェクト構造
mcp_gateway/
├── __init__.py # 包入口
├── server.py # MCP Server 生命周期管理
├── gateway.py # 动态工具注册、CLI 参数解析
├── config.py # 配置文件加载
├── sanitizers.py # 请求/响应安全分发
├── plugins/
│ ├── base.py # Plugin ABC 基类
│ ├── manager.py # 插件发现、注册、Pipeline
│ ├── guardrails/
│ │ ├── basic.py # Token 掩码插件
│ │ └── presidio.py # PII 检测插件
│ └── tracing/
│ └── xetrack.py # 调用追踪插件
├── security_scanner/
│ ├── scanner.py # 扫描器主入口
│ ├── github_collector.py # GitHub API 数据采集
│ ├── npm_collector.py # NPM Registry 数据采集
│ ├── smithery_collector.py# Smithery 市场数据采集
│ ├── project_analyzer.py # 综合信誉评分算法
│ └── tool_poisoning_analyzer.py # 工具描述安全分析
└── tests/
├── test_sanitizers.py
├── test_tool_poisoning_analyzer.py
├── test_plugin_pipeline.py
└── test_config.pyライセンス
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
- FlicenseNot gradedqualityNot gradedmaintenanceA transparent proxy and execution firewall that intercepts and audits AI agent tool calls against configurable security policies before forwarding them to downstream MCP servers. It provides safe execution environments with features like data redaction, anti-loop protection, and unified alert dispatching.
- AlicenseAqualityBmaintenanceRuntime governance proxy for MCP tool calls. Inspects tool results for prompt injection and capability abuse before they reach your agent, blocking attacks that exploit the MCP trust boundary.12AGPL 3.0
- FlicenseNot gradedqualityBmaintenanceEnables secure interaction between LLMs and MCP tools by applying zero-trust security controls, including sensitive data masking, file system protection, and policy enforcement.
- AlicenseAqualityBmaintenanceProvides prompt injection detection, PII/secrets redaction, and an audit trail for AI agents via MCP tools.4MIT
Related MCP Connectors
Security firewall for AI agents — scans MCP calls for injection, secrets, and risks.
The WAF for agents. Pattern-based + heuristic firewall scans prompts, RAG documents, tool argume...
MCP server for secureFlows: token-free URL builders and integration-linting tools for AI agents.
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/wxsh-hub/mcp-gateway'
If you have feedback or need assistance with the MCP directory API, please join our Discord server