Labsco
aws-samples logo

MCP Server Automation CLI

β˜… 4

from aws-samples

A CLI tool to automate packaging MCP servers as Docker images and deploying them to AWS ECS.

πŸ”₯πŸ”₯πŸ”₯βœ“ VerifiedFreeNeeds API keys

MCP Server Automation CLI

A powerful CLI tool that automates the process of transforming Model Context Protocol (MCP) stdio servers into Docker images deployed on AWS ECS using mcp-proxy. This tool bridges the gap between local MCP servers and remote HTTP-based deployments.

πŸš€ Features

  • ⚑ Direct Command Mode: Build MCP servers instantly without config files using -- separator syntax
  • πŸ”„ Automatic Build: Fetch MCP servers from GitHub, build Docker images, and push to ECR
  • ☁️ One-Click Deploy: Generate CloudFormation templates and deploy complete ECS infrastructure
  • πŸ” Smart Detection: Automatically detect MCP server commands from README files
  • 🐳 Multi-Language: Support for Python and Node.js/TypeScript MCP servers with automatic language detection
  • 🏷️ Smart Naming: Automatic package name extraction for Docker image naming
  • πŸ”§ Debug Support: Built-in debug logging for troubleshooting
  • πŸ“ Config Generation: Generate MCP client configurations for Claude Desktop, Cline, etc.

πŸ—οΈ Architecture

Build Process Flow

The tool supports two build modes:

Direct Command Mode

  1. Command Parsing: Parses command and arguments from CLI using -- separator (e.g., -- npx -y @modelcontextprotocol/server-everything)
  2. Package Name Extraction: Automatically extracts package names for Docker image naming (e.g., @modelcontextprotocol/server-everything β†’ mcp-server-everything)
  3. Language Detection: Detects runtime (Node.js/Python) from command
  4. Dockerfile Generation: Creates optimized containers with pre-installed packages
  5. Image Building: Builds container ready to execute the specified command

Config File Mode (GitHub/Entrypoint)

  1. Repository Analysis: Downloads GitHub repos and detects MCP server configuration from README files (GitHub mode)
  2. Language Detection: Automatically detects Python or Node.js/TypeScript based on project files (package.json, pyproject.toml, etc.)
  3. Command Detection: Parses JSON blocks in README files to extract MCP server start commands from both Claude Desktop (mcpServers) and VS Code (mcp.servers) configuration formats
  4. Dockerfile Generation: Uses language-specific Jinja2 templates (Dockerfile-python.j2, Dockerfile-nodejs.j2) to create optimized builds with mcp-proxy CLI integration
  5. Image Building: Creates language-specific containers with proper dependency management and multi-stage builds

Deployment Architecture

GitHub Repo β†’ Docker Build β†’ ECR β†’ ECS Fargate ← ALB ← Internet
     ↓              ↓           ↓         ↓        ↓
MCP Server β†’ mcp-proxy + MCP β†’ Image β†’ Service β†’ HTTP/SSE Endpoints

Language Support and Detection

The tool supports both Python and Node.js/TypeScript MCP servers with automatic language detection:

Python Projects

  • Detected by: pyproject.toml, requirements.txt, setup.py, or .py files
  • Package managers: pip, uv, poetry (automatically detected)
  • Base image: python:3.12-slim-bookworm
  • Command extraction from: console scripts in pyproject.toml, setup.py entry points

Node.js/TypeScript Projects

  • Detected by: package.json, tsconfig.json, or .ts/.js files
  • Package manager: npm (with Node.js 24-bullseye base image)
  • Base image: node:24-bullseye
  • Command extraction from: README JSON configurations

Command Detection and Override

The tool automatically detects MCP server startup commands from:

  1. README files - JSON configuration blocks supporting both formats:
    • Claude Desktop: {"mcpServers": {...}}
    • VS Code: {"mcp": {"servers": {...}}}
  2. Python projects - pyproject.toml console scripts, setup.py entry points
  3. Node.js projects - README configurations (package.json scripts not parsed)

Command Override Required When:

  • README only contains Docker commands (not suitable for containerization)
  • No suitable startup command can be detected
  • You want to specify exact startup parameters

Example:

build:
  github:
    github_url: "https://github.com/my-org/custom-mcp-server"
  command_override:
    - "python"
    - "-m"
    - "my_server_module"
    - "--verbose"
    - "--port"
    - "3000"
  push_to_ecr: true

Example README Configurations Supported:

Claude Desktop format:

{
  "mcpServers": {
    "everything": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-everything"]
    }
  }
}

VS Code format:

{
  "mcp": {
    "servers": {
      "everything": {
        "command": "python",
        "args": ["-m", "server"]
      }
    }
  }
}

Error Example:

If your MCP server README only shows Docker commands:

{
  "mcpServers": {
    "myserver": {
      "command": "docker",
      "args": ["run", "myserver:latest"]
    }
  }
}

You'll get an error requiring command_override to specify the direct startup command.

πŸ” AWS Permissions Required

The AWS credentials used must have the following permissions:

ECR Permissions

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "ecr:BatchCheckLayerAvailability",
        "ecr:GetDownloadUrlForLayer",
        "ecr:BatchGetImage",
        "ecr:GetAuthorizationToken",
        "ecr:PutImage",
        "ecr:InitiateLayerUpload",
        "ecr:UploadLayerPart",
        "ecr:CompleteLayerUpload"
      ],
      "Resource": "*"
    }
  ]
}

ECS and CloudFormation Permissions

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "ecs:*",
        "cloudformation:*",
        "ec2:*",
        "elasticloadbalancing:*",
        "iam:CreateRole",
        "iam:AttachRolePolicy",
        "iam:PassRole",
        "logs:CreateLogGroup",
        "logs:DescribeLogGroups"
      ],
      "Resource": "*"
    }
  ]
}

Security

See CONTRIBUTING for more information.

πŸ†˜ Support

  • Check the troubleshooting section for common issues
  • Review CloudFormation events in AWS Console for deployment issues
  • Use debug mode for detailed logging
  • Open an issue for bugs or feature requests