mcp-gateway
MCP Gateway
MCP 생태계의 보안 미들웨어 — LLM과 도구 서버 사이에 보호 장벽 구축
어떤 문제를 해결하나요?
LLM Agent가 MCP 프로토콜을 통해 외부 도구를 호출할 때 세 가지 핵심 위험이 있습니다:
자격 증명 유출 — 도구 응답에 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에 두 가지 표준화된 도구를 노출합니다:
도구 | 기능 |
| 등록된 모든 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.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