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 mempelajari cara mengonfigurasi lingkungan, terhubung ke server, dan mulai mengelola kluster Amazon ECS melalui interaksi bahasa alami.
catatan
Server Amazon ECS MCP sedang dalam rilis pratinjau dan dapat berubah sewaktu-waktu.
Prasyarat
Sebelum Anda mulai, 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
Siapkan izin IAM
Anda akan memerlukan izin IAM untuk membuat permintaan hanya-baca ke AWS layanan dan berinteraksi dengan server MCP. Anda dapat memanfaatkan kebijakan AWS terkelola, atau satu kebijakan khusus untuk kontrol yang lebih terperinci.
Opsi 1: Gabungan kebijakan terkelola dan kustom
-
Lampirkan kebijakan AWS terkelola ReadOnlyAccessuntuk akses hanya-baca ke semua layanan AWS
-
Membuat dan melampirkan kebijakan kustom tambahan untuk izin MCP (lihat izin MCP JSON di bawah)
{ "Version": "2012-10-17", "Statement": [ { "Sid": "MCPServerAccess", "Effect": "Allow", "Action": [ "ecs-mcp:InvokeReadOnlyTools", "ecs-mcp:UseMcp" ], "Resource": "*" } ] }
Opsi 2: Kebijakan kustom tunggal (kontrol paling terperinci)
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": "*" } ] }
Pilih dan konfigurasikan asisten AI
Instal asisten AI yang kompatibel dengan MCP atau alat yang kompatibel dengan MCP. 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 daftar wilayah yang lengkap. Kontainer Linux di AWS Fargate Pastikan juga 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 CLIkiro-cli,, verifikasi bahwa server MCP dimuat/mcp,, dan periksa alat yang tersedia. /tools
Verifikasi pengaturan Anda
Koneksi uji
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.
Berkomunikasi 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
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 berikan rahasia atau informasi sensitif melalui mekanisme input yang diizinkan:
-
Jangan sertakan rahasia atau kredensional 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 Amazon ECS MCP.