本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
升級代理程式的設定
注意
Apache Spark 升級代理程式使用跨區域推論來處理自然語言請求並產生回應。如需詳細資訊,請參閱 上的此頁面Apache Spark 升級代理程式的跨區域處理。Amazon SageMaker Unified Studio MCP 伺服器處於預覽狀態,可能會有所變更。
先決條件
在我們開始與 Kiro CLI 整合的設定程序之前,請確定您的工作站已安裝下列項目:
-
AWS 已設定的本機登入資料 (透過 AWS CLI、環境變數或 IAM 角色) - 用於本機操作,例如上傳升級的任務成品以進行 EMR 驗證任務執行。
設定資源
您可以使用 CloudFormation 範本來設定 MCP 伺服器的資源。這些範本是範例,您應加以修改以符合您的需求。範本會為升級程序建立下列資源:
-
IAM 角色,其具有呼叫 MCP Server 的許可,以及基礎 EMR 平台升級程序所需的許可。
-
用於上傳升級成品的 Amazon S3 預備儲存貯體,以及用於 Amazon S3 加密的選用 KMS 金鑰。
選擇下表中的其中一個 Launch Stack (啟動堆疊) 按鈕。這會在個別區域的 CloudFormation 主控台上啟動堆疊。
繼續前往指定堆疊詳細資訊頁面,輸入堆疊名稱。在 Parameters (參數) 下輸入其他資訊。提供以下資訊並繼續建立堆疊。
-
SparkUpgradeIAMRoleName - 用於 Spark 升級程序的 IAM 角色名稱
-
EnableEMREC2 - 啟用 EMR-EC2 升級許可 (預設值: true)
-
EnableEMRServerless - 啟用 EMR-Serverless 升級許可 (預設值: true)
-
StagingBucketPath - 預備成品的 Amazon S3 路徑 (例如 s3://my-bucket/spark-upgrade 或 my-bucket/spark-upgrade)。保留空白以自動產生新儲存貯體
-
UseS3Encryption - 啟用 Amazon S3 預備儲存貯體的 KMS 加密 (預設值:false,設定為 true 以使用 KMS 加密,而非預設 S3 加密)
-
Amazon S3 儲存貯體加密現有 KMS 金鑰的 S3KmsKeyArn - (選用) ARN。 Amazon S3 僅在 UseS3Encryption 為 true 且您擁有具有 KMS 金鑰的現有儲存貯體時使用
-
CloudWatchKmsKeyArn - (選用) CloudWatch Logs 加密現有 KMS 金鑰的 ARN (僅限 EMR Serverless,預設加密保留空白)
-
EMRServerlessS3LogPath - (選用) 存放 EMR-Serverless 應用程式日誌的 S3 路徑 (例如 s3://my-bucket/emr-serverless-logs 或 my-bucket/emr-serverless-logs)。提供時, 會授予 IAM 角色對這些日誌的讀取存取權以供分析。僅在 EnableEMRServerless 為 true 時使用
-
ExecutionRoleToGrantS3Access - (選用) 現有 EMR-EC2/EMR-Serverless 執行角色的 IAM 角色名稱或 ARN,以授予 Amazon S3 預備儲存貯體存取權。僅適用於建立新的預備儲存貯體時。用於授予 EMR 任務執行角色對預備儲存貯體的存取權。支援具有路徑的簡單角色名稱和 ARNs。
您也可以下載並檢閱 CloudFormation 範本
# deploy the stack with CloudFormation CLI commands aws cloudformation deploy \ --template-file spark-upgrade-mcp-setup.yaml \ --stack-name spark-mcp-setup \ --region <your mcp server launch region> \ --capabilities CAPABILITY_NAMED_IAM \ --parameter-overrides \ ExecutionRoleToGrantS3Access=<your EMR or EMR Serverless job execution 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-mcp-setup \ --region <your mcp server launch region> \ --query "Stacks[0].Outputs[?OutputKey=='ExportCommand'].OutputValue" \ --output text
開啟輸出索引標籤 (或從上述 CloudFormation describe-stacks CLI 命令擷取) 並複製 1 行指令 ExportCommand,然後在您的本機環境中執行。範例 1 行指令:
export SMUS_MCP_REGION=<your mcp server launch region> && export IAM_ROLE=arn:aws:iam::111122223333:role/spark-upgrade-role-xxxxxx && export STAGING_BUCKET_PATH=<your staging bucket path>
然後在本機執行下列命令來設定 IAM 設定檔和 MCP 伺服器組態
# Step 1: Configure AWS CLI Profile aws configure set profile.spark-upgrade-profile.role_arn ${IAM_ROLE} aws configure set profile.spark-upgrade-profile.source_profile <AWS CLI Profile to assume the IAM role - ex: default> aws configure set profile.spark-upgrade-profile.region ${SMUS_MCP_REGION} # Step 2: if you are using Kiro CLI, use the following command to add the MCP configuration kiro-cli-chat mcp add \ --name "spark-upgrade" \ --command "uvx" \ --args "[\"mcp-proxy-for-aws@latest\",\"https://sagemaker-unified-studio-mcp.${SMUS_MCP_REGION}.api.aws/spark-upgrade/mcp\", \"--service\", \"sagemaker-unified-studio-mcp\", \"--profile\", \"spark-upgrade-profile\", \"--region\", \"${SMUS_MCP_REGION}\", \"--read-timeout\", \"180\"]" \ --timeout 180000\ --scope global
這應該更新~/.kiro/settings/mcp.json為包含 MCP 伺服器組態,如下所示。
{ "mcpServers": { "spark-upgrade": { "type": "stdio", "command": "uvx", "args": [ "mcp-proxy-for-aws@latest", "https://sagemaker-unified-studio-mcp.us-east-1.api.aws/spark-upgrade/mcp", "--service", "sagemaker-unified-studio-mcp", "--profile", "spark-upgrade-profile", "--region", "us-east-1", "--read-timeout", "180" ], "timeout": 180000, "disabled": false } } }
使用升級代理程式 如需 Kiro、Cline 和 GitHub CoPilot 等不同 MCP 用戶端的組態指引,請參閱 。