本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
MCP 伺服器整合
如果您在解決方案部署期間部署了選用的 MCP 伺服器元件,您可以將分散式負載測試解決方案與支援模型內容通訊協定的 AI 開發工具整合。MCP 伺服器提供透過 AI 助理擷取、管理和分析負載測試的程式設計存取權。
客戶可以使用自己選擇的用戶端 (Amazon Q、Claude 等) 連線到 DLT MCP 伺服器,每個用戶端的組態指示略有不同。本節提供 MCP Inspector、Amazon Q CLI、Cline 和 Amazon Q Suite 的設定指示。
步驟 1:取得 MCP 端點和存取權杖
設定任何 MCP 用戶端之前,您需要從 DLT Web 主控台擷取 MCP 伺服器端點和存取權杖。
-
導覽至分散式負載測試 Web 主控台中的 MCP 伺服器頁面。
-
找到 MCP 伺服器端點區段。
-
使用複製端點 URL 按鈕複製端點 URL。端點 URL 遵循以下格式:
https://[api-id].execute-api.[region].amazonaws.com/[stage]/gateway/backend-agent/sse/mcp -
找到存取字符區段。
-
使用複製存取權杖按鈕複製存取權杖。
重要
保護您的存取權杖,不要公開共用。字符透過 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 伺服器連線後,您可以設定偏好的 AI 開發用戶端。
Amazon Q CLI
Amazon Q CLI 透過 MCP 伺服器整合,提供 AI 輔助開發的命令列存取。
組態步驟
-
編輯
mcp.json組態檔案。如需組態檔案位置的詳細資訊,請參閱《Amazon Q 開發人員使用者指南》中的設定遠端 MCP 伺服器。 -
新增您的 DLT MCP 伺服器組態:
{ "mcpServers": { "dlt-mcp": { "type": "http", "url": "https://[api-id].execute-api.[region].amazonaws.com/[stage]/gateway/backend-agent/sse/mcp", "headers": { "Authorization": "your_access_token_here" } } } }
驗證組態
-
在終端機中,輸入
q以啟動 Amazon Q CLI。 -
輸入
/mcp查看所有可用的 MCP 伺服器。 -
輸入
/tools查看dlt-mcp和其他設定的 MCP 伺服器提供的可用工具。 -
確認
dlt-mcp已成功初始化。
曲線
Cline 是支援 MCP 伺服器整合的 AI 編碼助理。
組態步驟
-
在 Cline 中,導覽至管理 MCP 伺服器 > 設定 > 設定 MCP 伺服器。
-
更新
cline_mcp_settings.json檔案:{ "mcpServers": { "dlt-mcp": { "type": "streamableHttp", "url": "https://[api-id].execute-api.[region].amazonaws.com/[stage]/gateway/backend-agent/sse/mcp", "headers": { "Authorization": "your_access_token_here" } } } } -
儲存組態檔案。
-
重新啟動 Cline 以套用變更。
Amazon Q Suite
Amazon Q Suite 提供全方位的 AI 助理平台,並支援 MCP 伺服器動作。
先決條件
在 Amazon Q Suite 中設定 MCP 伺服器之前,您需要從 DLT 部署的 Cognito 使用者集區擷取 OAuth 憑證:
-
選取分散式負載測試堆疊。
-
在輸出索引標籤中,尋找並複製與您的 DLT 部署相關聯的 Cognito 使用者集區 ID。
-
導覽至 Amazon Cognito 主控台
。 -
使用 CloudFormation 輸出中的使用者集區 ID 選取使用者集區。
-
在左側導覽中,選取應用程式整合 > 應用程式用戶端。
-
找到名稱結尾為
m2m(machine-to-machine) 的應用程式用戶端。 -
複製用戶端 ID 和用戶端秘密。
-
從網域索引標籤取得使用者集區網域。
-
透過附加
/oauth2/token到網域的結尾來建構字符端點 URL。
組態步驟
-
在 Amazon Q Suite 中,建立新的客服人員或選取現有的客服人員。
-
新增客服人員提示,說明如何與 DLT MCP 伺服器互動。
-
新增動作,然後選取 MCP 伺服器動作。
-
設定 MCP 伺服器詳細資訊:
-
MCP 伺服器 URL:您的 DLT MCP 端點
-
身分驗證類型:服務型身分驗證
-
權杖端點:您的 Cognito 權杖端點 URL
-
用戶端 ID:來自 m2m 應用程式用戶端的用戶端 ID
-
用戶端秘密:來自 m2m 應用程式用戶端的用戶端秘密
-
-
儲存 MCP 伺服器動作組態。
-
將新的 MCP 伺服器動作新增至您的代理程式。
啟動和測試代理程式
-
在 Amazon Q Suite 中啟動代理程式。
-
使用自然語言提示與客服人員開始對話。
-
代理程式將使用 MCP 工具來擷取和分析負載測試資料。
範例提示
下列範例示範如何與 AI 助理互動,以透過 MCP 界面分析負載測試資料。自訂測試 IDs、日期範圍和條件,以符合您的特定測試需求。
如需可用 MCP 工具及其參數的詳細資訊,請參閱《 開發人員指南》中的 MCP 工具規格。
簡單測試結果查詢
與 MCP Server 的正式語言互動可以像 一樣簡單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].