本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
故障排除代理的设置
注意
Apache Spark 故障排除代理使用跨区域推理来处理自然语言请求并生成响应。欲了解更多详情,请参阅Apache Spark 故障排除代理的跨区域处理。Amazon SageMaker Unified Studio MCP 服务器处于预览状态,可能会发生变化。
先决条件
在我们开始与 Kiro CLI 集成的设置过程之前,请确保您的工作站上安装了以下内容:
-
AWS 配置的本地证书(通过 AWS CLI、环境变量或 IAM 角色)-用于本地操作,例如上传升级后的作业工件以执行 EMR 验证任务。
安装资源
您可以使用 AWS CloudFormation 模板为 MCP 服务器设置资源。这些模板是您应修改以满足要求的示例。该模板为故障排除过程创建了以下资源:
-
IAM 角色,该角色具有调用 MCP 服务器的权限以及所选平台的故障排除过程所需的权限。
选择下表中的 Launch Stack (启动堆栈) 按钮之一。这将在相应区域的主 AWS CloudFormation 机上启动堆栈。
进入指定堆栈详细信息页面,输入堆栈名称。在 Parameters(参数)下输入其他信息。提供以下信息,然后继续创建堆栈。
-
TroubleshootingRoleName-要为故障排除操作创建的 IAM 角色的名称
-
启用 EMREC2-启用 EMR-EC2 疑难解答权限(默认:true)
-
启用 EMRServerless-启用 EMR 无服务器故障排除权限(默认值:true)
-
EnableGlue-启用 Glue 疑难解答权限(默认值:true)
-
CloudWatchKmsKeyArn-(可选)用于 CloudWatch 日志加密的现有 KMS 密钥的 ARN(仅限 EMR Serverless,默认加密留空)
您也可以下载并查看 CloudFormation 模板
# deploy the stack with CloudFormation CLI commands aws cloudformation deploy \ --template-file spark-troubleshooting-mcp-setup.yaml \ --stack-name spark-troubleshooting-mcp-setup \ --region <your Spark MCP server launch region> \ --capabilities CAPABILITY_NAMED_IAM \ --parameter-overrides \ TroubleshootingRoleName=spark-troubleshooting-role # retrieve the 1-line instruction to set the local environment variables, which will be used for the following MCP server configuration aws cloudformation describe-stacks \ --stack-name spark-troubleshooting-mcp-setup \ --region <your Spark MCP server launch region> \ --query "Stacks[0].Outputs[?OutputKey=='ExportCommand'].OutputValue" \ --output text
打开 “输出” 选项卡(或从上面的 desc CloudFormation ribe-stacks CLI 命令中检索),从输出中复制单行指令以设置环境变量,然后 CloudFormation 在本地环境中执行该指令。单行指令示例:
export SMUS_MCP_REGION=<your mcp server launch region> && export IAM_ROLE=arn:aws:iam::111122223333:role/spark-troubleshooting-role-xxxxxx
然后在本地运行以下命令来设置 IAM 配置文件和 MCP 服务器配置:
# Step 1: Configure AWS CLI Profile aws configure set profile.smus-mcp-profile.role_arn ${IAM_ROLE} aws configure set profile.smus-mcp-profile.source_profile <AWS CLI Profile to assume the IAM role - ex: default> aws configure set profile.smus-mcp-profile.region ${SMUS_MCP_REGION} # Step 2: if you are using kiro CLI, use the following command to add the MCP configuration # Add Spark Troubleshooting MCP Server kiro-cli-chat mcp add \ --name "sagemaker-unified-studio-mcp-troubleshooting" \ --command "uvx" \ --args "[\"mcp-proxy-for-aws@latest\",\"https://sagemaker-unified-studio-mcp.${SMUS_MCP_REGION}.api.aws/spark-troubleshooting/mcp\", \"--service\", \"sagemaker-unified-studio-mcp\", \"--profile\", \"smus-mcp-profile\", \"--region\", \"${SMUS_MCP_REGION}\", \"--read-timeout\", \"180\"]" \ --timeout 180000 \ --scope global # Add Spark Code Recommendation MCP Server kiro-cli-chat mcp add \ --name "sagemaker-unified-studio-mcp-code-rec" \ --command "uvx" \ --args "[\"mcp-proxy-for-aws@latest\",\"https://sagemaker-unified-studio-mcp.${SMUS_MCP_REGION}.api.aws/spark-code-recommendation/mcp\", \"--service\", \"sagemaker-unified-studio-mcp\", \"--profile\", \"smus-mcp-profile\", \"--region\", \"${SMUS_MCP_REGION}\", \"--read-timeout\", \"180\"]" \ --timeout 180000 \ --scope global
这应该~/.kiro/settings/mcp.json会更新以包括下面的 MCP 服务器配置。
{ "mcpServers": { "sagemaker-unified-studio-mcp-troubleshooting": { "type": "stdio", "command": "uvx", "args": [ "mcp-proxy-for-aws@latest", "https://sagemaker-unified-studio-mcp.us-east-1.api.aws/spark-troubleshooting/mcp", "--service", "sagemaker-unified-studio-mcp", "--profile", "smus-mcp-profile", "--region", "us-east-1", "--read-timeout", "180" ], "timeout": 180000, "disabled": false }, "sagemaker-unified-studio-mcp-code-rec": { "type": "stdio", "command": "uvx", "args": [ "mcp-proxy-for-aws@latest", "https://sagemaker-unified-studio-mcp.us-east-1.api.aws/spark-code-recommendation/mcp", "--service", "sagemaker-unified-studio-mcp", "--profile", "smus-mcp-profile", "--region", "us-east-1", "--read-timeout", "180" ], "timeout": 180000, "disabled": false } } }
有关不同 MCP 客户端(例如 Kiro、Cline 和)的配置指南,请参阅支持的接口。 GitHub CoPilot