Skip to content

Commit ac539ba

Browse files
committed
feat: Implement profile-based Docker containerization architecture
- Replace separate Docker CLI with integrated workflow profiles - Add dynamic Dockerfile generation with environment detection - Implement build-only, build-and-push, and custom dev profiles - Add comprehensive Docker architecture documentation - Include full smoke test suite validating end-to-end workflows - Support both development (local source) and production deployments This architectural change consolidates Docker functionality into the main MCPStack workflow system, enabling containerized MCP deployments through a unified profile-based interface.
1 parent 19dabcf commit ac539ba

38 files changed

Lines changed: 4412 additions & 676 deletions

.dockerignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
__pycache__/
2+
*.pyc
3+
*.pyo
4+
*.pyd
5+
.Python
6+
env/
7+
venv/
8+
.venv/
9+
pip-log.txt
10+
pip-delete-this-directory.txt
11+
.mypy_cache/
12+
.coverage
13+
.pytest_cache/
14+
*.egg-info/
15+
docs/
16+
assets/
17+
workflows/
18+
# README.md - needed for Docker build
19+
# *.md - some markdown files needed for build
20+
.git
21+
.gitignore
22+
*.log
23+
tmp/
24+
Dockerfile*

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ config.json
6767
*config*.json
6868
m3_pipeline.json
6969

70+
# Generated Docker files (use workflow to generate)
71+
Dockerfile*
72+
!src/MCPStack/core/docker/dockerfile_generator.py
73+
7074
# Operating System specific files
7175
.DS_Store
7276
Thumbs.db
@@ -80,4 +84,4 @@ Desktop.ini
8084

8185
# Datasets and other large files
8286
data/
83-
m3_data/
87+
m3_data/

README.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,87 @@ You can also run your pipeline with FastMCP, allowing you to connect to various
158158

159159
<br />
160160

