convez.ai
MCP ServerDevOps & InfraestruturaAvançado
cuongdev

MCP Gateway

cuongdev/mcp-gateway

Gateway centralizado para MCP com auth, RBAC e observabilidade em produção

Ver no GitHub
BomPluginScore · de 0 a 100

Gateway/proxy auto-hospedado para servidores MCP que centraliza autenticação OIDC, controle de acesso fine-grained com Casbin (RBAC/ABAC/ReBAC), circuit breaking, redação de PII e secrets, além de dashboard administrativo completo. Permite que múltiplos agentes de IA conectem a um único endpoint, com segurança, observabilidade e isolamento de falhas automático.

Instalação

$npx convez-ai cuongdev/mcp-gateway

1 comando no terminal: detecta o formato do repositório (marketplace ou plugin avulso) e instala via Claude Code. Requer Node 18+ e o Claude Code instalado.

Métricas

Estrelas
4
Forks
0
Acompanhando
0
Saúde
100%
Último commit
há 5 meses
Versão
v0.8.0-pipeline
Issues abertas
0
Contribuidores
1

Casos de uso

  • Centralizar múltiplos servidores MCP atrás de um único endpoint seguro
  • Implementar controle de acesso granular (RBAC/ABAC) para ferramentas MCP
  • Proteger dados sensíveis com redação automática de PII e secrets
  • Monitorar e auditar chamadas a ferramentas com métricas e logs estruturados

Veredito

Solução madura e enterprise-ready para orquestração de MCP em ambientes multi-agente. Cobre autenticação, autorização, segurança e observabilidade — exatamente o que falta para levar MCP à produção em escala.

README

A tradução para o português deste README ainda está na fila.

🛡️ MCP Gateway

One gateway for all your MCP servers — with the auth, access control, and observability that production actually needs.

CI License: MIT Node TypeScript MCP Version

A self-hosted Model Context Protocol (MCP) gateway / proxy that puts every upstream MCP server behind one endpoint — with OIDC authentication, fine-grained access control (RBAC/ABAC/ReBAC), circuit breaking, PII/secret redaction, a 42-connector catalog, and a full admin dashboard.


💡 Why MCP Gateway?

Connecting AI agents (Claude, Cursor, VS Code…) to MCP servers one-by-one doesn't scale: every client re-configures every server, there's no central auth, no access control, no audit trail, and one flaky upstream can hang everything.

MCP Gateway sits in the middle and gives you a single control plane:

  • 🔌 Register once, use everywhere — agents connect to one /mcp endpoint; the gateway fans out to all upstreams.
  • 🔐 Real authentication — OIDC/SSO login + session cookies + personal access tokens, not just static API keys.
  • 🛂 Fine-grained authorization — Casbin RBAC/ABAC/ReBAC decides exactly who can call which tool.
  • 🧰 Curated tool surfaces — expose only the tools an agent needs via scoped group endpoints, cutting context-window pollution.
  • 🩺 Stays up — per-server circuit breaker + health probes isolate failing upstreams automatically.
  • 🕵️ Stays safe — built-in PII/secret redaction scrubs tool arguments and responses; approval gates protect sensitive tools.
  • 📊 Stays observable — Prometheus metrics, OpenTelemetry tracing, JSONL audit logs, and per-principal usage stats.

Already using MCPJungle? See the honest side-by-side comparison below.


✨ Features

🔌 Unified MCP endpointOne /mcp for all upstreams. Canonical server__tool naming keeps names globally unique.
🧰 Tool GroupsCurated, role-gated subsets of tools, each on its own endpoint (/mcp/groups/:name).
🔐 OIDC + Sessions + PATsSSO login via any OIDC provider, signed session cookies, and personal access tokens.
🛂 Casbin RBAC/ABAC/ReBACPolicy-file access control down to the individual tool.
🩺 Circuit BreakerPer-server state machine (healthy → degraded → open → half-open) + background probe recovery.
🕵️ PII / Secret Redaction22 built-in rules (AWS, GitHub, Stripe, JWT, PEM, credit cards…) with redact / block / warn modes.
✅ Approval WorkflowsMark tools sensitive → calls require admin approval before execution.
🧩 Virtual ToolsCompose multiple upstream tools into one declarative DAG meta-tool.
📦 Connector Catalog42 ready-to-install server templates with a guided install wizard.
🚦 Rate Limit · Quota · CachePer-principal sliding-window limits, daily/monthly quotas, and tool-call caching (memory / SQL / Redis).
🌐 Outbound Proxy MgmtRoute upstream calls through named HTTP/HTTPS/SOCKS5 proxies.
🏢 Multi-tenancyTenant isolation with per-tenant scoping.
📊 ObservabilityPrometheus metrics + OpenTelemetry traces + JSONL audit + usage analytics.
🖥️ Admin DashboardA full web UI for everything above.

