-
Notifications
You must be signed in to change notification settings - Fork 359
feat: mcpgateway and plugin deployment as a configuration yaml. #1207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Mihai Criveti <[email protected]>
Signed-off-by: Teryl Taylor <[email protected]>
Signed-off-by: Teryl Taylor <[email protected]>
Signed-off-by: Teryl Taylor <[email protected]>
…mcp-runtime Signed-off-by: Teryl Taylor <[email protected]>
Signed-off-by: Teryl Taylor <[email protected]>
Signed-off-by: Teryl Taylor <[email protected]>
Signed-off-by: Teryl Taylor <[email protected]>
Signed-off-by: Teryl Taylor <[email protected]>
Signed-off-by: Teryl Taylor <[email protected]>
Signed-off-by: Teryl Taylor <[email protected]>
Signed-off-by: Teryl Taylor <[email protected]>
Signed-off-by: Teryl Taylor <[email protected]>
Signed-off-by: Teryl Taylor <[email protected]>
…gurable_plugin_deployment
Signed-off-by: Teryl Taylor <[email protected]>
Signed-off-by: Teryl Taylor <[email protected]>
Signed-off-by: Teryl Taylor <[email protected]>
…gurable_plugin_deployment
Signed-off-by: Teryl Taylor <[email protected]>
mcpgateway/tools/builder/common.py
Outdated
| if not template_dir.exists(): | ||
| raise FileNotFoundError(f"Template directory not found: {template_dir}") | ||
|
|
||
| env = Environment(loader=FileSystemLoader(str(template_dir))) |
Check failure
Code scanning / Bandit
By default, jinja2 sets autoescape to False. Consider using autoescape=True or use the select_autoescape function to mitigate XSS vulnerabilities. Error
mcpgateway/tools/builder/common.py
Outdated
| # Auto-detect and assign env files if not specified | ||
| _auto_detect_env_files(config, output_dir, verbose=verbose) | ||
|
|
||
| env = Environment(loader=FileSystemLoader(str(template_dir))) |
Check failure
Code scanning / Bandit
By default, jinja2 sets autoescape to False. Consider using autoescape=True or use the select_autoescape function to mitigate XSS vulnerabilities. Error
mcpgateway/tools/builder/common.py
Outdated
| "plugins_cert_base": os.path.join(certs_rel_base, "mcp/plugins"), | ||
| } | ||
|
|
||
| env = Environment(loader=FileSystemLoader(str(template_dir))) |
Check failure
Code scanning / Bandit
By default, jinja2 sets autoescape to False. Consider using autoescape=True or use the select_autoescape function to mitigate XSS vulnerabilities. Error
Signed-off-by: Teryl Taylor <[email protected]>
Signed-off-by: Teryl Taylor <[email protected]>
Signed-off-by: Teryl Taylor <[email protected]>
Signed-off-by: Teryl Taylor <[email protected]>
Signed-off-by: Teryl Taylor <[email protected]>
Signed-off-by: Teryl Taylor <[email protected]>
Signed-off-by: Teryl Taylor <[email protected]>
Signed-off-by: Teryl Taylor <[email protected]>
Signed-off-by: Teryl Taylor <[email protected]>
Signed-off-by: Teryl Taylor <[email protected]>
…gurable_plugin_deployment
Signed-off-by: Teryl Taylor <[email protected]>
…gurable_plugin_deployment
Signed-off-by: Teryl Taylor <[email protected]>
Signed-off-by: Teryl Taylor <[email protected]>
Signed-off-by: Teryl Taylor <[email protected]>
Signed-off-by: Teryl Taylor <[email protected]>
Signed-off-by: Teryl Taylor <[email protected]>
Signed-off-by: Teryl Taylor <[email protected]>
…dmin site. Signed-off-by: Teryl Taylor <[email protected]>
cforge gateway - Deployment Tool
Closes #1148
Overview
The
cforge gatewaycommand is a powerful deployment tool for MCP Gateway and its external plugins. It provides a unified, declarative way to build, configure, and deploy the complete MCP stack from a single YAML configuration file.Why We Created It
Before
cforge gateway, deploying MCP Gateway with external plugins required:cforge gatewaysolves these challenges by:✅ Automating the entire deployment pipeline from source to running services
✅ Managing mTLS certificates automatically with proper distribution
✅ Generating deployment manifests (Kubernetes or Docker Compose) from a single source
✅ Supporting multiple build modes (Dagger for performance, plain Python for portability)
✅ Validating configurations before deployment
✅ Integrating with CI/CD workflows and secret management
Features
Build System
Deployment Targets
Security
Workflow Automation
Future Directions
The
cforge gatewaytool is actively evolving to support broader MCP ecosystem workflows. Planned enhancements include:MCP Server Lifecycle Management
Currently,
cforge gatewayfocuses on deploying external plugins. Future versions will support the complete lifecycle of MCP servers:This will enable declarative deployment of complete MCP ecosystems from a single configuration file:
Live MCP Server Discovery
Automatic discovery and registration of running MCP servers:
Container Security Policies
Attach security policies to built containers for enhanced compliance and governance:
Example future configuration:
These enhancements will make
cforge gatewaya comprehensive tool for building, securing, deploying, and managing the entire MCP infrastructure stack.Quick Start
Installation
The
cforgeCLI is installed with the MCP Gateway package:pip install -e .Verify installation:
Basic Workflow
Commands
cforge gateway validateValidates the deployment configuration file without making any changes.
Example:
Output:
cforge gateway buildBuilds container images for gateway and/or plugins from source repositories.
Options:
--plugins-onlyfalse--plugin NAME,-p NAME--no-cachefalse--copy-env-templates.env.templatefiles from plugin repostrueExamples:
What it does:
repospecified)ref)containerfileincontextdirectory.env.templatefiles todeploy/env/for customizationcforge gateway certsGenerates mTLS certificate hierarchy for secure gateway ↔ plugin communication.
Example:
What it generates:
Certificate Properties:
mcp-gatewaymcp-plugin-{PluginName}{PluginName}, mcp-plugin-{PluginName}, localhostcforge gateway deployDeploys the complete MCP stack to the target environment.
Options:
--output-dir DIR,-o DIRdeploy/--dry-runfalse--skip-buildfalse--skip-certsfalseExamples:
Deployment Process:
--skip-build)--skip-certsor already exist)kubectl apply -fdocker-compose up -dGenerated Files:
cforge gateway verifyVerifies that the deployed stack is healthy and running.
Options:
--waittrue--timeout SECONDS300Examples:
Checks:
cforge gateway destroyTears down the deployed MCP stack.
Options:
--forcefalseExamples:
What it removes:
cforge gateway generateGenerates deployment manifests without deploying them.
Options:
--output DIR,-o DIRdeploy/Examples:
Use cases:
cforge gateway versionShows version and runtime information.
Output:
Global Options
These options apply to all commands:
--no-dagger--verbose,-vfalseExamples:
Configuration Reference
Deployment Configuration
Top-level deployment settings:
typekubernetesorcomposeproject_namenamespaceGateway Configuration
Gateway server settings:
Build Configuration Fields:
imagereporefmaincontext.containerfileContainerfiletarget* Either
imageORrepomust be specifiedRuntime Configuration Fields:
port4444host_portenv_vars{}mtls_enabledtruemtls_verifytruemtls_check_hostnamefalseKubernetes-specific Fields:
replicas1service_typeClusterIPservice_port4444memory_request256Mimemory_limit512Micpu_request100mcpu_limit500mimage_pull_policyIfNotPresentPlugin Configuration
External plugin settings (array of plugin objects):
Required Fields:
nameBuild Configuration: Same as Gateway (see above)
Runtime Configuration:
port8000expose_portfalseenv_vars{}mtls_enabledtrueplugin_overrides{}Plugin Overrides:
prioritymodeenforce,monitor, ordry-rundescriptiontagshooksprompt_pre_fetch,tool_pre_invoke, etc.Kubernetes-specific: Same as Gateway (see above)
Certificate Configuration
mTLS certificate generation settings:
validity_days825auto_generatetrueca_path./certs/mcp/cagateway_path./certs/mcp/gatewayplugins_path./certs/mcp/pluginsInfrastructure Services
PostgreSQL and Redis are automatically deployed with the MCP Gateway stack using hardcoded defaults:
PostgreSQL (always deployed):
postgres:17mcppostgresmysecretpassword(override withPOSTGRES_PASSWORDenv var)5432Redis (always deployed):
redis:latest6379Connection strings (auto-configured):
DATABASE_URL=postgresql://postgres:${POSTGRES_PASSWORD}@postgres:5432/mcp REDIS_URL=redis://redis:6379/0These services are included in all deployments and cannot currently be disabled or customized via the deployment YAML. To customize PostgreSQL password:
Example Configurations
Example 1: Docker Compose (No mTLS)
File:
examples/deployment-configs/deploy-compose.yamlSimple local deployment for development and testing:
Use case: Quick local testing without security overhead
Deploy:
Access:
Example 2: Docker Compose (With mTLS)
File:
examples/deployment-configs/deploy-compose.mtls.yamlSecure local deployment with mutual TLS:
Use case: Local testing with production-like security
Deploy:
# Certificates are auto-generated during deploy cforge gateway deploy examples/deployment-configs/deploy-compose.mtls.yamlHow mTLS works:
cforge gateway certsgenerates CA + gateway client cert + plugin server certsExample 3: Kubernetes (Pre-built Images)
File:
examples/deployment-configs/deploy-k8s.yamlProduction-ready Kubernetes deployment using pre-built images:
Use case: Production deployment with HA and resource limits
Deploy:
Example 4: Kubernetes (Build from Source)
Building plugins from Git repositories in Kubernetes:
Deploy:
mTLS Configuration Guide
Understanding mTLS in MCP Gateway
mTLS (Mutual TLS) provides:
Certificate Hierarchy
Enabling mTLS
In your configuration:
Certificate Generation
Automatic (recommended):
Manual:
Environment Variables
The deployment tool automatically sets these environment variables:
Gateway (client):
Plugin (server):
PLUGINS_SERVER_SSL_CERTFILE=/certs/server.crt PLUGINS_SERVER_SSL_KEYFILE=/certs/server.key PLUGINS_SERVER_SSL_CA_CERTS=/certs/ca.crt PLUGINS_SERVER_SSL_CERT_REQS=2 # CERT_REQUIREDTroubleshooting mTLS
Problem: Certificate verification fails
Check certificate validity:
Problem: Hostname mismatch errors
Solution: Set
mtls_check_hostname: falsein gateway config, or use service DNS namesProblem: Connection refused
mtls_enabled: trueProblem: Expired certificates
Regenerate:
Then redeploy to distribute new certificates.
Deployment Modes
Dagger Mode (Recommended)
What is Dagger?
Dagger is a programmable CI/CD engine that runs pipelines in containers. It provides:
When to use:
Requirements:
Enable:
Performance benefits:
Plain Python Mode (Fallback)
What is it?
Pure Python implementation using standard tools (
docker,kubectl,git, etc.)When to use:
Requirements:
kubectl(for Kubernetes deployments)git(for building from source)Enable:
# Force plain Python mode cforge gateway --no-dagger deploy deploy.yamlLimitations:
CI/CD Integration
GitHub Actions
GitLab CI
Best Practices
Configuration Management
✅ DO:
deploy.yamlref: v1.2.3)env_varsin comments❌ DON'T:
ref: mainin production (pin versions)Environment Variables
✅ DO:
❌ DON'T:
Certificate Management
✅ DO:
cforgeauto-generate certificates❌ DON'T:
Resource Limits
✅ DO:
❌ DON'T:
High Availability
✅ DO:
❌ DON'T:
Troubleshooting
Build Issues
Problem: Git clone fails
Solution:
repoURL is correctProblem: Docker build fails
Solution:
contextandcontainerfilepathsDeployment Issues
Problem: Pod/container fails to start
Solution:
deploy/env/Problem: mTLS connection fails
Solution:
Verification Issues
Problem: Deployment verification timeout
Solution:
FAQ
Q: Can I use pre-built images instead of building from source?
A: Yes! Just specify
imageinstead ofrepo:Q: How do I update a plugin to a new version?
A: Update the
refand redeploy:Then:
Q: Can I deploy only the gateway without plugins?
A: Yes, just omit the
pluginssection or use an empty array:Q: How do I add custom environment variables?
A: Two ways:
1. In YAML (committed to Git):
2. In .env file (not committed):
# deploy/env/.env.gateway CUSTOM_VAR=valueQ: Can I use cforge in a CI/CD pipeline?
A: Absolutely! See CI/CD Integration section above.
Q: How do I switch between Dagger and plain Python modes?
A:
Q: Where are the generated manifests stored?
A: Default:
deploy/directorydeploy/docker-compose.yaml(Compose mode)deploy/manifests/(Kubernetes mode)Custom location:
Q: How do I access the gateway after deployment?
A:
http://localhost:<host_port>(default: 4444)Additional Resources
examples/deployment-configs/mcpgateway/tools/builder/Getting Help
If you encounter issues:
cforge gateway validate deploy.yamlcforge gateway deploy deploy.yaml --dry-runcforge gateway -v <command>for detailed outputexport MCP_DEBUG=1for stack traces