Skip to content

Instantly share code, notes, and snippets.

@dwillitzer
Created July 31, 2025 17:53
Show Gist options
  • Save dwillitzer/683204ed1c9cf5585e4bc4fce25187bf to your computer and use it in GitHub Desktop.
Save dwillitzer/683204ed1c9cf5585e4bc4fce25187bf to your computer and use it in GitHub Desktop.
MCP Unified Gateway: Enterprise-Grade MCP Orchestration Platform

MCP Unified Gateway: Enterprise-Grade MCP Orchestration Platform

Overview

The MCP Unified Gateway is a production-ready orchestration platform that provides centralized management, security, and scaling for Model Context Protocol (MCP) servers. Designed for agencies and enterprises adopting MCP at scale, it enables secure multi-project deployments with credential isolation and comprehensive monitoring.

Core Architecture

Central Gateway Design

┌─────────────────────────────────────────────────────────────┐
│                    MCP Unified Gateway                      │
├─────────────────────────────────────────────────────────────┤
│  Authentication Layer (JWT/mTLS/WorkOS)                    │
│  Authorization Layer (RBAC)                                │
│  Rate Limiting & Audit Logging                             │
├─────────────────────────────────────────────────────────────┤
│              Server Manager                                │
│  ┌─────────────┐ ┌─────────────┐ ┌─────────────┐           │
│  │   Client A  │ │   Client B  │ │   Client C  │           │
│  │ MCP Servers │ │ MCP Servers │ │ MCP Servers │           │
│  │             │ │             │ │             │           │
│  │ • Filesystem│ │ • Database  │ │ • Shell     │           │
│  │ • Git       │ │ • API       │ │ • Custom    │           │
│  │ • Shell     │ │ • Shell     │ │ • Git       │           │
│  └─────────────┘ └─────────────┘ └─────────────┘           │
└─────────────────────────────────────────────────────────────┘

Multi-Transport Support

  • gRPC: High-performance binary protocol with TLS and mTLS
  • HTTP/REST: Standard web API with JSON payloads
  • WebSocket: Real-time bidirectional communication
  • Server-Sent Events (SSE): Streaming updates and notifications

Security Model

Project Isolation

Complete credential and resource isolation between projects:

servers:
  client-alpha-filesystem:
    command: node
    args: ["/opt/mcp-servers/filesystem/index.js"]
    env:
      ALLOWED_DIRECTORIES: "/projects/alpha"
      API_KEY: "${ALPHA_FILESYSTEM_KEY}"
      DATABASE_URL: "${ALPHA_DB_URL}"
    enabled: true
    
  client-beta-filesystem:
    command: node
    args: ["/opt/mcp-servers/filesystem/index.js"] 
    env:
      ALLOWED_DIRECTORIES: "/projects/beta"
      API_KEY: "${BETA_FILESYSTEM_KEY}"
      DATABASE_URL: "${BETA_DB_URL}"
    enabled: true

Authentication & Authorization

Multi-Modal Authentication:

  • JWT Tokens: Industry-standard with configurable issuers
  • Mutual TLS (mTLS): Certificate-based authentication
  • WorkOS Integration: Enterprise SSO with OAuth2/OIDC
  • API Keys: Simple authentication for service accounts

Role-Based Access Control (RBAC):

security:
  authentication:
    type: jwt
    jwt_key: "${JWT_SECRET_KEY}"
    audience: mcp-gateway
    issuers:
      - https://auth.company.com
      
  authorization:
    type: rbac
    policy_file: /etc/mcp-gateway/policies.yaml

Credential Management

Environment Variable Injection:

  • Credentials never exposed to AI agents
  • Per-project environment isolation
  • Support for credential rotation via config hot-reload
  • Integration with external secret management systems

Process Isolation:

  • Each MCP server runs in separate OS process
  • Process groups enable clean resource management
  • Resource limits prevent interference between projects

Operational Capabilities

Health Monitoring & Quality Gates

Comprehensive Health Checks:

health_check:
  enabled: true
  interval: 30s
  timeout: 5s

Real-time Monitoring:

  • Process health and resource usage
  • Tool discovery and availability tracking
  • Response time and error rate monitoring
  • Automatic restart of failed servers

Resource Management

Per-Server Resource Limits:

resources:
  max_memory_mb: 512
  max_cpu: 2

Dynamic Port Allocation:

  • Automatic port assignment prevents conflicts
  • Configurable port ranges
  • Support for reserved port exclusions

Telemetry & Observability