📸 Dashboard Tour


🆚 MCP Gateway vs MCPJungle

Both projects solve the same core problem — "one place to manage and connect to all your MCP servers." MCPJungle is a mature, popular, Go single-binary gateway. MCP Gateway is a TypeScript gateway focused on enterprise security, governance, and resilience.

The table reflects MCPJungle as of its v0.4.5 (per its public docs/README) and MCP Gateway v0.8.0. Corrections welcome via PR.

Capability🛡️ MCP Gateway🌿 MCPJungle
Language / distributionTypeScript (Node ≥ 20)Go (single binary)
Unified /mcp endpoint✅✅
Canonical server__tool naming✅✅
Tool Groups (scoped endpoints)✅ updatable, prompts included✅ no updates, no prompts in groups
Transportsstreamable-HTTP, stdiostreamable-HTTP, stdio, SSE (immature)
Client / user authenticationOIDC/SSO + session cookies + PATsStatic bearer tokens only (no OAuth/OIDC)
Authorization modelCasbin RBAC / ABAC / ReBACadmin/user roles + per-client allow-lists
Upstream authbearer token, custom headersbearer, headers, upstream OAuth (beta)
Circuit breaker + health probes✅— (not documented)
PII / secret redaction✅ 22 rules❌
Approval workflows✅❌
Virtual tools (composition)✅ DAG❌
Rate limit · quota · cache✅— (not documented)
Outbound proxy management✅❌
Multi-tenancy✅❌
Connector catalog✅ 42 templates + installerregister via config files
MCP spec coveragetools, prompts, resources, completion, logging, rootstools, prompts, resources
ObservabilityPrometheus + OTel tracing + JSONL audit + usagePrometheus metrics + /health
Admin dashboard✅✅
Maturitynewer (v0.8.0)mature (~1k★, releasing since 2025)
LicenseMITMPL-2.0

Choose MCP Gateway when you need OIDC/SSO user login, fine-grained RBAC/ABAC, audit trails, PII redaction, circuit breaking, approval gates, or multi-tenancy — i.e. production governance & security.

Choose MCPJungle when you want a lightweight, battle-tested Go single binary, the smallest possible footprint, or its browser-based upstream-OAuth auto-negotiation. It's a great, more mature option for simpler setups.

MCPJungle is excellent work and the inspiration for this project — this comparison is about fit, not winners.


🚀 Quick Start

Requires Node.js >= 20.

# Clone
git clone https://github.com/cuongdev/mcp-gateway.git
cd mcp-gateway

# Install dependencies
npm install

# Copy the env template and adjust as needed
cp .env.example .env

# Development mode (no auth, full access)
npm run dev

# Web dashboard (separate Vite dev server)
npm run dev:web

# Enterprise mode (OIDC + strict ACL)
GATEWAY_MODE=enterprise \
OIDC_DISCOVERY_URL=https://your-provider/.well-known/openid-configuration \
OIDC_CLIENT_ID=mcp-gateway \
OIDC_AUDIENCES=mcp-gateway \
GATEWAY_SESSION_SECRET="$(openssl rand -hex 32)" \
npm run dev

Production build & CLI

npm run build              # compile to dist/ + bundle the web dashboard
npm start                  # run the compiled gateway
./bin/mcp-gateway --help   # admin CLI: register servers, manage tools/policies/catalog, etc.

🧩 Key Concepts

Canonical Tool Naming — every tool is exposed as server-name__tool-name, so names stay globally unique across servers (filesystem__read_file, database__query_data).

Tool Groups — curated subsets of tools with dedicated MCP endpoints. An agent on /mcp/groups/data-analyst only sees data tools, reducing context-window pollution.

