对 AWS 合作伙伴中心 API 参考进行了重组。有关支持的 API 操作的更多信息,请参阅 AWS 合作伙伴中心 API 参考。
本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
工具参考
合作伙伴中心代理 MCP 服务器提供了两个 MCP 工具:sendMessage用于所有代理交互和检索会话getSession状态。Partner Central 的所有操作(机会查询、资金申请、文件分析)均通过自然语言来处理sendMessage。
工具概述
| 工具 | 说明 | 类别 |
|---|---|---|
sendMessage |
向 Partner Central AI 代理发送消息。支持文本、文件附件和人工审批响应。 | 读取/写入 |
getSession |
检索会话状态,包括对话历史记录、事件和元数据。 | Read-only |
发送消息
所有 Partner Central AI 代理互动的主要工具。使用此工具提出问题、请求操作、附加文档进行分析,以及回复写入操作的批准请求。
代理在会话中维护对话上下文,因此您可以提出后续问题,而无需重复之前的上下文。
参数
content(必填)-内容块数组。每个区块必须包含一个用于确定区块结构的type字段。你可以在一条消息(例如,文本 + 文档附件)中包含多个区块。内容块类型:
Type 字段 说明 texttype(必填),text(必填)发送给代理的用户消息文本 documenttype(必填)、filename(必填)、s3Uri(必填)供代理分析的文件附件。 s3Uri必须包含一个versionId参数。tool_approval_responsetype(必填)、toolUseId(必填)、decision(必填)、message(可选)对人工在圈审批请求的回应 catalog(必填)-操作的目标环境。有效值:
"AWS"(生产)、"Sandbox"(测试)sessionId(可选)— UUID v4 标识要继续的现有会话。省略创建新会话。格式:session-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx。默认:自动创建新会话。
stream(可选)-启用 Server-Sent 事件 (SSE) 流式传输以实现实时响应交付。有效值:
true、false默认值:
false
响应
响应包括以下内容:
| 字段 | 说明 |
|---|---|
sessionId |
后续消息的会话标识符 |
status |
响应状态:"complete""requires_approval"、或 "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" } }
Follow-up 消息(现有会话)
请求:
{ "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
允许的扩展名:
docdocx、pdf、png、、jpeg、xlsx、csv、txt文件必须上传到
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" } } }
批准决策值:
| 决策 | 行为 |
|---|---|
"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: {}
获取会话
检索对话会话的当前状态,包括完整的对话历史记录、事件和元数据。使用它来检查会话状态、查看过去的互动或恢复对话。
参数
sessionId(必填)— 要检索的会话的 UUID。格式:session-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx。catalog(必填)-会话所属的环境。有效值:
"AWS"、"Sandbox"
响应
| 字段 | Type | 说明 |
|---|---|---|
sessionId |
字符串 | 会话标识符 |
createdAt |
字符串 | ISO 8601 会话创建的时间戳 |
lastActivity |
字符串 | 上次活动的 ISO 8601 时间戳 |
sequenceNumber |
integer | 当前事件序列号 |
stateType |
字符串 | 当前会话状态 |
events |
array | 完整的对话历史记录(用户消息、代理回复、工具使用情况) |
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_EXCEDED):重试,从 1 秒开始采用指数回退对于
-32603(INTERNAL_ERROR):使用指数回退,最多重试 3 次对于
-32001(AUTHENTICATION_FAILURE):刷新凭据并重试对于所有其他错误:请勿自动重试 — 检查错误消息并更正请求