How qred/qred-mcp-proxy works
1. This repository is a three-layer MCP gateway system: an AWS/CDK infrastructure layer, a Python MCP proxy runtime, and a Python OAuth 2.1 sidecar. The design goal is to present clients with one secure MCP endpoint while hiding the complexity of multiple backend MCP servers and OAuth quirks.
2. The top-level control plane lives in cdk/mcp-proxy/, which is a TypeScript AWS CDK app. It defines the deployable infrastructure boundary: ECS services, load balancing, DNS, IAM roles, CloudWatch logging, and Secrets Manager wiring. The CDK stack is the deployment entrypoint for environment-specific configuration such as dev/staging/prod.
3. The main serving component is docker/mcp_proxy/. This is the aggregated MCP proxy server, implemented in Python, that sits in front of multiple backend MCP servers. It supports both HTTP and STDIO transports, which matters because different MCP clients connect through different protocols.
4. Inside the proxy service, the architecture is split into server-facing logic and support utilities. The server/ modules handle request routing, aggregation, OAuth-aware client handling, and server lifecycle concerns. The utils/ modules handle configuration loading, health checks, startup mitigation, and logging. This indicates the proxy is not just a pass-through; it actively manages backend reachability and startup behavior.
5. The proxy’s core data flow is: MCP client connects to the proxy endpoint, the proxy authenticates the caller, then forwards or aggregates requests to one or more configured backend MCP services. The servers.json configuration in the Docker image and the example config under cdk/mcp-proxy/config/ define which backend servers are exposed through the gateway.
6. Authentication is separated into a dedicated sidecar in docker/mcp_oauth/. This service provides OAuth 2.1 discovery, Dynamic Client Registration, callback forwarding for localhost-based clients, and token validation. The sidecar exists specifically to normalize client behavior across MCP clients with uneven OAuth support.
7. The OAuth sidecar’s external dependency boundary is Google Workspace / Google OAuth. The README shows it relies on Google OAuth client credentials, Workspace domain restrictions, and Google Workload Identity Federation. In practice, this means the service authenticates users through Google, validates membership/identity, and then lets the proxy enforce access to the MCP layer.
8. There is also a cross-cloud trust boundary: AWS hosts the runtime, while GCP provides identity and API permissions. The repo’s configuration and documentation emphasize Workload Identity Federation so the AWS ECS task can securely access Google resources without long-lived Google service account keys.
9. The runtime deployment model is container-based. Both services have Dockerfiles and build scripts, and the CDK references container images likely pushed to ECR. This makes ECS the operational unit, with the proxy and OAuth sidecar running as separate containers in the same AWS deployment footprint.
10. Secrets and configuration are intentionally externalized. AWS Secrets Manager stores Google OAuth credentials, Google WIF JSON, and optional upstream API keys for supported MCP backends. This keeps sensitive identity and backend credentials out of image builds and source-controlled config.
11. Client configuration is treated as a separate enterprise distribution concern. The client-config/deployment/ scripts automate rollout of a single MCP proxy URL into desktop and IDE clients, which reinforces the repository’s “one endpoint for many clients” model rather than per-service client setup.
12. The repository also includes a meaningful testing boundary. tests/oauth/ covers OAuth endpoints, token validation, refresh behavior, and performance, while tests/proxy/ covers config loading, lifecycle, and advanced proxy configuration. The CI workflow under .github/workflows/tests.yml indicates these components are tested separately, matching the service split in the architecture.
13. At a high level, the architecture diagram should show: MCP clients at the edge; OAuth discovery/DCR flow through the sidecar; authenticated traffic into the MCP proxy; proxy fan-out to multiple backend MCP servers; and AWS/GCP as the operational and identity backplanes supporting the system.
Main entry points: mcp-proxy.ts MCP stack · proxy_server.py Proxy routing · mcp_oauth/__main__.py OAuth sidecar · mcp_proxy/__main__.py Proxy service
Components 21
Control plane
CDK deployment boundary and environment wiring
- CDK app · AWS CDK deployment entrypoint and environment selection
cdk/mcp-proxy/bin/mcp-proxy.ts - MCP stack · Defines ECS, load balancing, DNS, IAM, logging, and secrets wiring
cdk/mcp-proxy/lib/mcp-proxy.ts - Service construct · Reusable ECS/service wiring and deployment composition
cdk/mcp-proxy/lib/constructs/service.ts - Volume wiring · Persistent storage and filesystem support for the deployment
cdk/mcp-proxy/lib/constructs/volumes.ts - Config types · Typed configuration and interface definitions for the stack
cdk/mcp-proxy/lib/types/config.ts
Runtime services
Containerized MCP proxy and OAuth sidecar
- Proxy service · Aggregated MCP proxy server container
docker/mcp_proxy/mcp_proxy/__main__.py - Proxy routing · Request routing, transport handling, and proxy lifecycle
docker/mcp_proxy/mcp_proxy/server/proxy_server.py - Aggregator · Combines requests across multiple backend MCP servers
docker/mcp_proxy/mcp_proxy/server/aggregated_proxy_server.py - OAuth client · Client-side handling for authenticated backend calls
docker/mcp_proxy/mcp_proxy/server/oauth_client.py - Proxy utils · Configuration loading, health checks, startup mitigation, and logging
docker/mcp_proxy/mcp_proxy/utils/config_loader.py - OAuth sidecar · OAuth 2.1 discovery, DCR, callback forwarding, and token validation
docker/mcp_oauth/mcp_oauth/__main__.py - OAuth server · Discovery and callback handling for MCP clients
docker/mcp_oauth/mcp_oauth/server.py - Token validation · Validates access tokens and refresh behavior
docker/mcp_oauth/mcp_oauth/token_validation.py - WIF module · Google Workload Identity Federation support
docker/mcp_oauth/mcp_oauth/gcp/google_wif.py
External systems
Clients, backends, and identity providers
- MCP clients · Desktop and IDE clients connecting to the gateway
- Proxy endpoint · Single exposed MCP endpoint for clients
- Backend MCPs · Multiple configured MCP servers behind the gateway
- Google OAuth · Google Workspace and OAuth boundary for user authentication
- AWS runtime · ECS, load balancing, IAM, logging, and secrets hosting
- Google WIF · Workload Identity Federation used by AWS tasks to access Google resources
Client rollout
Scripts that distribute the shared MCP endpoint
- Client rollout · Automates distribution of the shared proxy URL to clients
client-config/deployment/mcp-config-deployment.sh
Connections 24
- CDK app → MCP stack: deploys · CDK entrypoint instantiates the stack
- MCP stack → Service construct: uses · Stack composes ECS/service infrastructure
- MCP stack → Volume wiring: wires · Adds persistent storage and volume support
- MCP stack → Config types: typed by · Configuration and interfaces shape deployment options
- MCP stack → AWS runtime: runs on · Infrastructure is provisioned in AWS
- MCP stack → Google WIF: trusts · AWS runtime federates into Google identity
- Service construct → Proxy endpoint: exposes · Publishes the single MCP endpoint
- Proxy endpoint → MCP clients: serves · Clients connect to the gateway endpoint
- Client rollout → MCP clients: configures · Distributes the shared endpoint into desktop and IDE clients
- MCP clients → OAuth server: discovers auth · OAuth discovery and DCR flow starts at the sidecar
- OAuth server → Google OAuth: authenticates · Sidecar delegates user identity to Google
- OAuth sidecar → Token validation: validates · OAuth sidecar verifies tokens and refresh behavior
- OAuth sidecar → WIF module: federates · Sidecar supports Google workload identity federation
- OAuth sidecar → Proxy endpoint: forwards · Callback and auth completion feed the proxy boundary
- Proxy endpoint → Proxy service: routes to · Authenticated traffic enters the proxy runtime
- Proxy service → Proxy routing: boots · Main module starts the server runtime
- Proxy routing → Aggregator: coordinates · Proxy server uses aggregation for backend fan-out
- Proxy routing → OAuth client: authenticates · Server-facing logic uses OAuth-aware backend clients
- Proxy routing → Proxy utils: depends on · Runtime helpers manage config, health, and startup behavior
- Aggregator → Backend MCPs: fans out to · Requests are forwarded or aggregated across MCP backends
- OAuth client → Backend MCPs: calls · Authenticated backend interactions use the configured MCP servers
- Proxy utils → Backend MCPs: loads config for · Server definitions come from runtime configuration
- MCP stack → Proxy service: packages · Deployment builds the proxy container image into ECS
- MCP stack → OAuth sidecar: packages · Deployment builds the OAuth sidecar image into ECS