mcp-gateway
MCP Gateway
Sichere Zwischenschicht für das MCP-Ökosystem — eine Schutzbarriere zwischen LLM und Tool-Servern
Welches Problem löst es?
Wenn ein LLM-Agent über das MCP-Protokoll externe Tools aufruft, bestehen drei zentrale Risiken:
Credential-Leak — Antworten von Tools können sensible Informationen wie API-Keys oder Tokens enthalten, die direkt im LLM-Kontext offengelegt werden.
Verlust privater Daten — Persönliche Benutzerdaten (Name, Ausweisnummer, Bankkartennummer) können in der Tool-Aufrufkette übertragen werden.
Böswillige Tool-Injektion — In Tool-Beschreibungen können Prompt-Injection-Anweisungen versteckt sein, die den Agenten zu gefährlichen Aktionen verleiten.
MCP Gateway fungiert als Proxy-Ebene, die den gesamten Datenverkehr abfängt und vor dem Erreichen des Agenten sicher filtert (Anfragen/Antworten).
Related MCP server: arc-gate-mcp
Architekturübersicht
┌─────────────┐ ┌──────────────────────────────────┐ ┌─────────────┐
│ │ │ MCP Gateway │ │ │
│ LLM Agent │ ───► │ ┌──────────┐ ┌──────────────┐ │ ───► │ MCP Server │
│ │ │ │ Sanitize │ │ Plugin │ │ │ (tools) │
│ │ ◄─── │ │ Request │ │ Pipeline │ │ ◄─── │ │
└─────────────┘ │ └──────────┘ └──────────────┘ │ └─────────────┘
│ ▲ │ │
│ │ ┌──────────▼──┐ │
│ │ │ Sanitize │ │
│ │ │ Response │ │
│ │ └─────────────┘ │
└──────────────────────────────────┘Kernablauf:
Anfrage-Richtung: Die Plugin-Pipeline bereinigt Parameter (z. B. Entfernen von PII, Filtern von Injektionsanweisungen)
Antwort-Richtung: Token-Maskierung und Filterung sensibler Informationen für Tool-Rückgabewerte
Startphase: Der Security Scanner führt eine Reputationsbewertung aller konfigurierten MCP-Server durch
Schnellstart
Installation
git clone <your-repo-url>
cd mcp-gateway
pip install -e .Optionale Abhängigkeiten:
pip install -e .[presidio] # 启用 PII 检测(基于 Microsoft Presidio)Minimalkonfiguration
Erstellen Sie mcp.json im Projektstammverzeichnis:
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "."]
}
}
}Start
# 启用基础 Token 掩码
mcp-gateway -p basic
# 启用 Token 掩码 + PII 检测
mcp-gateway -p basic -p presidio
# 调试模式
LOGLEVEL=DEBUG mcp-gateway -p basicIntegration in Cursor / 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", "."]
}
}
}
}
}Sicherheitsfunktionen
Token-Maskierung (basic-Plugin)
Automatische Erkennung und Ersetzung sensibler Anmeldeinformationen in Antworten. Unterstützt 12 gängige Schlüsselformate von Cloud-Plattformen und Entwicklungswerkzeugen:
Typ | Beispielformat |
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-Erkennung (presidio-Plugin)
Basierend auf der Microsoft-Presidio-Engine werden personenbezogene Daten im Text automatisch erkannt und anonymisiert:
Kreditkartennummern, IP-Adressen, E-Mail-Adressen
Telefonnummern, Sozialversicherungsnummern (SSN)
Weitere Entitätstypen finden Sie in der Presidio-Dokumentation
pip install -e .[presidio]
mcp-gateway -p presidioSicherheitsscanner (--scan)
Vor dem Start werden alle MCP-Server einer Reputationsbewertung und Tool-Beschreibungsanalyse unterzogen:
mcp-gateway --scan -p basicScan-Dimensionen:
Reputationsbewertung — Berechnung einer Gesamtbewertung basierend auf GitHub-Daten (Stars, Forks, Issue-Aktivität) und NPM-Downloadzahlen
Tool-Beschreibungs-Scan — Erkennt versteckte Prompt-Injection-Anweisungen, Verweise auf sensible Dateipfade und Anweisungen für gefährliche Aktionen
Automatische Blockierung — Server mit einem Reputationswert unter dem Schwellenwert (Standard: 30 Punkte) werden als
blockedmarkiert und am Laden gehindert
Die Scan-Ergebnisse werden in die Konfigurationsdatei geschrieben:
{
"servers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "."],
"blocked": "passed"
}
}
}Statuswerte: "passed" (sicher) | "blocked" (blockiert) | "skipped" (manuell übersprungen) | null (nicht gescannt)
Aufruf-Tracking
Xetrack-Tracing-Plugin
Zeichnet den vollständigen Kontext aller Tool-Aufrufe auf und unterstützt SQLite- und DuckDB-Abfragen:
pip install xetrack
mcp-gateway -p xetrackKonfiguration über Umgebungsvariablen:
XETRACK_DB_PATH— Pfad zur SQLite-DatenbankXETRACK_LOGS_PATH— Verzeichnis für Logdateien
{
"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/"
}
}
}
}Abfragebeispiel:
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;Proxy-Tools
Das Gateway stellt dem LLM zwei standardisierte Tools bereit:
Tool | Funktion |
| Ruft die Fähigkeitsliste aller registrierten MCP-Server ab, um dem LLM die Auswahl geeigneter Tools zu erleichtern |
| Führt über das Gateway beliebige MCP-Tool-Aufrufe aus und übernimmt automatisch die Sicherheitsverarbeitung von Anfrage/Antwort |
Plugin-Entwicklung
Das Plugin-System basiert auf ABC-Basisklassen + Dekorator-Registrierungsmuster:
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 responsePlugins werden automatisch über den PluginManager erkannt und geladen und unterstützen die bidirektionale Abfangung von Anfrage/Antwort.
Projektstruktur
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.pyLicense
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