结账 MCP 绑定
概述
本文档指定结账能力的模型上下文协议 (MCP) 绑定。
协议基础
发现
商家通过其 UCP profile 宣布 MCP 传输可用性:
{
"ucp": {
"services": {
"dev.ucp.shopping": {
"mcp": {
"schema": "https://ucp.dev/services/shopping/mcp.openrpc.json",
"endpoint": "https://business.example.com/ucp/mcp"
}
}
}
}
}平台 Profile 宣告
MCP 客户端必须在每个请求的 _meta.ucp 结构中包含 UCP 平台 profile URI:
{
"jsonrpc": "2.0",
"id": 1,
"method": "create_checkout",
"params": {
"_meta": {
"ucp": {
"profile": "https://platform.example/profiles/v2026-01/shopping-agent.json"
}
}
}
}工具
UCP 能力与 MCP 工具一对一映射。
| 工具 | 操作 | 描述 |
|---|---|---|
create_checkout | 创建结账 | 创建结账会话 |
get_checkout | 获取结账 | 获取结账会话 |
update_checkout | 更新结账 | 更新结账会话 |
complete_checkout | 完成结账 | 下单 |
cancel_checkout | 取消结账 | 取消结账会话 |
示例:创建结账
请求:
{
"jsonrpc": "2.0",
"method": "create_checkout",
"params": {
"_meta": {
"ucp": {
"profile": "https://platform.example/profiles/v2026-01/shopping-agent.json"
}
},
"buyer": {
"email": "[email protected]"
},
"line_items": [
{
"item": {"id": "item_123"},
"quantity": 1
}
],
"currency": "USD"
},
"id": 1
}响应:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"ucp": {
"version": "2026-01-11",
"capabilities": [...]
},
"id": "checkout_abc123",
"status": "incomplete",
"line_items": [...],
"totals": [...],
"payment": {...}
}
}错误处理
错误响应遵循 JSON-RPC 2.0 格式,在 data 字段中包含 UCP 错误结构:
{
"jsonrpc": "2.0",
"id": 1,
"error": {
"code": -32603,
"message": "Internal error",
"data": {
"status": "error",
"errors": [
{
"code": "MERCHANDISE_NOT_AVAILABLE",
"message": "一个或多个购物车商品不可用",
"severity": "requires_buyer_input"
}
]
}
}
}一致性
符合标准的 MCP 传输实现必须:
- 正确实现 JSON-RPC 2.0 协议
- 提供所有核心结账工具
- 使用 UCP 特定错误代码处理错误
- 根据 UCP schema 验证工具输入
- 支持带流式传输的 HTTP 传输
另请参阅
- 结账能力 - 核心结账规范
- 结账 REST 绑定 - REST API 绑定
- 结账 A2A 绑定 - 智能体对智能体绑定