Containerization Assist

io.github.Azure由 GitHub 账号 Azure 发布v1.5.0更新于 Oct 24, 2026

TypeScript MCP server for AI-powered containerization workflows with Docker and Kubernetes support

概览

AI 生成的概览

一个本地 MCP 服务器,让助手分析代码仓库、生成 Dockerfile、构建、扫描、打标签和推送镜像,并生成与部署 Kubernetes 清单。

可以做什么
分析仓库结构,识别语言、框架和 monorepo 模块,并生成或修复 Dockerfile,附带策略校验和基于知识的建议。准备构建上下文、构建镜像、扫描漏洞、打标签并推送到镜像仓库。生成 Kubernetes、Helm、Kustomize 或 ACA 清单,准备集群并验证部署。运行引导式工作流,例如本地 Kind 循环、AKS 循环,或编写自定义 OPA Rego 策略。查询服务器状态,并为长时间操作发送进度通知。
适用场景
适合在容器化应用时,让助手按分析、生成 Dockerfile、构建与扫描镜像、部署到 Kubernetes 的顺序走完整个流程。最适合一名工程师一次容器化一个应用,也支持包含多个服务的 monorepo。
运行要求
通过 npm 包以 stdio 在本地运行,需要 Node.js 20 或更高版本。需要运行中的 Docker 守护进程和可访问的套接字;Kubernetes 部署功能需要 kubeconfig、集群访问权限和相应的 RBAC 权限。漏洞扫描可选安装 Trivy。可选环境变量包括 DOCKER_SOCKET、DOCKER_HOST、KUBECONFIG、K8S_NAMESPACE、LOG_LEVEL 和 CUSTOM_POLICY_PATH。
安装前请注意
它会构建镜像、推送到镜像仓库,并准备和部署到 Kubernetes 集群,会改变远端状态;操作前请确认目标仓库、命名空间和上下文。它需要访问 Docker 套接字,这在主机上几乎等同于 root 权限。可选的工具执行日志会把工具输入和输出写入磁盘上的 JSON 文件。推送镜像可能产生镜像仓库或云服务费用。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Containerization Assist,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

Containerization Assist MCP Server

[Test Pipeline] [Version] [MCP SDK] [Node] [TypeScript] [License] [Docs]

An AI-powered containerization assistant that helps you build, scan, and deploy Docker containers through VS Code and other MCP-compatible tools.

Full documentation →

Install

[Install in VS Code] [Install in VS Code Insiders]

Features

Core Capabilities

  • 🐳 Docker Integration: Build, scan, and deploy container images
  • ☸️ Kubernetes Support: Generate manifests and deploy applications
  • 🤖 AI-Powered: Intelligent Dockerfile generation and optimization
  • 🧠 Knowledge Enhanced: AI-driven content improvement with security and performance best practices
  • 🔄 Intelligent Tool Routing: Automatic dependency resolution and execution
  • 📊 Progress Tracking: Real-time progress updates via MCP notifications
  • 🔒 Security Scanning: Built-in vulnerability scanning with AI-powered suggestions
  • ✨ Smart Analysis: Context-aware recommendations
  • Policy-Driven System (v3.0)
    • Pre-generation configuration
    • Knowledge filtering and weighting
    • Template injection
    • Semantic validation
    • Cross-tool consistency

Policy System (v3.0)

Full control over containerization through Rego policies:

  • Configure Before Generation: Set defaults for resources, base images, build strategy
  • Guide During Generation: Filter knowledge base, inject templates automatically
  • Validate After Generation: Semantic checks, security scoring, cross-tool consistency

Example Policies Included:

  • Environment-based strategy (dev/staging/prod)
  • Cost control by team tier
  • Security-first organization
  • Multi-cloud registry governance
  • Speed-optimized development

See Policy Authoring Guide for details.

System Requirements

  • Node.js 20+
  • Docker or Docker Desktop
  • Optional: Trivy (for security scanning features)
  • Optional: Kubernetes (for deployment features)

Manual Install

Add the following to your VS Code settings or create .vscode/mcp.json in your project:

