本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
MCP 伺服器整合
如果您在解決方案部署期間部署了選用的 MCP Server 元件,您可以將分散式負載測試解決方案與支援模型內容通訊協定的 AI 開發工具整合。MCP Server 提供透過 AI 助理擷取、管理和分析負載測試的程式設計存取權。
您可以使用您選擇的用戶端 (Kiro CLI、Claude 等) 連線到 DLT MCP 伺服器,每個用戶端的組態指示略有不同。本節提供 MCP Inspector、Kiro CLI、Cline 和 Amazon Quick 的設定指示。
步驟 1:取得 MCP 端點和存取權杖
設定任何 MCP 用戶端之前,您需要從 DLT Web 主控台擷取 MCP 伺服器端點和存取權杖。
-
導覽至分散式負載測試 Web 主控台中的 MCP 伺服器頁面。
-
找到 MCP 伺服器端點區段。
-
使用複製端點 URL 按鈕複製端點 URL。端點 URL 遵循以下格式:
https://{gateway-id}.gateway.bedrock-agentcore.{region}.amazonaws.com/mcp -
找到存取字符區段。
-
使用複製存取權杖按鈕複製存取權杖。
重要
保護存取字符的安全。不要公開共用。根據預設,字符透過 MCP 介面提供對分散式負載測試解決方案的唯讀存取權。如果 MCP 伺服器部署在 ReadWrite 存取模式中,權杖也允許建立、更新和刪除操作。如需詳細資訊,請參閱《 開發人員指南》中的 MCP 工具規格。
步驟 2:使用 MCP Inspector 進行測試
模型內容通訊協定提供 MCP Inspector
注意
MCP Inspector 需要 0.17 版或更新版本。所有請求也可以直接使用 JSON RPC 提出,但 MCP Inspector 提供更易於使用的界面。
安裝和啟動 MCP Inspector
-
如有必要,請安裝 npm。
-
執行下列命令來啟動 MCP Inspector:
npx @modelcontextprotocol/inspector
設定連線
-
在 MCP Inspector 界面中,輸入您的 MCP 伺服器端點 URL。
-
使用存取權杖新增授權標頭。
-
選擇連線以建立連線。
叫用工具
連線後,您可以測試可用的 MCP 工具:
-
瀏覽左側面板中可用工具的清單。
-
選取工具 (例如,
list_scenarios)。 -
提供任何必要的參數。
-
選擇叫用以執行工具並檢視回應。
步驟 3:設定 AI 開發用戶端
使用 MCP Inspector 驗證 MCP Server 連線後,您可以設定偏好的 AI 開發用戶端。
Kiro CLI
Kiro CLI (先前為 Amazon Q Developer CLI) 提供命令列存取 AI 輔助開發與 MCP Server 整合。
組態步驟
-
編輯
mcp.json組態檔案。如需組態檔案位置的詳細資訊,請參閱 Kiro CLI 文件中的模型內容通訊協定 (MCP)。 -
新增您的 DLT MCP 伺服器組態:
{ "mcpServers": { "dlt-mcp": { "type": "http", "url": "https://<gateway-id>.gateway.bedrock-agentcore.<region>.amazonaws.com/mcp", "headers": { "Authorization": "Bearer <access-token>" } } } }
將 <gateway-id>和 <region>取代為 MCP 伺服器端點 URL 中的值,並將 <access-token>取代為您在步驟 1 中複製的值。
驗證組態
-
在終端機中,輸入
kiro-cli以啟動 Kiro CLI。 -
輸入
/mcp查看所有可用的 MCP 伺服器。 -
輸入
/tools查看dlt-mcp和其他設定的 MCP 伺服器提供的可用工具。 -
確認
dlt-mcp已成功初始化。
曲線
Cline 是支援 MCP Server 整合的 AI 編碼助理。
組態步驟
-
在 Cline 中,導覽至管理 MCP 伺服器 > 設定 > 設定 MCP 伺服器。
-
更新
cline_mcp_settings.json檔案:{ "mcpServers": { "dlt-mcp": { "type": "streamableHttp", "url": "https://<gateway-id>.gateway.bedrock-agentcore.<region>.amazonaws.com/mcp", "headers": { "Authorization": "Bearer <access-token>" } } } }將
<gateway-id>和<region>取代為 MCP 伺服器端點 URL 中的值,並將<access-token>取代為您在步驟 1 中複製的值。 -
儲存組態檔案。
-
重新啟動 Cline 以套用變更。
Amazon Quick
Amazon Quick (前身為 Amazon Quick Suite) 提供全方位的 AI 助理平台,並支援 MCP Server 動作。
先決條件
在 Amazon Quick 中設定 MCP 伺服器之前,您需要從 DLT 部署的 Cognito 使用者集區擷取 OAuth 憑證:
-
選取分散式負載測試堆疊。
-
在輸出索引標籤中,尋找並複製與您的 DLT 部署相關聯的 Cognito 使用者集區 ID。
-
導覽至 Amazon Cognito 主控台
。 -
使用 CloudFormation 輸出中的使用者集區 ID 選取使用者集區。
-
在左側導覽中,選取應用程式整合 > 應用程式用戶端。
-
找到名稱結尾為
m2m(machine-to-machine) 的應用程式用戶端,然後選取它。 -
在應用程式用戶端詳細資訊頁面上,複製用戶端 ID。若要顯示用戶端秘密,請選擇顯示用戶端秘密,然後複製 值。
-
返回使用者集區,並從網域索引標籤取得使用者集區網域。
-
透過附加
/oauth2/token到網域的結尾來建構字符端點 URL。
組態步驟
-
在 Amazon Quick 中,建立新的客服人員或選取現有的客服人員。
-
新增客服人員提示,說明如何與 DLT MCP 伺服器互動。
-
新增動作,然後選取 MCP Server 動作。
-
設定 MCP 伺服器詳細資訊:
-
MCP 伺服器 URL:您的 DLT MCP 端點
-
身分驗證類型:服務型身分驗證
-
權杖端點:您的 Cognito 權杖端點 URL
-
用戶端 ID:來自 m2m 應用程式用戶端的用戶端 ID
-
用戶端秘密:來自 m2m 應用程式用戶端的用戶端秘密
-
-
儲存 MCP Server 動作組態。
-
將新的 MCP Server 動作新增至您的代理程式。
啟動和測試代理程式
-
在 Amazon Quick 中啟動代理程式。
-
使用自然語言提示與客服人員開始對話。
-
代理程式將使用 MCP 工具來擷取和分析負載測試資料。
輪換 MCP Server 用戶端秘密
如果您使用服務型 machine-to-machine) 身分驗證將 MCP 用戶端連線至 解決方案,您需負責輪換用戶端使用的用戶端秘密。
這適用於哪個登入資料
解決方案會發出兩個不同的 MCP 登入資料。只有其中一個需要手動輪換。
| Credential | 使用者: | 輪換 |
|---|---|---|
|
使用者存取字符 — 從 Web 主控台的 MCP 伺服器頁面複製 |
MCP Inspector、Kiro CLI、Cline 和其他傳送 |
不需要。這是短期的 Amazon Cognito 存取權杖,會在發出存取權杖後約一小時過期。若要取得新的字符,請返回 MCP 伺服器頁面並再次複製。 |
|
Machine-to-machine用戶端 ID 和用戶端秘密 — 從 Amazon Cognito 使用者集區擷取 |
Amazon Quick,以及為服務型身分驗證設定的任何其他用戶端 |
需要手動輪換。用戶端秘密是長期的,不會自行過期。 |
本節的其餘部分適用於machine-to-machine用戶端秘密。當您使用部署選用 MCP 伺服器設定為 進行部署 <stack-name>-userpool-client-m2m時,解決方案會將此登入資料建立為名為 的 Amazon Cognito 應用程式用戶端Yes。如需擷取指示,請參閱 Amazon Quick 中的先決條件。
重要
像對待任何其他長期憑證一樣對待用戶端秘密:
-
請勿將其遞交至來源控制、將其嵌入應用程式程式碼中,或將其貼入問題追蹤器、聊天或文件中。
-
請勿寫入日誌、建置輸出或 CI/CD 任務輸出。
-
將它存放在秘密管理員中,例如 AWS Secrets Manager
,或是取用它的 MCP 用戶端的加密登入資料存放區中。請勿將其保留在純文字檔案中。 -
僅將秘密的存取權授予需要秘密的人員,例如您和取用秘密的服務。
建議的輪換節奏
至少每 90 天輪換machine-to-machine用戶端秘密。每當發生下列任何情況時,立即在一般排程之外輪換:
-
您懷疑或確認秘密已公開。
-
有權存取秘密的運算子會離開團隊或變更角色。
-
您淘汰使用秘密設定的 MCP 用戶端。
輪換秘密
Amazon Cognito 應用程式用戶端同時支援最多兩個作用中的用戶端秘密。透過新增第二個秘密、將 MCP 用戶端遷移至其中,然後刪除原始 - 不會中斷 MCP 存取。
用戶端 ID 在輪換期間不會變更,因此您不需要更新解決方案的 AWS CloudFormation 堆疊、MCP 伺服器端點或字符端點。只有存放在 MCP 用戶端中的秘密值會變更。
-
新增第二個用戶端秘密。Amazon Cognito 會產生 值,並在回應中傳回該值。
aws cognito-idp add-user-pool-client-secret \ --user-pool-id <user-pool-id> \ --client-id <m2m-client-id> \ --region <region>重要
ClientSecretValue從回應複製 並安全地存放,然後再繼續。Amazon Cognito 只會在此回應中傳回產生的秘密值,而且永遠不會再次顯示它,Amazon Cognito 主控台list-user-pool-client-secrets也不會顯示它。如果您遺失 值,請刪除秘密並新增秘密。原始秘密此時仍然有效,因此仍使用它設定的任何 MCP 用戶端都會繼續運作。
-
更新每個 MCP 用戶端以使用新的秘密。對於 Amazon Quick,編輯 MCP Server 動作並取代 Client Secret 值,讓 MCP Server URL、字符端點和用戶端 ID 保持不變。儲存動作。
-
驗證新的秘密是否發出權杖。從使用者集區的字符端點請求用戶端憑證授予。
curl -X POST https://<user-pool-domain>/oauth2/token \ -H 'Content-Type: application/x-www-form-urlencoded' \ -d 'grant_type=client_credentials' \ -d 'client_id=<m2m-client-id>' \ -d 'client_secret=<new-client-secret>' \ -d 'scope=dlt-mcp-gateway/read'成功的回應包含
access_token欄位。然後,從您重新設定的用戶端叫用 MCP 工具來確認end-to-end存取,例如,要求客服人員列出您的測試案例。 -
列出用戶端的秘密以識別原始秘密。每個秘密都是由 格式
ClientSecretId的 識別<client-id>--<epoch-create-time>。使用ClientSecretCreateDate欄位來區分原始秘密與您剛新增的秘密。aws cognito-idp list-user-pool-client-secrets \ --user-pool-id <user-pool-id> \ --client-id <m2m-client-id> \ --region <region> -
使原始秘密失效。在此呼叫之後,Amazon Cognito 不會再向任何呈現舊秘密的用戶端發出字符。
aws cognito-idp delete-user-pool-client-secret \ --user-pool-id <user-pool-id> \ --client-id <m2m-client-id> \ --client-secret-id <old-client-secret-id> \ --region <region>
注意
當您輪換時,會套用兩個限制條件:
-
應用程式用戶端最多可以有兩個秘密。如果兩個已存在,請在新增另一個之前刪除您不再需要的。
-
您無法刪除應用程式用戶端上最後一個剩餘的秘密。
add-user-pool-client-secret 命令也接受選用--client-secret參數來提供您自己的值。如果您提供值,Amazon Cognito 不會在回應中傳回它,因此您必須在進行呼叫之前存放它。我們建議讓 Amazon Cognito 產生秘密。
如果秘密已公開
使用上述步驟輪換,並儘快完成步驟 5 (刪除舊秘密),而不是等待維護時段。然後採取下列其他動作。
-
已發行權杖的帳戶。刪除秘密會阻止 Amazon Cognito 發出新的權杖,但使用公開秘密取得的存取權杖會一直有效,直到過期為止,最多約 1 小時。刪除秘密不會使它們失效。
-
限制這些字符可以執行的操作。如果您的部署使用
ReadWrite存取模式,請在 MCP 伺服器存取模式設定為 的情況下執行 AWS CloudFormation 堆疊更新ReadOnly。這會移除寫入工具,並將 MCP Server Lambda 函數的 IAM 許可限制為GET請求,因此未完成的字符無法建立、修改、刪除或啟動測試案例。如需每個存取模式的行為,請參閱《 開發人員指南》中的 MCP 工具規格。 -
檢閱憑證的用途。檢查解決方案的測試執行歷史記錄和 MCP Server Lambda 函數的 Amazon CloudWatch Logs 是否有非預期的活動。如果部署使用
ReadWrite存取模式,也請檢閱您的測試案例和案例儲存貯體public/test-scenarios/字首的內容是否有未經授權的變更。
注意
若要立即拒絕所有 MCP 請求,無論字符有效性為何,請使用部署選用 MCP 伺服器設定為 來執行堆疊更新No。這會刪除 AgentCore Gateway。
只有當您必須保證沒有任何未完成的字符可以到達 MCP 伺服器時,才使用此項目。將 參數設定為 No也會刪除machine-to-machine應用程式用戶端。將其設回以Yes使用新的用戶端 ID 和新的秘密建立新的應用程式用戶端。然後,您必須使用新的用戶端 ID 和新的秘密來重新設定每個 MCP 用戶端。
範例提示
下列範例示範如何與 AI 助理互動,以透過 MCP 界面分析負載測試資料。自訂測試 IDs、日期範圍和條件,以符合您的特定測試需求。
如需可用 MCP 工具及其參數的詳細資訊,請參閱《 開發人員指南》中的 MCP 工具規格。
簡單測試結果查詢
與 MCP 伺服器的自然語言互動可以像 一樣簡單Show me the load tests that have completed in the last 24 hours with their associated completion status,也可以更描述性,例如
Use list_scenarios to find my load tests. Then use get_latest_test_run to show me the basic execution data and performance metrics for the most recent test. If the results look concerning, also get the detailed performance metrics using get_test_run.
具有漸進式揭露的互動式效能分析
I need to analyze my load test performance, but I'm not sure which specific tests to focus on. Please help me by: 1. First, use list_scenarios to show me available test scenarios 2. Ask me which tests I want to analyze based on the list you show me 3. For my selected tests, use list_test_runs to get the test run history 4. Then use get_test_run with the test_run_id to get detailed response times, throughput, and error rates 5. If I want to compare tests, use get_baseline_test_run to compare against the baseline 6. If there are any issues, use get_test_run_artifacts to help me understand what went wrong Please guide me through this step by step, asking for clarification whenever you need more specific information.
生產準備度驗證
Help me validate if my API is ready for production deployment: 1. Use list_scenarios to find recent test scenarios 2. For the most recent test scenario, use get_latest_test_run to get basic execution data 3. Use get_test_run with that test_run_id to get detailed response times, error rates, and throughput 4. Use get_scenario_details with the test_id to show me what load patterns and endpoints were tested 5. If I have a baseline, use get_baseline_test_run to compare current results with the baseline 6. Provide a clear go/no-go recommendation based on the performance data 7. If there are any concerns, use get_test_run_artifacts to help identify potential issues My SLA requirements are: response time under [X]ms, error rate under [Y]%.
效能趨勢分析
Analyze the performance trend for my load tests over the past [TIME_PERIOD]: 1. Use list_scenarios to get all test scenarios 2. For each scenario, use list_test_runs with start_date and end_date to get tests from that period 3. Use get_test_run for the key test runs to get detailed metrics 4. Use get_baseline_test_run to compare against the baseline 5. Identify any significant changes in response times, error rates, or throughput 6. If you detect performance degradation, use get_test_run_artifacts on the problematic tests to help identify causes 7. Present the trend analysis in a clear format showing whether performance is improving, stable, or degrading Focus on completed tests and limit results to [N] tests if there are too many.
故障診斷失敗的測試
Help me troubleshoot my failed load tests: 1. Use list_scenarios to find test scenarios 2. For each scenario, use list_test_runs to find recent test runs 3. Use get_test_run with the test_run_id to get the basic execution data and failure information 4. Use get_test_run_artifacts to get detailed error messages and logs 5. Use get_scenario_details to understand what was being tested when it failed 6. If I have a similar test that passed, use get_baseline_test_run to identify differences 7. Summarize the causes of failure and suggest next steps for resolution Show me the most recent [N] failed tests from the past [TIME_PERIOD].