協助改進此頁面
本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
若要為本使用者指南貢獻內容,請點選每個頁面右側面板中的在 GitHub 上編輯此頁面連結。
本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
Amazon EKS MCP 伺服器入門
本指南會逐步解說設定和使用 EKS MCP 伺服器與 AI 程式碼助理的步驟。您將了解如何設定環境、連線至伺服器,並透過自然語言互動開始管理 EKS 叢集。
注意
Amazon EKS MCP 伺服器目前為 Amazon EKS 的預覽版本,可能會有所變更。
先決條件
開始之前,請確定您已執行下列任務:
設定
1. 確認 先決條件
# Check that your Python version is 3.10 or higher python3 --version # Check uv installation uv --version # Verify CLI configuration aws configure list
2. 設定 IAM 許可
若要連線至 EKS MCP 伺服器,您的 IAM 角色必須連接下列政策: eks-mcp:InvokeMcp(初始化和擷取可用工具相關資訊所需的許可)、 eks-mcp:CallReadOnlyTool(使用唯讀工具所需的許可) 和 eks-mcp:CallPrivilegedTool(使用完整存取 (寫入) 工具所需的許可)。這些eks-mcp許可包含在以下提供的唯讀和完整存取 AWS 受管政策中。
-
開啟 IAM 主控台
。 -
在左側導覽窗格中,根據您要連接政策的身分,然後選擇使用者、使用者群組或角色,然後選擇特定使用者、群組或角色的名稱。
-
選擇許可索引標籤。
-
選擇連接政策 (如果是第一次新增許可)。
-
在政策清單中,搜尋並選取您要連接的受管政策:
-
唯讀操作:AmazonEKSMCPReadOnlyAccess
-
選擇連接政策 (或下一步,然後選擇新增許可以確認)。
這會連接政策,且許可會立即生效。您可以將多個政策連接到相同的身分,而且每個政策都可以包含各種許可。若要進一步了解這些政策,請參閱 AWS Amazon Elastic Kubernetes Service 的 受管政策。
3. 選擇 AI 助理
選擇下列其中一個 MCP 相容 AI 助理或任何 MCP 相容工具:
步驟 1:設定您的 AI 助理
選擇下列任一選項來設定您的 AI 程式碼助理。完成此步驟會將您的 AI 程式碼助理設定為使用 MCP Proxy AWS,這是安全、已驗證存取 Amazon EKS MCP 伺服器的必要項目。這包括新增或編輯 MCP 組態檔案 (例如,~/.aws/amazonq/mcp.json適用於 Amazon Q Developer CLI)。代理充當用戶端橋接器,使用本機 AWS 登入資料處理 AWS SigV4 身分驗證,並啟用動態工具探索,以便與後端 AWS MCP 伺服器互動,例如 EKS MCP 伺服器。若要進一步了解,請參閱儲存 AWS 庫的 MCP Proxy
選項 A:Amazon Q 開發人員 CLI
Q 開發人員 CLI 提供最整合的 EKS MCP 伺服器體驗。
1. 尋找 MCP 組態檔案
-
macOS/Linux:
~/.aws/q/mcp.json -
Windows:
%USERPROFILE%\.aws\q\mcp.json
2. 新增 MCP 伺服器組態
如果組態檔案不存在,請建立組態檔案。請務必將區域 ({region}) 預留位置取代為您想要的區域。
對於 Mac/Linux:
{ "mcpServers": { "eks-mcp": { "disabled": false, "type": "stdio", "command": "uvx", "args": [ "mcp-proxy-for-aws@latest", "https://eks-mcp.{region}.api.aws/mcp", "--service", "eks-mcp", "--profile", "default", "--region", "{region}" ] } } }
用於 Windows:
{ "mcpServers": { "eks-mcp": { "disabled": false, "type": "stdio", "command": "uvx", "args": [ "--from", "mcp-proxy-for-aws@latest", "mcp-proxy-for-aws.exe", "https://eks-mcp.{region}.api.aws/mcp", "--service", "eks-mcp", "--profile", "default", "--region", "{region}" ] } } }
安全備註: --read-only 只能用於允許唯讀工具操作。
3. 驗證組態
重新啟動 Q 開發人員 CLI,然後檢查可用的工具:
q /tools
選項 B:Kiro IDE
Kiro 是具有內建 MCP 支援的
1. 開啟 Kiro 設定
-
開啟 Kiro
-
前往 Kiro → 設定並搜尋 "MCP Config"
-
或按
Cmd+Shift+P,(Mac) 或Ctrl+Shift+P,(Windows/Linux) 搜尋 "MCP Config"
2. 新增 MCP 伺服器組態
-
按一下「開啟工作區 MCP Config」或「開啟使用者 MCP Config」以直接編輯 MCP 組態檔案。
請務必將區域 ({region}) 預留位置取代為您想要的區域。
對於 Mac/Linux:
{ "mcpServers": { "eks-mcp": { "disabled": false, "type": "stdio", "command": "uvx", "args": [ "mcp-proxy-for-aws@latest", "https://eks-mcp.{region}.api.aws/mcp", "--service", "eks-mcp", "--profile", "default", "--region", "{region}" ] } } }
用於 Windows:
{ "mcpServers": { "eks-mcp": { "disabled": false, "type": "stdio", "command": "uvx", "args": [ "--from", "mcp-proxy-for-aws@latest", "mcp-proxy-for-aws.exe", "https://eks-mcp.{region}.api.aws/mcp", "--service", "eks-mcp", "--profile", "default", "--region", "{region}" ] } } }
安全備註: --read-only 只能用於允許唯讀工具操作。
選項 C:游標 IDE
游標透過圖形組態界面提供內建的 MCP 支援。
1. 開啟游標設定
-
開啟游標
-
前往設定 → 游標設定 → 工具和 MCP
-
或按
Cmd+Shift+P(Mac) /Ctrl+Shift+P(Windows) 搜尋 "MCP"
2. 新增 MCP 伺服器組態
-
按一下「新的 MCP 伺服器」
如果組態檔案不存在,請建立組態檔案。請務必將區域 ({region}) 預留位置取代為您想要的區域。
對於 Mac/Linux:
{ "mcpServers": { "eks-mcp": { "disabled": false, "type": "stdio", "command": "uvx", "args": [ "mcp-proxy-for-aws@latest", "https://eks-mcp.{region}.api.aws/mcp", "--service", "eks-mcp", "--profile", "default", "--region", "{region}" ] } } }
用於 Windows:
{ "mcpServers": { "eks-mcp": { "disabled": false, "type": "stdio", "command": "uvx", "args": [ "--from", "mcp-proxy-for-aws@latest", "mcp-proxy-for-aws.exe", "https://eks-mcp.{region}.api.aws/mcp", "--service", "eks-mcp", "--profile", "default", "--region", "{region}" ] } } }
安全備註: --read-only 只能用於允許唯讀工具操作。
3. 重新啟動游標
關閉並重新開啟游標,以使變更生效。
4. 在游標聊天中驗證
開啟聊天面板並嘗試:
What EKS MCP tools are available?
您應該會看到可用的 EKS 管理工具清單。
選項 D:Cline (VS 程式碼延伸)
Cline 是熱門的 VS 程式碼延伸模組,可將 AI 協助直接帶入編輯器。
1. 開啟曲線設定
-
開啟曲線
-
按
Cmd+Shift+P(Mac) /Ctrl+Shift+P(Windows) 搜尋 "MCP"
2. 新增 MCP 伺服器組態
-
按一下「新增伺服器」
-
按一下「開啟使用者組態」
如果組態檔案不存在,請建立組態檔案。請務必將區域 ({region}) 預留位置取代為您想要的區域。
對於 Mac/Linux:
{ "mcpServers": { "eks-mcp": { "disabled": false, "type": "stdio", "command": "uvx", "args": [ "mcp-proxy-for-aws@latest", "https://eks-mcp.{region}.api.aws/mcp", "--service", "eks-mcp", "--profile", "default", "--region", "{region}" ] } } }
用於 Windows:
{ "mcpServers": { "eks-mcp": { "disabled": false, "type": "stdio", "command": "uvx", "args": [ "--from", "mcp-proxy-for-aws@latest", "mcp-proxy-for-aws.exe", "https://eks-mcp.{region}.api.aws/mcp", "--service", "eks-mcp", "--profile", "default", "--region", "{region}" ] } } }
安全備註: --read-only 只能用於允許唯讀工具操作。
2. 重新載入 VS 程式碼
按 Cmd+Shift+P / Ctrl+Shift+P然後選取「開發人員:重新載入視窗」
3. 驗證組態
開啟 Cline 並詢問:
List the available MCP tools for EKS
步驟 2:(選用) 建立「寫入」政策
或者,您可以建立客戶管理的 IAM 政策,提供 Amazon EKS MCP 伺服器的完整存取權。此政策授予許可,以使用 EKS MCP 伺服器中的所有工具,包括可能涉及寫入操作和唯讀工具的特權工具。請注意,此政策包含高風險許可 (任何 Delete* 或未限制的 IAM 資源),因為在 manage_eks_stacks 工具中設定/縮減叢集資源時需要這些許可。
aws iam create-policy \ --policy-name EKSMcpWriteManagementPolicy \ --policy-document "{\"Version\": \"2012-10-17\", \"Statement\": [{\"Effect\": \"Allow\", \"Action\": [\"eks:DescribeCluster\", \"eks:ListClusters\", \"eks:DescribeNodegroup\", \"eks:ListNodegroups\", \"eks:DescribeAddon\", \"eks:ListAddons\", \"eks:DescribeAccessEntry\", \"eks:ListAccessEntries\", \"eks:DescribeInsight\", \"eks:ListInsights\", \"eks:AccessKubernetesApi\"], \"Resource\": \"*\"}, {\"Effect\": \"Allow\", \"Action\": [\"eks:CreateCluster\", \"eks:DeleteCluster\", \"eks:CreateAccessEntry\", \"eks:TagResource\"], \"Resource\": \"*\"}, {\"Effect\": \"Allow\", \"Action\": [\"iam:GetRole\", \"iam:ListRolePolicies\", \"iam:ListAttachedRolePolicies\", \"iam:GetRolePolicy\", \"iam:GetPolicy\", \"iam:GetPolicyVersion\"], \"Resource\": \"*\"}, {\"Effect\": \"Allow\", \"Action\": [\"iam:TagRole\", \"iam:CreateRole\", \"iam:AttachRolePolicy\", \"iam:PutRolePolicy\", \"iam:DetachRolePolicy\", \"iam:DeleteRole\"], \"Resource\": \"*\"}, {\"Effect\": \"Allow\", \"Action\": [\"iam:PassRole\"], \"Resource\": \"*\", \"Condition\": {\"StringEquals\": {\"iam:PassedToService\": [\"eks.amazonaws.com\", \"ec2.amazonaws.com\"]}}}, {\"Effect\": \"Allow\", \"Action\": [\"ec2:CreateVpc\", \"ec2:CreateSubnet\", \"ec2:CreateRouteTable\", \"ec2:CreateRoute\", \"ec2:CreateInternetGateway\", \"ec2:CreateNatGateway\", \"ec2:CreateSecurityGroup\", \"ec2:AttachInternetGateway\", \"ec2:AssociateRouteTable\", \"ec2:ModifyVpcAttribute\", \"ec2:ModifySubnetAttribute\", \"ec2:AllocateAddress\", \"ec2:CreateTags\"], \"Resource\": \"*\"}, {\"Effect\": \"Allow\", \"Action\": [\"ec2:DeleteVpc\", \"ec2:DeleteSubnet\", \"ec2:DisassociateRouteTable\", \"ec2:DeleteRouteTable\", \"ec2:DeleteRoute\", \"ec2:DetachInternetGateway\", \"ec2:DeleteInternetGateway\", \"ec2:DeleteNatGateway\", \"ec2:ReleaseAddress\", \"ec2:DeleteSecurityGroup\"], \"Resource\": \"*\"}, {\"Effect\": \"Allow\", \"Action\": [\"ec2:DescribeVpcs\", \"ec2:DescribeSubnets\", \"ec2:DescribeRouteTables\", \"ec2:DescribeInternetGateways\", \"ec2:DescribeNatGateways\", \"ec2:DescribeAddresses\", \"ec2:DescribeSecurityGroups\", \"ec2:DescribeAvailabilityZones\"], \"Resource\": \"*\"}, {\"Effect\": \"Allow\", \"Action\": [\"cloudformation:CreateStack\", \"cloudformation:UpdateStack\", \"cloudformation:DeleteStack\", \"cloudformation:DescribeStacks\", \"cloudformation:TagResource\"], \"Resource\": \"*\"}, {\"Effect\": \"Allow\", \"Action\": [\"sts:GetCallerIdentity\"], \"Resource\": \"*\"}, {\"Effect\": \"Allow\", \"Action\": [\"logs:StartQuery\", \"logs:GetQueryResults\"], \"Resource\": \"*\"}, {\"Effect\": \"Allow\", \"Action\": [\"cloudwatch:GetMetricData\"], \"Resource\": \"*\"}, {\"Effect\": \"Allow\", \"Action\": [\"eks-mcp:*\"], \"Resource\": \"*\"}]}"
步驟 3:驗證您的設定
測試連線
向您的 AI 助理詢問簡單的問題以驗證連線:
List all EKS clusters in my {aws} account
您應該會看到 EKS 叢集的清單。
步驟 4:執行您的第一個任務
範例 1:探索您的叢集
Show me all EKS clusters and their status What insights does EKS have about my production-cluster? Show me the VPC configuration for my staging cluster
範例 2:檢查 Kubernetes 資源
Get the details of all the kubernetes resources deployed in my EKS cluster Show me pods that are not in Running state or pods with any restarts Get the logs from the aws-node daemonset in the last 30 minutes
範例 3:故障診斷問題
Why is my nginx-ingress-controller pod failing to start? Search the EKS troubleshooting guide for pod networking issues Show me events related to the failed deployment in the staging namespace
範例 4:建立資源 (如果已啟用「寫入」模式)
Create a new EKS cluster named demo-cluster with VPC and Auto Mode Deploy my containerized app from ECR to the production namespace with 3 replicas Generate a Kubernetes deployment YAML for my Node.js app running on port 3000
常見組態
案例 1:多個 AWS 設定檔
如果您使用多個 AWS 帳戶,請建立個別的 MCP 伺服器組態。
對於 Mac/Linux:
{ "mcpServers": { "eks-mcp-prod": { "disabled": false, "type": "stdio", "command": "uvx", "args": [ "mcp-proxy-for-aws@latest", "https://eks-mcp.{region}.api.aws/mcp", "--service", "eks-mcp", "--profile", "production", "--region", "us-west-2" ] }, "eks-mcp-dev": { "disabled": false, "type": "stdio", "command": "uvx", "args": [ "mcp-proxy-for-aws@latest", "https://eks-mcp.{region}.api.aws/mcp", "--service", "eks-mcp", "--profile", "development", "--region", "us-east-1" ] } } }
用於 Windows:
{ "mcpServers": { "eks-mcp-prod": { "disabled": false, "type": "stdio", "command": "uvx", "args": [ "--from", "mcp-proxy-for-aws@latest", "mcp-proxy-for-aws.exe", "https://eks-mcp.{region}.api.aws/mcp", "--service", "eks-mcp", "--profile", "production", "--region", "us-west-2" ] }, "eks-mcp-dev": { "disabled": false, "type": "stdio", "command": "uvx", "args": [ "--from", "mcp-proxy-for-aws@latest", "mcp-proxy-for-aws.exe", "https://eks-mcp.{region}.api.aws/mcp", "--service", "eks-mcp", "--profile", "development", "--region", "us-east-1" ] } } }
案例 2:生產唯讀
建立生產環境的唯讀組態。
對於 Mac/Linux:
{ "mcpServers": { "eks-mcp-prod-readonly": { "command": "uvx", "args": [ "mcp-proxy-for-aws@latest", "https://eks-mcp.{region}.api.aws/mcp", "--service", "eks-mcp", "--profile", "production", "--region", "us-west-2", "--read-only" ], "autoApprove": [ "list_k8s_resources", "get_pod_logs", "get_k8s_events" ] } } }
用於 Windows:
{ "mcpServers": { "eks-mcp-prod-readonly": { "command": "uvx", "args": [ "--from", "mcp-proxy-for-aws@latest", "mcp-proxy-for-aws.exe", "https://eks-mcp.{region}.api.aws/mcp", "--service", "eks-mcp", "--profile", "production", "--region", "us-west-2", "--read-only" ], "autoApprove": [ "list_k8s_resources", "get_pod_logs", "get_k8s_events" ] } } }
案例 3:具有完整存取權的開發
適用於具有完整寫入存取權的開發環境。
對於 Mac/Linux:
{ "mcpServers": { "eks-mcp-dev-full": { "command": "uvx", "args": [ "mcp-proxy-for-aws@latest", "https://eks-mcp.{region}.api.aws/mcp", "--service", "eks-mcp", "--profile", "development", "--region", "us-east-1" ] } } }
用於 Windows:
{ "mcpServers": { "eks-mcp-dev-full": { "command": "uvx", "args": [ "--from", "mcp-proxy-for-aws@latest", "mcp-proxy-for-aws.exe", "https://eks-mcp.{region}.api.aws/mcp", "--service", "eks-mcp", "--profile", "development", "--region", "us-east-1" ] } } }
考量事項
安全
請勿透過允許的輸入機制傳遞秘密或敏感資訊:
-
請勿在搭配 apply_yaml 套用的 YAML 檔案中包含秘密或登入資料。
-
請勿直接在提示中將敏感資訊傳遞給模型。
-
請勿在 CloudFormation 範本或應用程式資訊清單中包含秘密。
-
避免使用 MCP 工具建立 Kubernetes 秘密,因為這需要將秘密資料提供給模型。
-
避免在 Kubernetes Pod 內的應用程式日誌中記錄敏感資訊。
YAML 內容安全性:
-
僅使用來自可信任來源的 YAML 檔案。
-
伺服器依賴 Kubernetes API 驗證 YAML 內容,並且不執行自己的驗證。
-
將 YAML 檔案套用至叢集之前,請對其進行稽核。
而不是透過 MCP 傳遞秘密:
-
使用 AWS Secrets Manager 或 參數存放區來存放敏感資訊。
-
為服務帳戶設定適當的 Kubernetes RBAC。
-
將服務帳戶 (IRSA) 的 IAM 角色用於 Pod AWS 的服務存取。
敏感資料的編輯:
-
EKS MCP 伺服器會自動修訂工具回應中安全字符、憑證和其他敏感資訊的常見模式。
-
修訂後的值會取代為
HIDDEN_FOR_SECURITY_REASONS,以避免不小心將資料暴露至模型。 -
此修訂適用於所有工具回應,包括日誌、資源描述和組態資料。
下一步
如需組態選項,請參閱 Amazon EKS MCP 伺服器組態參考。如需工具的完整清單,請參閱 Amazon EKS MCP 伺服器工具參考。