View a markdown version of this page

工具參考 - AWS Partner Central

AWS Partner Central API 參考已重組。如需支援的 API 操作的詳細資訊,請參閱 AWS Partner Central API 參考

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

工具參考

Partner Central Agent MCP Server 會公開兩種 MCP 工具:sendMessage用於所有客服人員互動,以及getSession用於擷取工作階段狀態。所有 Partner Central 操作 - 機會查詢、資金應用程式、文件分析 - 透過 以自然語言處理sendMessage

工具概觀

工具 說明 Category
sendMessage 傳送訊息給 Partner Central AI 代理器。支援文字、檔案附件和human-in-the-loop核准回應。 讀取/寫入
getSession 擷取工作階段狀態,包括對話歷史記錄、事件和中繼資料。 唯讀

sendMessage

所有 Partner Central AI 代理器互動的主要工具。使用此工具來提出問題、請求動作、附加文件進行分析,以及回應寫入操作的核准請求。

客服人員會在工作階段中維護對話內容,因此您可以提出後續問題,而無需重複先前的內容。

Parameters

  • content (必要) — 內容區塊陣列。每個區塊必須包含決定區塊結構type的欄位。您可以在單一訊息中包含多個區塊 (例如文字 + 文件附件)。

    內容區塊類型:

    Type 欄位 說明
    text type (必要)、 text(必要) 傳送給客服人員的使用者訊息文字
    document type (必要)、 filename (必要)、 s3Uri(必要) 代理程式要分析的檔案附件。s3Uri 必須包含 versionId 參數。
    tool_approval_response type (必要)、 toolUseId (必要)、 decision (必要)、 message(選用) 回應human-in-the-loop核准請求
  • catalog (必要) — 操作的目標環境。

    有效值: "AWS" (生產)、 "Sandbox"(測試)

  • sessionId (選用) — UUID v4 識別現有工作階段以繼續。省略 以建立新的工作階段。格式:session-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

    預設:系統會自動建立新的工作階段。

  • stream (選用) — 啟用伺服器傳送事件 (SSE) 串流以進行即時回應交付。

    有效值:truefalse

    預設:false

回應

回應包括:

欄位 說明
sessionId 後續訊息的工作階段識別符
status 回應狀態:"requires_approval""complete""error"
content 來自代理程式的回應內容區塊陣列

範例

基本文字訊息 (新工作階段)

要求:

{ "jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": { "name": "sendMessage", "arguments": { "content": [ { "type": "text", "text": "List my open opportunities with expected close date in Q1 2026" } ], "catalog": "AWS" } } }

回應:

{ "jsonrpc": "2.0", "id": 1, "result": { "content": [ { "type": "text", "text": "I found 12 open opportunities with expected close dates in Q1 2026. Here's a summary:\n\n1. **O1234567890** - Acme Corp Cloud Migration - $250,000 - Qualified stage\n2. **O1234567891** - GlobalTech Data Analytics - $180,000 - Prospect stage\n..." } ], "sessionId": "session-550e8400-e29b-41d4-a716-446655440000", "status": "complete" } }

後續訊息 (現有工作階段)

要求:

{ "jsonrpc": "2.0", "id": 2, "method": "tools/call", "params": { "name": "sendMessage", "arguments": { "sessionId": "session-550e8400-e29b-41d4-a716-446655440000", "content": [ { "type": "text", "text": "Tell me more about O1234567890. Is it ready for submission?" } ], "catalog": "AWS" } } }

檔案連接

先將文件上傳至 S3,然後在訊息中參考文件:

{ "jsonrpc": "2.0", "id": 3, "method": "tools/call", "params": { "name": "sendMessage", "arguments": { "sessionId": "session-550e8400-e29b-41d4-a716-446655440000", "content": [ { "type": "text", "text": "Review this customer proposal and suggest which opportunity it aligns with" }, { "type": "document", "filename": "acme-proposal.pdf", "s3Uri": "s3://aws-partner-central-marketplace-ephemeral-writeonly-files/123456789012/acme-proposal.pdf?versionId=abc123def456" } ], "catalog": "AWS" } } }

檔案上傳限制:

  • 每則訊息最多 3 個檔案

  • 影像大小限制:3.75 MB

  • 文件大小限制:4.5 MB

  • 允許擴充功能:docdocxpdfpngjpegxlsxcsvtxt

  • 檔案必須上傳至 s3://{bucket}/{your-aws-account-id}/

  • S3 URI 必須包含versionId查詢參數

Human-in-the-loop工作流程

當客服人員需要執行寫入操作 (例如,更新機會、提交資金應用程式) 時,它會傳回包含建議動作詳細資訊"requires_approval"的狀態。您必須使用tool_approval_response內容區塊來回應。

步驟 1 — 客服人員請求核准:

{ "jsonrpc": "2.0", "id": 4, "result": { "content": [ { "type": "text", "text": "I'd like to update opportunity O1234567890 with the following changes:\n- Target close date: 2026-03-31\n- Expected revenue: $300,000\n- Stage: Qualified\n\nPlease approve, reject, or override this action." }, { "type": "tool_approval_request", "toolUseId": "tool-use-98765", "toolName": "update_opportunity_enhanced", "parameters": { "opportunityId": "O1234567890", "targetCloseDate": "2026-03-31", "expectedRevenue": 300000, "stage": "Qualified" } } ], "sessionId": "session-550e8400-e29b-41d4-a716-446655440000", "status": "requires_approval" } }