json
{  "servers": {    "ca": {      "command": "npx",      "args": ["-y", "containerization-assist-mcp", "start"],      "env": {         "LOG_LEVEL": "info"      }    }  }}

Restart VS Code to enable the MCP server in GitHub Copilot.

SDK Usage (Without MCP)

For direct tool usage without MCP protocol (e.g., VS Code extensions, programmatic access):

typescript
import { analyzeRepo, buildImageContext, scanImage } from 'containerization-assist-mcp/sdk';import { execSync } from 'child_process';
// Simple function calls - no MCP server neededconst analysis = await analyzeRepo({ repositoryPath: './myapp' });if (analysis.ok) {  console.log('Detected:', analysis.value.modules);}
// buildImageContext returns build context with security analysis and commandsconst buildContext = await buildImageContext({ path: './myapp', imageName: 'myapp:v1', platform: 'linux/amd64' });if (buildContext.ok) {  const { securityAnalysis, nextAction } = buildContext.value;  console.log('Security risk:', securityAnalysis.riskLevel);    // Execute the generated build command from the build context directory  execSync(nextAction.buildCommand.command, {    cwd: buildContext.value.context.buildContextPath,    env: { ...process.env, ...nextAction.buildCommand.environment }  });}
const scan = await scanImage({ imageId: 'myapp:v1' });

See the SDK integration examples for full SDK documentation.

Windows Users

For Windows, use the Windows Docker pipe:

json
"DOCKER_SOCKET": "//./pipe/docker_engine"

Quick Start

The easiest way to understand the containerization workflow is through an end-to-end example:

Single-App Containerization Journey

This MCP server guides you through a complete containerization workflow for a single application. The journey follows this sequence:

  1. Analyze Repository → Understand your application's language, framework, and dependencies
  2. Generate Dockerfile → Create an optimized, security-hardened container configuration
  3. Build Image → Compile your application into a Docker image
  4. Scan Image → Identify security vulnerabilities and get remediation guidance
  5. Tag Image → Apply appropriate version tags to your image
  6. Generate K8s Manifests → Create deployment configurations for Kubernetes
  7. Prepare Cluster → Set up namespace and prerequisites, then deploy with kubectl apply
  8. Verify → Confirm deployment health and readiness

Prerequisites

Before starting, ensure you have:

  • Docker: Running Docker daemon with accessible socket (docker ps should work)
    • Linux/Mac: /var/run/docker.sock accessible
    • Windows: Docker Desktop with //./pipe/docker_engine accessible
  • Kubernetes (optional, for deployment features):
    • Valid kubeconfig at ~/.kube/config
    • Cluster connectivity (kubectl cluster-info should work)
    • Appropriate RBAC permissions for deployments, services, namespaces
  • Node.js: Version 20 or higher
  • MCP Client: VS Code with Copilot, Claude Desktop, or another MCP-compatible client

Example Workflow with Natural Language

Once configured in your MCP client (VS Code Copilot, Claude Desktop, etc.), use natural language:

Starting the Journey:

"Analyze my Java application for containerization"

Building the Container:

"Generate an optimized Dockerfile with security best practices""Build a Docker image tagged myapp:v1.0.0""Scan the image for vulnerabilities"

Deploying to Kubernetes:

"Generate Kubernetes manifests for this application""Prepare my cluster and deploy to the default namespace""Verify the deployment is healthy"

Single-Operator Model

This server is optimized for one engineer containerizing one application at a time. Key characteristics:

  • Sequential execution: Each tool builds on the results of previous steps
  • Fast-fail validation: Clear, actionable error messages if Docker/Kubernetes are unavailable
  • Deterministic AI generation: Tools provide reproducible outputs through built-in prompt engineering
  • Real-time progress: MCP notifications surface progress updates to clients during long-running operations

Multi-Module/Monorepo Support

The server detects and supports monorepo structures with multiple independently deployable services:

  • Automatic Detection: analyze-repo identifies monorepo patterns (npm workspaces, services/, apps/ directories)
  • Automated Multi-Module Generation: generate-dockerfile and generate-k8s-manifests support multi-module workflows
  • Conservative Safeguards: Excludes shared libraries and utility folders from containerization

Multi-Module Workflow Example:

1. "Analyze my monorepo at ./my-monorepo"   → Detects 3 modules: api-gateway, user-service, notification-service
2. "Generate Dockerfiles"   → Automatically creates Dockerfiles for all 3 modules:     - services/api-gateway/Dockerfile     - services/user-service/Dockerfile     - services/notification-service/Dockerfile
3. "Generate K8s manifests"   → Automatically creates manifests for all 3 modules
4. Optional: "Generate Dockerfile for user-service module"   → Creates module-specific deployment manifests

Detection Criteria:

  • Workspace configurations (npm, yarn, pnpm workspaces, lerna, nx, turborepo, cargo workspace)
  • Separate package.json, pom.xml, go.mod, Cargo.toml per service
  • Independent entry points and build configs
  • EXCLUDES: shared/, common/, lib/, packages/utils directories

Available Tools

The server provides 11 MCP tools organized by functionality:

Analysis & Planning

ToolDescription
analyze-repoAnalyze repository structure and detect technologies by parsing config files

Dockerfile Operations

ToolDescription
generate-dockerfileGather insights from knowledge base and return requirements for Dockerfile creation
fix-dockerfileAnalyze Dockerfile for issues including organizational policy validation and return knowledge-based fix recommendations

Image Operations

ToolDescription
build-image-contextPrepare Docker build context with security analysis and return build commands
scan-imageScan Docker images for security vulnerabilities with remediation guidance (uses Trivy CLI)
tag-imageTag Docker images with version and registry information
push-imagePush Docker images to a registry

Kubernetes Operations

ToolDescription
generate-k8s-manifestsGather insights and return requirements for Kubernetes/Helm/ACA/Kustomize manifest creation
prepare-clusterPrepare Kubernetes cluster for deployment
verify-deployVerify Kubernetes deployment status

Utilities

ToolDescription
opsOperational utilities for ping and server status

Workflow Tools

Interactive workflow tools that return step-by-step plans (output is collapsed by default in VS Code Copilot Chat):

ToolDescriptionInputs
create-containerization-policyStep-by-step guidance for authoring a custom OPA Rego policyNone
kind-loopLocal dev loop: analyze → build → scan → deploy to Kindnamespace (optional), imageName (optional)
aks-loopRemote dev loop: analyze → build → push → deploy to AKSregistry, resourceGroup, clusterName (required); namespace, imageName (optional)

Version Tracking

All generated artifacts include version metadata so you can track which version of containerization-assist produced them.

Dockerfiles (generate-dockerfile):

The tool output includes attributionLabels.labels with a version label, included as a LABEL instruction in the generated Dockerfile:

LabelValuePurpose
com.azure.containerizationassist.versionPackage version (e.g., 1.4.0)Version of containerization-assist used

Kubernetes Manifests (generate-k8s-manifests):

The tool output includes attributionLabels.annotations applied to all generated Kubernetes resource metadata:

TypeKeyValuePurpose
Annotationcom.azure.containerizationassist/versionPackage version (e.g., 1.4.0)Version of containerization-assist used

Organizations can add custom labels via the policy system's orgStandards.requiredLabels configuration.

Supported Technologies

Languages & Frameworks

  • Java: Spring Boot, Quarkus, Micronaut (Java 8-21)
  • .NET: ASP.NET Core, Blazor (.NET 6.0+)

Build Systems

  • Maven, Gradle (Java)
  • dotnet CLI (.NET)

Configuration

Environment Variables

The following environment variables control server behavior:

VariableDescriptionDefaultRequired
DOCKER_SOCKETDocker socket path/var/run/docker.sock (Linux/Mac)
//./pipe/docker_engine (Windows)
No
DOCKER_HOSTDocker host URI (unix://, tcp://, http://, https://, npipe://)Auto-detectedNo
DOCKER_TIMEOUTDocker operation timeout in milliseconds60000 (60s)No
KUBECONFIGPath to Kubernetes config file~/.kube/configNo
K8S_NAMESPACEDefault Kubernetes namespacedefaultNo
LOG_LEVELLogging levelinfoNo
WORKSPACE_DIRWorking directory for operationsCurrent directoryNo
MCP_MODEEnable MCP protocol mode (logs to stderr)falseNo
MCP_QUIETSuppress non-essential output in MCP modefalseNo
CONTAINERIZATION_ASSIST_TOOL_LOGS_DIR_PATHDirectory path for tool execution logs (JSON format)DisabledNo
CUSTOM_POLICY_PATHDirectory path for custom policies (highest priority)Not setNo

Progress Notifications: Long-running operations (build, deploy, scan-image) emit real-time progress updates via MCP notifications. MCP clients can subscribe to these notifications to display progress to users.

Tool Execution Logging

Enable detailed logging of all tool executions to JSON files for debugging and auditing:

bash
export CONTAINERIZATION_ASSIST_TOOL_LOGS_DIR_PATH=/path/to/logs

Log File Format:

  • Filename: ca-tool-logs-${timestamp}.jsonl
  • Example: ca-tool-logs-2025-10-13T14-30-15-123Z.jsonl

Log Contents:

json
{  "timestamp": "2025-10-13T14:30:15.123Z",  "toolName": "analyze-repo",  "input": { "path": "/workspace/myapp" },  "output": { "language": "typescript", "framework": "express" },  "success": true,  "durationMs": 245,  "error": "Error message if failed",  "errorGuidance": {    "hint": "Suggested fix",    "resolution": "Step-by-step instructions"  }}

The logging directory is validated at startup to ensure it's writable.

Policy System

The policy system uses OPA Rego for security, quality, and compliance enforcement. Rego is the industry-standard policy language from Open Policy Agent, providing expressive rules with rich built-in functions.

Default Behavior (No Configuration Needed): By default, all policies in the policies/ directory are automatically discovered and merged:

  • policies/security-baseline.rego - Essential security rules (root user prevention, secrets detection, privileged containers)
  • policies/base-images.rego - Base image governance (Microsoft Azure Linux recommendation, no :latest tag, deprecated versions)
  • policies/container-best-practices.rego - Docker best practices (HEALTHCHECK, multi-stage builds, layer optimization)

This provides comprehensive out-of-the-box security and quality enforcement.

Policy Customization

The policy system supports four priority-ordered search paths for easy customization:

Priority Order (highest to lowest):

  1. Custom directory via CUSTOM_POLICY_PATH environment variable (highest priority)
  2. Project directory at <git-root>/.containerization-assist/policy/ (tracked in git)
  3. Global directory at ~/.config/containerization-assist/policy/ (XDG-compliant)
  4. Built-in policies/ (shipped with package, lowest priority)

Migration Note: The policies.user/ directory is deprecated. For project-specific policies, use .containerization-assist/policy/ at your git root. For user-wide policies, use ~/.config/containerization-assist/policy/. The old directory still works but will log a deprecation warning.

Quick Start
bash
# Option 1: Global policies (no env var needed)mkdir -p ~/.config/containerization-assist/policy
# Copy example policy from the npm packagecp node_modules/containerization-assist-mcp/policies.user.examples/allow-all-registries.rego \   ~/.config/containerization-assist/policy/
# Policies are auto-reloaded on the next tool execution — no restart needed

Or set a custom location in .vscode/mcp.json:

json
{  "servers": {    "ca": {      "env": {        "CUSTOM_POLICY_PATH": "/path/to/policies"      }    }  }}
Pre-Built Example Policies

The policies.user.examples/ directory (included in the npm package) provides three ready-to-use examples:

ExamplePurposeUse Case
allow-all-registries.regoOverride MCR preferenceDocker Hub, GCR, ECR, private registries
warn-only-mode.regoAdvisory-only enforcementTesting, gradual adoption, dev environments
custom-organization-template.regoOrganization templateCustom labels, registries, compliance

See policies.user.examples/README.md for detailed usage.

Built-In Policies

Three production-ready Rego policies are included by default:

  • policies/security-baseline.rego - Essential security rules (root user prevention, secrets detection, privileged containers)
  • policies/base-images.rego - Base image governance (Microsoft Azure Linux recommendation, no :latest tag, deprecated versions)
  • policies/container-best-practices.rego - Docker best practices (HEALTHCHECK, multi-stage builds, layer optimization)

User policies override built-in policies by package namespace.

Policy File Format (Rego):

rego
package containerization.custom_policy
# Blocking violationsviolations contains result if {  input_type == "dockerfile"  regex.match(`FROM\s+[^:]+:latest`, input.content)
  result := {    "rule": "block-latest-tag",    "category": "quality",    "priority": 80,    "severity": "block",    "message": "Using :latest tag is not allowed. Specify explicit version tags.",    "description": "Prevent :latest for reproducibility",  }}
