结账 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 传输实现必须

  1. 正确实现 JSON-RPC 2.0 协议
  2. 提供所有核心结账工具
  3. 使用 UCP 特定错误代码处理错误
  4. 根据 UCP schema 验证工具输入
  5. 支持带流式传输的 HTTP 传输

另请参阅