帮助改进此页面
要帮助改进本用户指南,请选择位于每个页面右侧窗格中的在 GitHub 上编辑此页面链接。
Amazon EKS MCP 服务器入门
本指南将指导您完成通过人工智能代码助手设置和使用 EKS MCP 服务器的步骤。您将了解如何配置环境、连接到服务器以及通过自然语言交互开始管理 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
-
选择附加策略(或选择下一步,再选择添加权限进行确认)。
执行此操作后,策略即被附加,相关权限会立即生效。您可以为同一个身份附加多个策略,且每个策略均可包含多种权限。要了解有关这些政策的更多信息,请参阅 Amazon Elastic Kubernetes Service 的 AWS 托管策略。
3. 选择人工智能助手
选择以下任一兼容 MCP 的人工智能助手,或其他任意兼容 MCP 的工具:
步骤 1:配置人工智能助手
从以下任一选项中选择,完成人工智能代码助手配置。完成此步骤后,人工智能代码助手将通过适用于 AWS 的 MCP 代理运行,而该代理是安全、经过身份验证访问 Amazon EKS MCP 服务器的必要组件。此过程需要添加或编辑 MCP 配置文件(例如,适用于 Amazon Q 开发者版 CLI 的配置文件路径为 ~/.aws/amazonq/mcp.json)。该代理充当客户端侧的桥接组件,会利用本地的 AWS 凭证执行 AWS SigV4 身份验证,同时支持动态工具发现功能,以此实现与后端 AWS MCP 服务器(如 EKS MCP 服务器)的交互。要了解更多信息,请参阅 MCP Proxy for AWS 存储库
选项 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 配置”或“打开用户 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 参数限制工具仅执行只读操作。
选项 C:Cursor IDE
Cursor 通过图形配置界面提供内置 MCP 支持功能。
1. 打开 Cursor 设置
-
打开 Cursor
-
前往设置 → Cursor 设置 → 工具和 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. 重新启动 Cursor
关闭并重新打开 Cursor,使更改生效。
4. 在 Cursor 对话中验证
打开对话面板,尝试输入以下内容:
What EKS MCP tools are available?
此时应该会看到一份可用的 EKS 管理工具列表。
选项 D:Cline(VS Code 扩展)
Cline 是一款热门的 VS Code 扩展程序,可直接在编辑器中提供人工智能助手功能。
1. 打开 Cline设置
-
打开 Cline
-
按下
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 Code
按下 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 或 Parameter Store 存储敏感信息。
-
为服务账户配置合规的 Kubernetes RBAC 权限。
-
对于容器组(pod)访问 AWS 服务的场景,采用基于服务账户的 IAM 角色(IRSA)机制。
后续步骤
有关工具和配置的完整列表,请参阅 Amazon EKS MCP 服务器工具配置参考。