# Non-blocking warningswarnings contains result if {  input_type == "dockerfile"  not regex.match(`HEALTHCHECK`, input.content)
  result := {    "rule": "suggest-healthcheck",    "category": "quality",    "priority": 70,    "severity": "warn",    "message": "Consider adding HEALTHCHECK instruction for container monitoring",    "description": "HEALTHCHECK improves container lifecycle management",  }}
# Policy decisiondefault allow := falseallow if count(violations) == 0
# Result structureresult := {  "allow": allow,  "violations": violations,  "warnings": warnings,  "suggestions": [],  "summary": {    "total_violations": count(violations),    "total_warnings": count(warnings),    "total_suggestions": 0,  },}

Priority Levels:

  • 90-100: Security rules (highest priority)
  • 70-89: Quality rules
  • 50-69: Performance rules
  • 30-49: Compliance rules

Using Policies:

bash
# List discovered policiesnpx containerization-assist-mcp list-policies
# List policies and show merged resultnpx containerization-assist-mcp list-policies --show-merged
# Validate Dockerfile with policies (automatic discovery)npx containerization-assist-mcp fix-dockerfile --path ./Dockerfile

Creating Custom Policies:

See Policy Customization Guide and existing policies in policies/ for examples.

Testing Policies:

bash
# Validate policy syntaxopa check .containerization-assist/policy/my-policy.rego
# Run policy testsopa test .containerization-assist/policy/
# Test with MCP Inspectornpx @modelcontextprotocol/inspector containerization-assist-mcp start

MCP Inspector (Testing)

bash
npx @modelcontextprotocol/inspector containerization-assist-mcp start

Troubleshooting

Docker Connection Issues

bash
# Check Docker is runningdocker ps
# Check socket permissions (Linux/Mac)ls -la /var/run/docker.sock
# For Windows, ensure Docker Desktop is running

MCP Connection Issues

bash
# Test with MCP Inspectornpx @modelcontextprotocol/inspector containerization-assist-mcp start
# Check logs with debug levelnpx -y containerization-assist-mcp start --log-level debug

Kubernetes Connection Issues

The server performs fast-fail validation when Kubernetes tools are used. If you encounter Kubernetes errors:

Kubeconfig Not Found

bash
# Check if kubeconfig existsls -la ~/.kube/config
# Verify kubectl can connectkubectl cluster-info
# If using cloud providers, update kubeconfig:# AWS EKSaws eks update-kubeconfig --name <cluster-name> --region <region>
# Google GKEgcloud container clusters get-credentials <cluster-name> --zone <zone>
# Azure AKSaz aks get-credentials --resource-group <rg> --name <cluster-name>

Connection Timeout or Refused

bash
# Verify cluster is runningkubectl get nodes
# Check API server addresskubectl config view
# Test connectivity to API serverkubectl cluster-info dump
# Verify firewall rules allow connection to API server port (typically 6443)

Authentication or Authorization Errors

bash
# Check current context and userkubectl config current-contextkubectl config view --minify
# Test permissionskubectl auth can-i create deployments --namespace defaultkubectl auth can-i create services --namespace default
# If using cloud providers, refresh credentials:# AWS EKS: re-run update-kubeconfig# GKE: run gcloud auth login# AKS: run az login

Invalid or Missing Context

bash
# List available contextskubectl config get-contexts
# Set a contextkubectl config use-context <context-name>
# View current configurationkubectl config view

License

MIT License - See LICENSE file for details.

Support

See SUPPORT.md for information on how to get help with this project.

Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft’s Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party’s policies.

来源:README.md,提交 c724271

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v1.5.0最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分