161+
### `Docker Containerization` 🐳
162+
163+
Build and deploy your MCP pipelines as Docker containers for production environments.
164+
165+
#### Prerequisites
166+
- **MCPStack**: `uv add mcpstack` or `pip install mcpstack`
167+
- **Available Presets**: Check with `mcpstack list-presets` (assumes `example_preset` exists)
168+
- **For full testing**: [Claude Desktop](https://claude.ai/desktop) for MCP server usage
169+
- **For building images**: Docker CLI installed and available
170+
171+
#### Quick Start Commands
172+
173+
**Basic Config (Fastest setup)***Recommended for first-time users*
174+
```bash
175+
# Generate Docker config only - creates claude_desktop_config.json
176+
mcpstack build --config-type docker --presets example_preset
177+
```
178+
*Outputs:* `claude_desktop_config.json` for MCP host configuration
179+
180+
**Development Workflow** 🛠️ *Recommended for local development*
181+
```bash
182+
# Generate config, dockerfile, and build image locally
183+
mcpstack build --config-type docker --presets example_preset --profile build-only
184+
```
185+
*Outputs:* `claude_desktop_config.json` + `Dockerfile` + built image for local testing
186+
187+
**Production Pipeline** 🚀 *Recommended for deployment*
188+
```bash
189+
# Complete workflow: generate, build, and push container image
190+
mcpstack build --config-type docker --presets example_preset --profile build-and-push
191+
```
192+
*Outputs:* Complete CI/CD pipeline with config, dockerfile, built & pushed container image
193+
194+
#### Verification Steps
195+
```bash
196+
# Check available profiles
197+
mcpstack list-profiles --config-type docker
198+
199+
# After running any command, verify outputs:
200+
ls -la claude_desktop_config.json Dockerfile # Check generated files
201+
docker images | grep mcpstack # Check built images
202+
cat claude_desktop_config.json # Config for Claude Desktop
203+
```
204+
205+
Perfect for deploying MCP tools to Kubernetes, Docker Swarm, or any container orchestration system.
206+
207+
<br />
208+
209+
### `Workflow Profiles` ⚙️
210+
211+
Define and run complex multi-stage workflows beyond basic config generation using workflow profiles.
212+
213+
#### Discover Available Profiles
214+
```bash
215+
# List all profiles
216+
mcpstack list-profiles
217+
218+
# List profiles for specific config type
219+
mcpstack list-profiles --config-type docker
220+
```
221+
222+
#### Use Built-in Profiles
223+
```bash
224+
# Docker build and push workflow
225+
mcpstack build --config-type docker --presets example_preset --profile build-and-push
226+
227+
# Docker build-only workflow (local development)
228+
mcpstack build --config-type docker --presets example_preset --profile build-only
229+
```
230+
231+
#### Custom Profile Examples
232+
Check the `workflows/` directory for YAML examples:
233+
- `docker-dev.yaml` - Development workflow with custom Dockerfile
234+
- `docker-prod.yaml` - Production CI/CD pipeline with tagging and registry push
235+
236+
Profiles support environment variables like `${GIT_COMMIT}`, `${GIT_BRANCH}`, and `${preset}` for dynamic naming.
237+
238+
Perfect for implementing complex deployment pipelines while maintaining MCPStack's clean architecture.
239+
240+
<br />
241+
161242
<img src="assets/readme/more.gif" width="61.8%" align="left" style="border-radius: 10px;"/>
162243

163244
### `Many Other CLIs Options`

docs/API/cli/stack_cli.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,58 @@
44
This page documents the **programmatic** CLI class — handy if you embed the CLI or generate help programmatically.
55
For end-user command help, see the **CLI** section of the docs.
66

7+
## Workflow Profiles
8+
9+
The `build` command supports workflow profiles for executing multi-stage operations beyond basic config generation:
10+
11+
- `--profile NAME`: Run extended workflow profile after basic build
12+
13+
### Profile Discovery
14+
15+
```bash
16+
# List all available profiles
17+
mcpstack list-profiles
18+
19+
# List profiles for specific config type
20+
mcpstack list-profiles --config-type docker
21+
```
22+
23+
### Profile Examples
24+
25+
```bash
26+
# Generate Docker config only (basic usage)
27+
mcpstack build --config-type docker --presets example_preset
28+
29+
# Execute build-and-push workflow profile
30+
mcpstack build --config-type docker --presets example_preset --profile build-and-push
31+
32+
# Execute build-only workflow profile
33+
mcpstack build --config-type docker --presets example_preset --profile build-only
34+
```
35+
36+
### Built-in Docker Profiles
37+
38+
- `build-and-push`: Generate config, dockerfile, build image, push to registry
39+
- `build-only`: Generate config, dockerfile, build image locally
40+
41+
### Custom Profiles
42+
43+
Create YAML profiles in the `workflows/` directory for complex deployment scenarios:
44+
45+
```yaml
46+
name: docker-prod
47+
description: Production deployment with tagging
48+
config_type: docker
49+
stages:
50+
- config.generate
51+
- dockerfile.generate
52+
- image.build:
53+
image: "${preset}:${GIT_COMMIT}"
54+
- image.push:
55+
registry: "docker.io"
56+
tags: ["latest", "${GIT_BRANCH}"]
57+
```
58+
759
::: MCPStack.cli.StackCLI
860
options:
961
show_root_heading: true
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# DockerMCP Config Generator
2+
3+
::: MCPStack.core.mcp_config_generator.mcp_config_generators.docker_mcp_config.DockerMCPConfigGenerator
4+
options:
5+
show_root_heading: true
6+
show_source: true
7+
8+
## Docker Workflow
9+
10+
The DockerMCP Config Generator provides unified Docker containerization functionality for MCPStack pipelines. It can:
11+
12+
- **Generate configuration files** for running MCPStack tools inside Docker containers (Claude Desktop integration)
13+
- **Generate Dockerfiles** from MCPStack pipeline configurations
14+
- **Build Docker images** automatically during configuration generation
15+
- **Push images** to Docker registries
16+
- **Support complex configuration** including volumes, ports, networks, and build arguments
17+
18+
## Usage
19+
20+
### Basic Configuration Generation
21+
```python
22+
config = DockerMCPConfigGenerator.generate(
23+
stack=mcp_stack,
24+
image_name="mcpstack:myapp"
25+
)
26+
```
27+
28+
### Complete Docker Workflow
29+
```python
30+
config = DockerMCPConfigGenerator.generate(
31+
stack=mcp_stack,
32+
image_name="myapp:latest",
33+
build_image="myapp:latest", # Build the image
34+
generate_dockerfile=True, # Generate Dockerfile
35+
docker_push=True, # Push to registry
36+
docker_registry_url="docker.io/username/"
37+
)
38+
```
39+
40+
## CLI Integration
41+
42+
The generator integrates with the unified MCPStack CLI through workflow profiles:
43+
44+
```bash
45+
# Generate Docker config only (basic usage)
46+
mcpstack build --config-type docker --presets my_preset
47+
48+
# Generate config, dockerfile, build and push (production pipeline)
49+
mcpstack build --config-type docker --presets my_preset --profile build-and-push
50+
51+
# Generate config, dockerfile, and build locally (development)
52+
mcpstack build --config-type docker --presets my_preset --profile build-only
53+
```
54+
55+
## Parameters
56+
57+
### Core Parameters
58+
- `stack`: MCPStackCore instance
59+
- `image_name`: Docker image name to use in configurations
60+
- `server_name`: Name for the MCP server in Claude config
61+
- `volumes`: Volume mounts for Docker container
62+
- `ports`: Port mappings for Docker container
63+
- `network`: Docker network name
64+
65+
### Docker Building Parameters
66+
- `build_image`: Image name to build (triggers Docker build)
67+
- `generate_dockerfile`: Generate Dockerfile when True
68+
- `dockerfile_path`: Custom path for generated Dockerfile
69+
- `docker_push`: Push built image to registry
70+
- `docker_registry_url`: Docker registry URL
71+
- `build_args`: Dictionary of Docker build arguments
72+
73+
## Integration with MCP Config Generators Registry
74+
75+
The DockerMCP Config Generator is automatically available through the MCP config generators registry:
76+
77+
```python
78+
from MCPStack.core.mcp_config_generator.registry import ALL_MCP_CONFIG_GENERATORS
79+
80+
# The DockerMCP generator is registered as 'docker'
81+
generator = ALL_MCP_CONFIG_GENERATORS['docker']
82+
config = generator.generate(stack, build_image="myimage:latest")

0 commit comments

Comments
 (0)