Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.
Memulai dengan Amazon ECS MCP Server
Panduan ini memandu Anda melalui langkah-langkah untuk mengatur dan menggunakan Amazon ECS MCP Server dengan asisten kode AI Anda. Anda akan belajar cara mengonfigurasi lingkungan Anda, terhubung ke server, dan mulai mengelola cluster Amazon ECS Anda melalui interaksi bahasa alami.
catatan
Server Amazon ECS MCP sedang dalam rilis pratinjau dan dapat berubah.
Prasyarat
Sebelum memulai, pastikan Anda memiliki:
Pengaturan
Memverifikasi prasyarat
Periksa apakah versi Python Anda 3.10 atau lebih tinggi
python3 --version
Periksa instalasi uv
uv --version
Verifikasi AWS CLI konfigurasi
aws configure list
Menyiapkan izin IAM
Anda akan memerlukan izin IAM untuk membuat permintaan read-only ke AWS layanan dan berinteraksi dengan server MCP. Anda dapat memanfaatkan kebijakan ter AWS kelola, atau kebijakan kustom tunggal untuk kontrol yang lebih terperinci.
Opsi 1: Gabungan kebijakan terkelola dan kustom
-
Lampirkan kebijakan AWS terkelola ReadOnlyAccess untuk akses baca-saja ke semua layanan AWS
-
Membuat dan melampirkan kebijakan kustom tambahan untuk izin MCP (lihat izin MCP berikut JSON)
{ "Version": "2012-10-17", "Statement": [ { "Sid": "MCPServerAccess", "Effect": "Allow", "Action": [ "ecs-mcp:InvokeReadOnlyTools", "ecs-mcp:UseMcp" ], "Resource": "*" } ] }
Opsi 2: Kebijakan kustom tunggal (kontrol paling granular)
Atau, Anda dapat membuat dan melampirkan kebijakan JSON kustom tunggal yang mencakup izin AWS layanan dan izin MCP:
{ "Version": "2012-10-17", "Statement": [ { "Sid": "MCPServerAccess", "Effect": "Allow", "Action": [ "ecs-mcp:InvokeReadOnlyTools", "ecs-mcp:UseMcp" ], "Resource": "*" }, { "Sid": "ECSReadOnlyAccess", "Effect": "Allow", "Action": [ "ecs:ListAccountSettings", "ecs:ListClusters", "ecs:ListContainerInstances", "ecs:ListTaskDefinitions", "ecs:ListServices", "ecs:ListServiceDeployments", "ecs:ListTasks", "ecs:DescribeClusters", "ecs:DescribeCapacityProviders", "ecs:DescribeContainerInstances", "ecs:DescribeTaskDefinition", "ecs:DescribeServices", "ecs:DescribeServiceDeployments", "ecs:DescribeServiceRevisions", "ecs:DescribeTaskSets", "ecs:DescribeTasks" ], "Resource": "*" }, { "Sid": "CloudWatchLogsReadOnlyAccess", "Effect": "Allow", "Action": [ "logs:DescribeLogGroups", "logs:DescribeLogStreams", "logs:GetLogEvents", "logs:FilterLogEvents" ], "Resource": "*" }, { "Sid": "ELBReadOnlyAccess", "Effect": "Allow", "Action": [ "elasticloadbalancing:DescribeLoadBalancers", "elasticloadbalancing:DescribeTargetGroups", "elasticloadbalancing:DescribeListeners" ], "Resource": "*" }, { "Sid": "EC2ReadOnlyAccess", "Effect": "Allow", "Action": [ "ec2:DescribeVpcs", "ec2:DescribeSubnets", "ec2:DescribeSecurityGroups", "ec2:DescribeRouteTables", "ec2:DescribeNetworkInterfaces" ], "Resource": "*" }, { "Sid": "ECRReadOnlyAccess", "Effect": "Allow", "Action": [ "ecr:DescribeRepositories", "ecr:DescribeImages" ], "Resource": "*" }, { "Sid": "IAMReadOnlyAccessForSecurityAnalysis", "Effect": "Allow", "Action": [ "iam:GetRole", "iam:ListAttachedRolePolicies", "iam:GetPolicy", "iam:GetPolicyVersion", "iam:ListRolePolicies", "iam:GetRolePolicy" ], "Resource": "*" } ] }
Pilih dan konfigurasikan asisten AI
Instal asisten MCP-compatible AI atau MCP-compatible alat apa pun. Misalnya, Anda dapat menggunakan Kiro
Temukan file konfigurasi MCP
-
macOS/Linux:
~/.kiro/settings/mcp.json -
Windows:
%USERPROFILE%\.kiro\settings\mcp.json
Buat file konfigurasi jika tidak ada.
Tambahkan konfigurasi server MCP
Pastikan untuk mengganti placeholder region ({region}) dengan wilayah yang Anda inginkan (mis.,us-west-2). Lihat Kontainer Linux di AWS Fargate untuk daftar lengkap wilayah. Juga pastikan untuk mengganti {profile} placeholder dengan nama AWS CLI profil Anda, mis. default
Untuk Mac/Linux:
{ "mcpServers": { "ecs-mcp": { "disabled": false, "type": "stdio", "command": "uvx", "args": [ "mcp-proxy-for-aws@latest", "https://ecs-mcp.{region}.api.aws/mcp", "--service", "ecs-mcp", "--profile", "{profile}", "--region", "{region}" ] } } }
Untuk Windows:
{ "mcpServers": { "ecs-mcp": { "disabled": false, "type": "stdio", "command": "uvx", "args": [ "--from", "mcp-proxy-for-aws@latest", "mcp-proxy-for-aws.exe", "https://ecs-mcp.{region}.api.aws/mcp", "--service", "ecs-mcp", "--profile", "{profile}", "--region", "{region}" ] } } }
Verifikasi konfigurasi
Mulai ulang Kiro CLI,kiro-cli, verifikasi bahwa server MCP dimuat,/mcp, dan periksa alat yang tersedia. /tools
Verifikasi penyiapan Anda
Uji koneksi
Ajukan pertanyaan sederhana kepada asisten AI Anda untuk memverifikasi koneksi:
List all ECS clusters in my AWS account
Anda akan melihat daftar cluster Amazon ECS Anda.
Berbicaralah dengan asisten AI Anda yang menggunakan server Amazon ECS MCP
Contoh 1: Memantau penerapan
Check deployment status for my web-service in production-cluster Show me the ALB URL for my deployed service Get service events for the last hour
Contoh 2: Selidiki kesehatan wadah
Show me all tasks that failed in the last 2 hours Why are my containers failing health checks? Display container logs for my api-service
Contoh 3: Memecahkan masalah kegagalan
Analyze task failures in my production cluster Check for image pull errors in the last 30 minutes Why is my task definition stuck in DELETE_IN_PROGRESS state?
Contoh 4: Periksa konfigurasi
Show me the network configuration for my web-service What security groups are attached to my service? List all VPC and subnet details for my ECS service
Contoh 5: Menilai postur keamanan
Are there any security issues with my production cluster? Analyze IAM roles and policies for my web-service Check for overly permissive security groups in my ECS cluster
Konfigurasi umum dan praktik terbaik
Beberapa AWS profil
Jika Anda bekerja dengan beberapa AWS akun, buat konfigurasi server MCP terpisah.
Untuk Mac/Linux:
{ "mcpServers": { "ecs-mcp-prod": { "disabled": false, "type": "stdio", "command": "uvx", "args": [ "mcp-proxy-for-aws@latest", "https://ecs-mcp.{region}.api.aws/mcp", "--service", "ecs-mcp", "--profile", "production", "--region", "us-west-2" ] }, "ecs-mcp-dev": { "disabled": false, "type": "stdio", "command": "uvx", "args": [ "mcp-proxy-for-aws@latest", "https://ecs-mcp.{region}.api.aws/mcp", "--service", "ecs-mcp", "--profile", "development", "--region", "us-east-1" ] } } }
Praktik terbaik keamanan
Jangan menyampaikan rahasia atau informasi sensitif melalui mekanisme input yang diizinkan:
-
Jangan menyertakan rahasia atau kredenSIAL dalam file konfigurasi apa pun
-
Jangan meneruskan informasi sensitif secara langsung dalam petunjuk ke model
-
Jangan sertakan rahasia dalam definisi tugas atau konfigurasi layanan
-
Hindari mencatat informasi sensitif di log aplikasi
-
Gunakan atau Parameter Store untuk menyimpan informasi sensitif
Konfigurasi alat
Untuk daftar lengkap alat dan konfigurasi, lihatKonfigurasi Alat Server MCP Amazon ECS.