mcp-server-automation
MCP Server Automation CLI
Documentation
Migration Notice
This repo has been migrated to `aws-samples`. New repo path is https://github.com/aws-samples/sample-mcp-server-automation . This repo is archived.
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
- ๐ 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-Architecture: Support for Python, Node.js, and hybrid MCP servers
- ๐ง Debug Support: Built-in debug logging for troubleshooting
- ๐ Config Generation: Generate MCP client configurations for Claude Desktop, Cline, etc.
๐ Prerequisites
- Python 3.8+
- Docker (with daemon running)
- AWS CLI configured with appropriate permissions
- AWS ECR repository (created if using ECR push)
- AWS ECS cluster (created if deploying)
Install uv
# On macOS and Linux.
curl -LsSf https://astral.sh/uv/install.sh | sh# On Windows.
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"๐ Quick Start
Using uvx (Recommended)
The easiest way to use this tool is with `uvx`, which handles dependencies automatically:
# Install from a Git repository
uvx --from git+https://github.com/aws-samples/sample-mcp-server-automation mcp-server-automation --config your-config.yamlLocal Development Setup
# Clone and setup
git clone
cd mcp-convert-automate
# Create virtual environment and install dependencies
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt
# Install in development mode (optional - for local CLI usage)
pip install -e .โ๏ธ Configuration
The tool uses a unified YAML configuration file with `build` and `deploy` sections.
Unified Configuration
build:
# Required: GitHub repository URL
github_url: "https://github.com/awslabs/mcp"
# Optional: Subfolder if MCP server is not in root
subfolder: "src/aws-documentation-mcp-server"
# Optional: Git branch to build from (default: main)
branch: "main"
# Required for deployment: Must be true to enable ECR push and deployment
push_to_ecr: true
# Optional: Custom Docker image configuration
# If not specified, auto-generated when push_to_ecr=true
# image:
# repository: "123456789012.dkr.ecr.us-east-1.amazonaws.com/mcp-servers/my-mcp-server"
# tag: "v1.0" # Optional, defaults to dynamic git-based tag
# Optional: AWS region (default: from AWS profile, fallback to us-east-1)
# aws_region: "us-west-2"
# Optional: Custom Dockerfile path
# dockerfile_path: "./custom.Dockerfile"
# Optional: Override auto-detected MCP server command
# Required when README only contains Docker commands or no suitable command is found
# command_override:
# - "python"
# - "-m"
# - "my_server_module"
# - "--verbose"
# Optional: Set environment variables in the container
# environment_variables:
# LOG_LEVEL: "debug"
# AWS_REGION: "us-east-1"
# MCP_SERVER_NAME: "custom-server"
deploy:
# Required: Enable deployment (only works when push_to_ecr=true)
enabled: true
# Required: ECS service name
service_name: "my-mcp-service"
# Required: ECS cluster name
cluster_name: "my-ecs-cluster"
# Required: VPC ID where resources will be created
vpc_id: "vpc-12345678"
# Required: Subnet configuration
alb_subnet_ids: # Public subnets for ALB (minimum 2 in different AZs)
- "subnet-public-1"
- "subnet-public-2"
ecs_subnet_ids: # Private subnets for ECS tasks (minimum 1, should resides in AZ of alb_subnet_ids)
- "subnet-private-1"
- "subnet-private-2"
# Optional: Container port (default: 8000)
port: 8000
# Optional: Task CPU units (default: 256)
cpu: 256
# Optional: Task memory in MB (default: 512)
memory: 512
# Optional: SSL certificate ARN for HTTPS
certificate_arn: "arn:aws:acm:us-east-1:123456789012:certificate/12345678-1234-1234-1234-123456789012"
# Optional: Save MCP client configuration to file
save_config: "./mcp-config.json"๐๏ธ Architecture
Build Process Flow
1. Repository Analysis: Downloads GitHub repos and detects MCP server configuration from README files
2. Command Detection: Parses JSON blocks in README files to extract MCP server start commands, prioritizing NPX/uvx over Docker commands
3. Dockerfile Generation: Uses Jinja2 templates to create multi-stage Docker builds with mcp-proxy CLI integration
4. Image Building: Creates hybrid Node.js + Python containers with proper dependency management
Deployment Architecture
GitHub Repo โ Docker Build โ ECR โ ECS Fargate โ ALB โ Internet
โ โ โ โ โ
MCP Server โ mcp-proxy + MCP โ Image โ Service โ HTTP/SSE EndpointsKey Technical Details
- mcp-proxy Integration: Uses TypeScript/Node.js CLI tool for HTTP transport with debug logging enabled
- Container Architecture: Multi-stage builds with `node:24-bullseye` base image, includes netcat for health checks
- Command Format: `mcp-proxy --debug --port 8000 --shell [-- ]` for proper argument ordering
- Transport Protocol: Converts MCP stdio to HTTP with `/mcp` endpoint for Streamable HTTP transport
- Dynamic Tagging: Images tagged with git commit hash and timestamp (e.g., `a1b2c3d4-develop-20231222-143055`)
- Branch Support: Can build from specific git branches, defaults to 'main'
- Health Checks: Container uses netcat port checking, ALB health checks `/mcp` endpoint expecting HTTP 400
- MCP Config Generation: Automatically generates and prints MCP client configuration after deployment
- Infrastructure: Complete CloudFormation stack with VPC, ALB, ECS Fargate, security groups, and IAM roles
๐ง Advanced Usage
Custom Dockerfile
build:
github_url: "https://github.com/my-org/custom-mcp-server"
dockerfile_path: "./custom/Dockerfile"
push_to_ecr: true
deploy:
enabled: true
# ... deployment configurationCommand Detection and Override
The tool automatically detects MCP server startup commands from:
1. README files - JSON configuration blocks with `mcpServers`
2. pyproject.toml - Console scripts or main modules
3. setup.py - Entry points and scripts
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_url: "https://github.com/my-org/custom-mcp-server"
command_override:
- "python"
- "-m"
- "my_server_module"
- "--verbose"
- "--port"
- "3000"
push_to_ecr: trueError Example:
If your MCP server README only shows:
{
"mcpServers": {
"myserver": {
"command": "docker",
"args": ["run", "myserver:latest"]
}
}
}You'll get an error requiring `command_override` to specify the direct startup command.
Environment Variables in Container
Set custom environment variables that will be available to the MCP server at runtime:
build:
github_url: "https://github.com/my-org/custom-mcp-server"
environment_variables:
LOG_LEVEL: "debug"
AWS_REGION: "us-east-1"
MCP_SERVER_NAME: "custom-server"
PYTHONPATH: "/app/mcp-server:/custom/path"
push_to_ecr: trueSystem Environment Variables
Set environment variables to override default AWS settings:
export AWS_REGION=us-west-2
export ECS_CLUSTER_NAME=my-production-cluster๐ Troubleshooting
Docker Build Issues
- Ensure Docker daemon is running
- Check that the MCP server has proper dependency files (requirements.txt, pyproject.toml, etc.)
- Verify GitHub repository URL is accessible
ECR Push Issues
- Ensure AWS credentials have ECR permissions
- Verify ECR repository exists and is accessible
- Check that Docker is authenticated with ECR
CloudFormation Deployment Issues
- Ensure AWS credentials have sufficient permissions
- Check that the ECS cluster exists
- Verify AWS region is correct
- Review CloudFormation events in AWS Console for detailed error messages
MCP Server Connection Issues
- Check container logs: `docker logs `
- Verify health check endpoint: `curl http:///mcp` (expects HTTP 400)
- Test direct connection: `curl http:///mcp`
- Use debug mode for detailed logging
๐ 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": "*"
}
]
}๐ MCP Client Configuration
After deployment, the tool generates configuration for MCP clients:
{
"mcpServers": {
"my-mcp-server": {
"type": "sse",
"url": "http:///sse"
}
}
}Testing MCP Connection
# Install mcp-proxy client
npm install -g mcp-proxy
# Test connection
mcp-proxy https://your-alb-url.amazonaws.com/mcpSecurity
See CONTRIBUTING for more information.
License
This library is licensed under the MIT-0 License. See the LICENSE file.
๐ 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
Frequently asked questions
What is mcp-server-automation?
mcp-server-automation is MCP Server Automation CLI
How do I install mcp-server-automation?
Open the GitHub repository and follow its README. Most MCP servers are added to your client's MCP config, then called by your agent.
Is mcp-server-automation open source?
Yes โ it is hosted on GitHub at https://github.com/yubingjiaocn/mcp-server-automation.
Related MCP tools
Cognee is the open-source AI memory platform for agents. Give your AI agents persistent long-term memory across sessions with a self-hosted knowledge graph engine.
Automate browser based workflows with AI
Hindsight: Agent Memory That Learns
A privacy-first app that strips AI watermarks from content you own.
Agent framework and applications built upon Qwen>=3.0, featuring Function Calling, MCP, Code Interpreter, RAG, Chrome extension, etc.
The power of Claude Code / GeminiCLI / CodexCLI + [Gemini / OpenAI / OpenRouter / Azure / Grok / Ollama / Custom Model / All Of The Above] working as one.
Run your own MCP server? See who uses it and what to fix.
Measure it with TrackMCP