步驟 2 — 核准動作:

{ "jsonrpc": "2.0", "id": 5, "method": "tools/call", "params": { "name": "sendMessage", "arguments": { "sessionId": "session-550e8400-e29b-41d4-a716-446655440000", "content": [ { "type": "tool_approval_response", "toolUseId": "tool-use-98765", "decision": "approve" } ], "catalog": "AWS" } } }

步驟 2 (替代) — 拒絕動作:

{ "jsonrpc": "2.0", "id": 5, "method": "tools/call", "params": { "name": "sendMessage", "arguments": { "sessionId": "session-550e8400-e29b-41d4-a716-446655440000", "content": [ { "type": "tool_approval_response", "toolUseId": "tool-use-98765", "decision": "reject", "message": "The expected revenue should be $250,000, not $300,000" } ], "catalog": "AWS" } } }

步驟 2 (替代) — 以自訂回應覆寫:

{ "jsonrpc": "2.0", "id": 5, "method": "tools/call", "params": { "name": "sendMessage", "arguments": { "sessionId": "session-550e8400-e29b-41d4-a716-446655440000", "content": [ { "type": "tool_approval_response", "toolUseId": "tool-use-98765", "decision": "override", "message": "Use expected revenue of $250,000 and keep the stage as Prospect instead" } ], "catalog": "AWS" } } }

核准決策值:

決策 Behavior (行為)
"approve" 使用建議的參數執行工具
"reject" 請勿執行工具。選用message說明原因。
"override" 透過 提供自訂回應或修改的指示 message

使用 SSE 串流

在代理程式處理您的請求時,啟用串流以接收增量回應區塊:

要求:

{ "jsonrpc": "2.0", "id": 6, "method": "tools/call", "params": { "name": "sendMessage", "arguments": { "sessionId": "session-550e8400-e29b-41d4-a716-446655440000", "content": [ { "type": "text", "text": "Analyze my pipeline and identify opportunities at risk" } ], "catalog": "AWS", "stream": true } } }

伺服器會以 SSE 事件串流回應:

event: stream_start data: {"sessionId": "session-550e8400-e29b-41d4-a716-446655440000"} event: assistant-response.start data: {} event: server-tool-use data: {"toolName": "analyze_pipeline", "parameters": {}} event: server-tool-response data: {"toolName": "analyze_pipeline", "result": {"opportunitiesAnalyzed": 47, "atRisk": 5}} event: assistant-response.delta data: {"text": "I analyzed your pipeline of 47 opportunities and identified "} event: assistant-response.delta data: {"text": "5 that are at risk of slipping:\n\n"} event: assistant-response.delta data: {"text": "1. **O2345678901** - Close date is past due by 15 days\n"} event: assistant-response.completed data: {"status": "complete"} event: stream_end data: {}

getSession

擷取對話工作階段的目前狀態,包括完整的對話歷史記錄、事件和中繼資料。使用此項目可檢查工作階段狀態、檢閱過去的互動,或繼續對話。

Parameters

  • sessionId (必要) — 要擷取之工作階段的 UUID。格式:session-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

  • catalog (必要) — 工作階段所屬的環境。

    有效值:"AWS""Sandbox"

回應

欄位 Type Description
sessionId string 工作階段識別符
createdAt string 工作階段建立的 ISO 8601 時間戳記
lastActivity string 上次活動的 ISO 8601 時間戳記
sequenceNumber integer 目前事件序號
stateType string 目前工作階段狀態
events 陣列 完整的對話歷史記錄 (使用者訊息、客服人員回應、工具使用)
variables object 工作階段變數和中繼資料
eventCount integer 工作階段中的事件總數

範例

要求:

{ "jsonrpc": "2.0", "id": 7, "method": "tools/call", "params": { "name": "getSession", "arguments": { "sessionId": "session-550e8400-e29b-41d4-a716-446655440000", "catalog": "AWS" } } }

回應:

{ "jsonrpc": "2.0", "id": 7, "result": { "content": [ { "type": "text", "text": "{\"sessionId\":\"session-550e8400-e29b-41d4-a716-446655440000\",\"createdAt\":\"2026-01-15T10:30:00Z\",\"lastActivity\":\"2026-01-15T11:45:00Z\",\"sequenceNumber\":8,\"stateType\":\"END_TURN\",\"eventCount\":8,\"events\":[...],\"variables\":{}}" } ] } }

錯誤處理

所有錯誤都遵循 JSON-RPC 2.0 錯誤格式:

{ "jsonrpc": "2.0", "id": 1, "error": { "code": -32001, "message": "Authentication failed. Verify your SigV4 credentials and ensure they have not expired." } }

錯誤代碼 如需錯誤代碼的完整清單及其意義,請參閱 。

建議的重試策略

  • 對於 -32004(LIMIT_EXCEEDED):從 1 秒開始以指數退避重試

  • 對於 -32603(INTERNAL_ERROR):以指數退避重試最多 3 次

  • 對於 -32001(AUTHENTICATION_FAILURE):重新整理憑證並重試

  • 對於所有其他錯誤:請勿自動重試 — 檢查錯誤訊息並更正請求