Enterprise Mcp Gateway

io.github.BenjaminJ由 GitHub 账号 BenjaminJ 发布v1.0.0更新于 Oct 24, 2026

Production-grade MCP Gateway in Go with RBAC, in-flight PII redaction, and audit logging.

概览

AI 生成的概览

一个自托管的 Go MCP 网关,把企业后端暴露为工具,并提供基于角色的工具权限、PII 脱敏和 JSON 审计日志。

可以做什么
从 OpenAPI 3.0 或 Swagger 规范自动注册 MCP 工具,并把调用转发到 CRM 接口、Java/Go 微服务和数据库等后端,README 中示例工具包括列出客户、查询客户详情和创建支持工单。按令牌到角色的规则限制每个调用方可见和可调用的工具。在工具响应到达模型前,对信用卡号、SSN、邮箱、电话、AWS 密钥、JWT、GitHub 令牌及自定义正则进行脱敏。输出结构化 JSON 审计记录,包含调用方身份、工具名、参数哈希、延迟和脱敏计数。支持面向桌面客户端的 stdio 传输,以及面向共享或分布式部署的 HTTP SSE 传输。
适用场景
适用于组织希望在 AI 助手与内部 API 之间建立统一受管控入口,并需要按角色控制工具权限、遮蔽 PII 和保留审计轨迹的场景。也适合已用 OpenAPI 规范描述后端、希望无需编写胶水代码即可生成工具的团队。
运行要求
以本地进程方式运行,需用 Go 1.24 或更高版本从源码构建,或使用 Docker 镜像;未发布任何软件包。需要一份 YAML 配置文件,列出令牌、角色、脱敏规则、审计设置和 OpenAPI 连接器规范,并需要可访问的后端服务。令牌通过命令行参数传入,后端凭据写在配置文件的连接器请求头中。
安装前请注意
README 将角色令牌作为命令行参数传入,可能出现在进程列表和客户端配置文件中,应视其为机密。Authorization 等后端凭据保存在配置文件里。网关可创建支持工单等记录,授予写权限前应审查角色规则。审计日志会记录调用方身份和工具使用情况,脱敏效果取决于配置规则是否完整。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Enterprise Mcp Gateway,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

Enterprise MCP Gateway

[CI Status] [Last Commit] [Go Version] [MCP Version] [Glama Score] [Security] [License]

Production-grade, high-performance Model Context Protocol (MCP) Gateway in Go.
A secure, audited, and PII-sanitized bridge connecting AI agents (Claude Desktop, Cursor, Antigravity, LangGraph) to enterprise backends (OpenAPI, Java/Spring Boot, Go microservices, relational databases).

[enterprise-mcp-gateway Glama Card]

[Enterprise MCP Gateway Live Demo]
Live Demo: AI Agent querying CRM with in-flight PII & card redaction (left) while the Gateway streams structured JSON audit logs in real-time (right).


🚀 Key Features

  • ⚡ Blazing Fast & Lightweight: Single static Go binary (<25MB resident memory footprint, sub-millisecond routing overhead, zero external runtime dependencies).
  • 🛡️ High-Performance PII & Secret Redaction: Real-time stream and JSON-key masking (Credit Cards with Luhn checksum validation, SSNs, emails, phone numbers, AWS keys, JWTs, GitHub PATs, and custom regex rules) before tool responses reach LLMs.
  • 🔐 Role-Based Tool Governance (RBAC): Token-to-role resolution that limits tool visibility in tools/list and enforces execution permissions during tools/call.
  • 🔌 Dynamic OpenAPI / Swagger Connector: Instantly registers validated MCP tools directly from OpenAPI 3.0/Swagger YAML or JSON specs without writing backend glue code.
  • 📜 Structured JSON Audit Logging: Emits tamper-resistant, structured JSON logs containing caller identity, tool invoked, SHA-256 hashed parameters, execution latency, and PII redaction metrics.
  • 🔄 Dual Transport Support: Fully compliant JSON-RPC 2.0 engine supporting both standard stdio (for Claude Desktop / Cursor) and HTTP Server-Sent Events (SSE) for distributed microservices.

🏗️ Architecture

┌────────────────────────────────────────────────────────┐│           AI Client (Claude / Cursor / Agent)          │└──────────────────────────┬─────────────────────────────┘                           │ JSON-RPC 2.0 (stdio or SSE)                           ▼┌────────────────────────────────────────────────────────┐│           Enterprise MCP Gateway (Single Go Binary)    ││                                                        ││  1. Transport Layer (pkg/mcp/transport)                ││     - Stdio & HTTP-SSE Transceivers                    ││  2. Security & Auth Guard (pkg/governance/rbac)        ││     - Token authentication & least-privilege filtering ││  3. Router & Tool Registry (pkg/mcp/protocol)          ││     - JSON-RPC 2.0 & MCP handshake engine              ││  4. Backend Dispatcher (pkg/connector/openapi)         ││     - Dynamic OpenAPI 3.0 path/query/body mapper       ││  5. Sanitization Engine (pkg/sanitizer/pii)            ││     - Zero-alloc PII, secret, & JSON key redactor      ││  6. Structured Audit Logger (pkg/audit)                ││     - Cryptographic JSON event trail for SIEM          │└──────────────────────────┬─────────────────────────────┘                           │ Authorized & Sanitized Calls                           ▼┌────────────────────────────────────────────────────────┐│      Internal Enterprise Services (Java / Go / DBs)    │└────────────────────────────────────────────────────────┘

📦 Quick Start

1. Build from Source

Ensure you have Go 1.24+ installed:

bash
# Clone the repositorygit clone https://github.com/BenjaminJ/enterprise-mcp-gateway.gitcd enterprise-mcp-gateway
# Build gateway and mock backend servergo build -o bin/mcp-gateway ./cmd/gatewaygo build -o bin/mockserver ./cmd/mockserver

2. Run the Mock Enterprise Backend (Terminal 1)

bash
./bin/mockserver --port 8081

3. Run the Gateway with Sample Config (Terminal 2)

Option A: Stdio Mode (Default)
bash
./bin/mcp-gateway --config ./examples/config.yaml --token "agent-support-key"
Option B: HTTP Server-Sent Events (SSE) Mode
bash
./bin/mcp-gateway --config ./examples/config.yaml --transport sse --port 8080

4. Stream Live Audit Logs in Real-Time (Terminal 3)

Follow and format structured audit records as tools execute:

PowerShell (Windows):

powershell
Get-Content -Path .\audit.log -Wait -Tail 10 | ForEach-Object {    if ($_ -match '^\s*\{') {        $e = $_ | ConvertFrom-Json        $time = ([DateTime]$e.timestamp).ToLocalTime().ToString("HH:mm:ss")        $statusColor = if ($e.status -eq "SUCCESS") { "Green" } else { "Red" }        $redactColor = if ($e.pii_redacted_count -gt 0) { "Yellow" } else { "DarkGray" }        Write-Host "[$time] " -NoNewline -ForegroundColor DarkGray        Write-Host "[$($e.status)] " -NoNewline -ForegroundColor $statusColor        Write-Host "$($e.tool) " -NoNewline -ForegroundColor Cyan        Write-Host "(Role: $($e.role), Latency: $($e.duration_ms)ms, Redacted: $($e.pii_redacted_count))" -ForegroundColor $redactColor    }}

Bash / Linux / macOS (jq):

bash
tail -f audit.log | jq -c '{time: .timestamp, status: .status, tool: .tool, role: .role, latency_ms: .duration_ms, redacted: .pii_redacted_count}'

🔍 Verification with Anthropic Official MCP Inspector

You can test and inspect the gateway using Anthropic's official @modelcontextprotocol/inspector:

Test via Stdio:

bash
npx @modelcontextprotocol/inspector ./bin/mcp-gateway --config ./examples/config.yaml --token agent-support-key

Test via SSE:

  1. Start the gateway in SSE mode:
    bash
    ./bin/mcp-gateway --config ./examples/config.yaml --transport sse --port 8080
  2. Open the inspector pointing to the SSE endpoint:
    bash
    npx @modelcontextprotocol/inspector http://localhost:8080/sse

💻 Claude Desktop Integration

To connect Claude Desktop to your enterprise systems through enterprise-mcp-gateway:

  1. Open your Claude Desktop configuration file:

    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    • Linux: ~/.config/Claude/claude_desktop_config.json
    • Windows: %APPDATA%\Claude\claude_desktop_config.json
  2. Add enterprise-mcp-gateway to the mcpServers object:

json
{  "mcpServers": {    "enterprise-gateway": {      "command": "/absolute/path/to/enterprise-mcp-gateway/bin/mcp-gateway",      "args": [        "--config",        "/absolute/path/to/enterprise-mcp-gateway/examples/config.yaml",        "--token",        "agent-support-key"      ]    }  }}
  1. Restart Claude Desktop. The enterprise tools (listCustomers, getCustomerDetails, createSupportTicket, etc.) will appear with a hammer icon in the prompt interface.

⚙️ Configuration Guide (config.yaml)

yaml
server:  name: "enterprise-mcp-gateway"  version: "1.0.0"  transport: "stdio"       # "stdio" or "sse"  host: "0.0.0.0"  port: 8080
governance:  enabled: true  default_role: "support_agent"  tokens:    "agent-ro-secret": "readonly_agent"    "agent-support-secret": "support_agent"    "admin-master-secret": "admin"  roles:    readonly_agent:      allowed_tools:        - "list*"        - "get*"    support_agent:      allowed_tools:        - "list*"        - "get*"        - "createSupportTicket"    admin:      allowed_tools:        - "*"
sanitizer:  enabled: true  mask_card_numbers: true  # Luhn-verified Credit Card masking  mask_ssn: true           # US SSN masking  mask_secrets: true       # Private keys, AWS keys, JWTs, PATs  sensitive_keys:    - "password"    - "secret"    - "token"    - "apiKey"    - "ssn"    - "creditCard"  custom_regex:    - name: "Internal Employee ID"      pattern: "\\bEMP-[0-9]{6}\\b"      replacement: "[REDACTED-EMP-ID]"
audit:  enabled: true  log_path: "stdout"       # "stdout" or path to file e.g. "/var/log/mcp-audit.log"  hash_inputs: true        # SHA-256 hashes tool arguments for compliance
connectors:  - name: "enterprise-crm"    type: "openapi"    spec_file: "./examples/crm-openapi.yaml"    base_url: "http://localhost:8081"    headers:      Authorization: "Bearer backend-secret-token"      X-Gateway-Source: "enterprise-mcp-gateway"    timeout_seconds: 15

🧪 Testing

Run all unit and end-to-end integration tests:

bash
# Run all unit and integration testsgo test -v ./...
# Run tests with the Go race detector enabledgo test -race ./...

🐳 Docker Deployment

bash
# Build lightweight Docker imagedocker build -t enterprise-mcp-gateway:latest .
# Run container in SSE modedocker run -d -p 8080:8080 -p 8081:8081 enterprise-mcp-gateway:latest --transport sse --port 8080

📄 License

MIT License.

来源:README.md,提交 76bbf14

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v1.0.0最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分