-
Notifications
You must be signed in to change notification settings - Fork 344
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 gateway
command 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 gateway
solves 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 gateway
tool is actively evolving to support broader MCP ecosystem workflows. Planned enhancements include:MCP Server Lifecycle Management
Currently,
cforge gateway
focuses 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 gateway
a comprehensive tool for building, securing, deploying, and managing the entire MCP infrastructure stack.Quick Start
Installation
The
cforge
CLI is installed with the MCP Gateway package:pip install -e .
Verify installation:
Basic Workflow
Commands
cforge gateway validate
Validates the deployment configuration file without making any changes.
Example:
Output:
cforge gateway build
Builds container images for gateway and/or plugins from source repositories.
Options:
--plugins-only
false
--plugin NAME
,-p NAME
--no-cache
false
--copy-env-templates
.env.template
files from plugin repostrue
Examples:
What it does:
repo
specified)ref
)containerfile
incontext
directory.env.template
files todeploy/env/
for customizationcforge gateway certs
Generates mTLS certificate hierarchy for secure gateway ↔ plugin communication.
Example:
What it generates:
Certificate Properties:
mcp-gateway
mcp-plugin-{PluginName}
{PluginName}, mcp-plugin-{PluginName}, localhost
cforge gateway deploy
Deploys the complete MCP stack to the target environment.
Options:
--output-dir DIR
,-o DIR
deploy/
--dry-run
false
--skip-build
false
--skip-certs
false
Examples:
Deployment Process:
--skip-build
)--skip-certs
or already exist)kubectl apply -f
docker-compose up -d
Generated Files:
cforge gateway verify
Verifies that the deployed stack is healthy and running.
Options:
--wait
true
--timeout SECONDS
300
Examples:
Checks:
cforge gateway destroy
Tears down the deployed MCP stack.
Options:
--force
false
Examples:
What it removes:
cforge gateway generate
Generates deployment manifests without deploying them.
Options:
--output DIR
,-o DIR
deploy/
Examples:
Use cases:
cforge gateway version
Shows version and runtime information.
Output:
Global Options
These options apply to all commands:
--no-dagger
--verbose
,-v
false
Examples:
Configuration Reference
Deployment Configuration
Top-level deployment settings:
type
kubernetes
orcompose
project_name
namespace
Gateway Configuration
Gateway server settings:
Build Configuration Fields:
image
repo
ref
main
context
.
containerfile
Containerfile
target
* Either
image
ORrepo
must be specifiedRuntime Configuration Fields:
port
4444
host_port
env_vars
{}
mtls_enabled
true
mtls_verify
true
mtls_check_hostname
false
Kubernetes-specific Fields:
replicas
1
service_type
ClusterIP
service_port
4444
memory_request
256Mi
memory_limit
512Mi
cpu_request
100m
cpu_limit
500m
image_pull_policy
IfNotPresent
Plugin Configuration
External plugin settings (array of plugin objects):
Required Fields:
name
Build Configuration: Same as Gateway (see above)
Runtime Configuration:
port
8000
expose_port
false
env_vars
{}
mtls_enabled
true
plugin_overrides
{}
Plugin Overrides:
priority
mode
enforce
,monitor
, ordry-run
description
tags
hooks
prompt_pre_fetch
,tool_pre_invoke
, etc.Kubernetes-specific: Same as Gateway (see above)
Certificate Configuration
mTLS certificate generation settings:
validity_days
825
auto_generate
true
ca_path
./certs/mcp/ca
gateway_path
./certs/mcp/gateway
plugins_path
./certs/mcp/plugins
Infrastructure Services
PostgreSQL and Redis are automatically deployed with the MCP Gateway stack using hardcoded defaults:
PostgreSQL (always deployed):
postgres:17
mcp
postgres
mysecretpassword
(override withPOSTGRES_PASSWORD
env var)5432
Redis (always deployed):
redis:latest
6379
Connection strings (auto-configured):
DATABASE_URL=postgresql://postgres:${POSTGRES_PASSWORD}@postgres:5432/mcp REDIS_URL=redis://redis:6379/0
These 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.yaml
Simple 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.yaml
Secure 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.yaml
How mTLS works:
cforge gateway certs
generates CA + gateway client cert + plugin server certsExample 3: Kubernetes (Pre-built Images)
File:
examples/deployment-configs/deploy-k8s.yaml
Production-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_REQUIRED
Troubleshooting mTLS
Problem: Certificate verification fails
Check certificate validity:
Problem: Hostname mismatch errors
Solution: Set
mtls_check_hostname: false
in gateway config, or use service DNS namesProblem: Connection refused
mtls_enabled: true
Problem: 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.yaml
Limitations:
CI/CD Integration
GitHub Actions
GitLab CI
Best Practices
Configuration Management
✅ DO:
deploy.yaml
ref: v1.2.3
)env_vars
in comments❌ DON'T:
ref: main
in production (pin versions)Environment Variables
✅ DO:
❌ DON'T:
Certificate Management
✅ DO:
cforge
auto-generate certificates❌ DON'T:
Resource Limits
✅ DO:
❌ DON'T:
High Availability
✅ DO:
❌ DON'T:
Troubleshooting
Build Issues
Problem: Git clone fails
Solution:
repo
URL is correctProblem: Docker build fails
Solution:
context
andcontainerfile
pathsDeployment 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
image
instead ofrepo
:Q: How do I update a plugin to a new version?
A: Update the
ref
and redeploy:Then:
Q: Can I deploy only the gateway without plugins?
A: Yes, just omit the
plugins
section 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=value
Q: 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.yaml
cforge gateway deploy deploy.yaml --dry-run
cforge gateway -v <command>
for detailed outputexport MCP_DEBUG=1
for stack traces