Dual Mode — Development (no auth, full access, console logging) for local use; Enterprise (OIDC, strict Casbin ACL, file audit, metrics) for production.

Session Manager — abstracts transport differences: HTTP servers use fetch; STDIO servers use persistent child processes with idle timeouts.


📡 API Reference

MCP Endpoints (for AI agents)

MethodPathDescription
POST/mcpMCP JSON-RPC (all tools)
GET/mcpSSE stream (server notifications)
DELETE/mcpClose MCP session
POST/mcp/groups/:nameGroup-scoped MCP JSON-RPC

Admin REST API (for developers)

MethodPathDescription
GET/api/healthGateway health check
GET/api/metricsPrometheus metrics
GET/api/serversList registered servers
POST/api/serversRegister a new MCP server
DELETE/api/servers/:nameDeregister a server
POST/api/servers/:name/syncRe-discover tools from server
GET/api/toolsList all tools (canonical names)
PUT/api/tools/:name/enableEnable a tool
PUT/api/tools/:name/disableDisable a tool
GET/api/groupsList tool groups
POST/api/groupsCreate a tool group
GET/api/groups/:nameGet group details
PUT/api/groups/:nameUpdate a group
DELETE/api/groups/:nameDelete a group
GET/api/policiesList Casbin policies
POST/api/policiesAdd a policy rule
POST/api/policies/reloadReload policies from file
POST/api/rolesAssign role to user

⚙️ Configuration

Server Registration

{
  "servers": [
    {
      "name": "my-db",
      "transport": {
        "type": "streamable-http",
        "url": "http://localhost:8002/mcp",
        "bearerToken": "optional-token"
      },
      "autoDiscover": true
    },
    {
      "name": "local-tools",
      "transport": {
        "type": "stdio",
        "command": "node",
        "args": ["./my-mcp-server.js"],
        "stateful": true
      }
    }
  ]
}

Tool Groups

{
  "groups": [
    {
      "name": "data-analyst",
      "description": "Read-only data tools",
      "tools": ["my-db__query_data", "my-db__get_report"],
      "allowedRoles": ["analyst", "admin"]
    }
  ]
}

Access Control (Casbin)

Edit config/policy.csv:

p, admin, *, *
p, analyst, tool:database__*, execute
p, user, tool:filesystem__read_file, execute

g, admin, analyst
g, analyst, user
g, alice@example.com, admin

📚 Documentation


🗒️ Release Highlights

v0.8.0 — Pipeline Platform

Five user-visible features built on a unified foundation:

  • Circuit Breaker — per-server state machine + probe-loop recovery; mcp_circuit_* metrics; /circuits dashboard.
  • PII / Secret Redaction — 22 built-in rules, redact/block/warn modes, custom per-tenant rules, safe-regex validation; /redaction dashboard.
  • Full MCP Spec Coverage — resources, prompts, completion, logging, roots in addition to tools.
  • Connector Catalog — 42 seed templates, atomic installer with env validation + rollback; /catalog install wizard.
  • Virtual Tools — declarative DAG composition of upstream tools, AJV-validated plans; /virtual-tools editor.
  • v0.7.0-p5 — Outbound proxies: named HTTP/HTTPS/SOCKS5 proxies with 3-level precedence, password redaction, fail-closed routing.
  • v0.6.0-p4 — Multi-tenancy: tenants table, X-Tenant resolution middleware, system admin API, tenant_id scoping.
  • v0.5.0-p3 — Differentiation: approval workflow, webhook dispatcher (HMAC-signed), OpenAPI 3.x → MCP adapter with SSRF guard.
  • v0.4.0-p2 — Hardening: OIDC↔Principal unification, rate limiting, quotas, tool-call caching, OpenTelemetry tracing.
  • v0.3.0-p1 — Parity: MCP client provisioning, user accounts + PATs, prompt registry, usage stats, Postgres adapter, full CLI.

🛠️ Tech Stack

Hono (HTTP) · jose (JWT/OIDC) · Casbin (policy engine) · Pino (logging) · prom-client (metrics) · Zod (config) · React + Vite (dashboard) · libSQL / Postgres (storage)


📄 License

MIT © Cuong Tuan Nguyen

Ver o original no GitHub

Bom para

Relacionados