Metrics Collection:

  • Prometheus/VictoriaMetrics integration
  • Custom business metrics
  • Real-time performance dashboards

Distributed Tracing:

  • OpenTelemetry integration
  • Request flow tracking across services
  • Performance bottleneck identification

Structured Logging:

  • JSON-formatted logs with correlation IDs
  • Configurable log levels and rotation
  • Centralized log aggregation support

Audit Logging:

audit:
  enabled: true
  file: /var/log/mcp-gateway/audit.log
  max_size_mb: 100
  max_backups: 10
  max_age_days: 30

Deployment & Scaling

Kubernetes-Native

Container Orchestration:

  • Multi-stage Docker builds with distroless final image
  • Kubernetes manifests with security contexts
  • Service mesh integration (Istio/Linkerd)
  • ConfigMap and Secret management

Scaling Capabilities:

  • Horizontal: Multiple gateway instances with load balancing
  • Vertical: Resource scaling per individual MCP servers
  • Auto-scaling: HPA based on CPU/memory/custom metrics

Service Discovery

Multiple Discovery Backends:

service_discovery:
  type: kubernetes
  namespace: mcp-system
  labels:
    app: mcp-gateway
    version: v1

Supported Backends:

  • Kubernetes service discovery
  • Consul service mesh
  • File-based static configuration
  • Custom discovery plugins

CI/CD Integration

GitOps Workflow:

  • ArgoCD application manifests
  • Environment-specific configuration overlays
  • Automated deployment pipelines
  • Configuration validation and testing

Enterprise Features

Multi-Tenancy

Project-Based Isolation:

  • Separate MCP server instances per project/client
  • Independent credential management
  • Resource quotas and limits per tenant
  • Usage tracking and billing integration

Configuration Management

Hot Reload Support:

# Add new client without restart
servers:
  new-client-database:
    command: python
    args: ["-m", "mcp_server_postgres"]
    env:
      DATABASE_URL: "${NEW_CLIENT_DB_URL}"
    enabled: true

Environment Variable Substitution:

  • Integration with external secret stores
  • Credential rotation without service restart
  • Environment-specific configuration

Rate Limiting & Traffic Management

Configurable Rate Limits:

rate_limit:
  enabled: true
  requests_per_second: 100.0
  burst: 200

Traffic Shaping:

  • Per-project rate limiting
  • Circuit breaker patterns
  • Request timeout management
  • Load balancing strategies

Use Cases

Agency/Consultancy

  • Multi-Client Management: Isolated environments per client
  • Credential Security: Never expose client APIs to AI agents
  • Resource Control: Prevent one client from affecting others
  • Billing Integration: Track usage per client for billing

Enterprise IT

  • Department Isolation: Separate MCP servers per business unit
  • Compliance: Audit logging and access control
  • Integration: Connect to existing authentication systems
  • Monitoring: Comprehensive observability for production operations

Development Teams

  • Environment Management: Dev/staging/production isolation
  • Tool Sharing: Central registry of available MCP tools
  • Development Workflow: GitOps-based configuration management
  • Testing: Isolated environments for testing new MCP servers

Production Readiness

Security Hardening

  • Non-root container execution
  • Read-only filesystem support
  • Security context enforcement
  • Network policy integration

Reliability

  • Graceful shutdown handling
  • Circuit breaker patterns
  • Automatic retry logic
  • Health check integration

Performance

  • Native Go implementation for high concurrency
  • Connection pooling and reuse
  • Efficient JSON-RPC communication
  • Optimized resource utilization

Monitoring

  • SLA/SLO tracking
  • Performance baseline establishment
  • Capacity planning metrics
  • Alert routing and escalation

Getting Started

Basic Configuration

version: "1.0"
gateway:
  name: mcp-unified-gateway
  environment: production
  max_servers: 50

servers:
  filesystem:
    command: node
    args: ["/opt/mcp-servers/filesystem/index.js"]
    env:
      ALLOWED_DIRECTORIES: "/workspace"
    enabled: true

transports:
  grpc:
    enabled: true
    port: 0  # Dynamic allocation
  http:
    enabled: true
    port: 0

security:
  authentication:
    type: jwt
  rate_limit:
    enabled: true
    requests_per_second: 100

Deployment

# Build and deploy
make build
make docker-build
kubectl apply -k deployment/kubernetes/

The MCP Unified Gateway provides enterprise-grade MCP orchestration with the security, scalability, and operational features needed for production deployments across agencies, enterprises, and development organizations. EOF < /dev/null

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment