| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- class OpenGoodsAuditTool:
- name = 'open_goods_audit'
- route_path = '/mcp/tools/openGoodsAudit'
- def __init__(self, api_client=None):
- self.api_client = api_client
- def metadata(self):
- return {
- 'name': self.name,
- 'description': (
- '使用场景:用户要打开一条商品的审核单时调用。'
- '商品编号就是审核页上的 SKU,不是内部商品 ID。'
- '同一个商品编号有多条时,先补充起运国和目的国,可以写国家名或国家代码。'
- '返回审核单、可选项和只看不提交的参考。'
- '禁止使用:在本工具里提交审核结果,不得改走后台商品审核页。'
- '参数只用于工具内部调用;最终回答只能展示中文业务名称。'
- ),
- 'input_schema': {
- 'type': 'object',
- 'properties': {
- 'sku': {
- 'type': 'string',
- 'minLength': 1,
- 'maxLength': 200,
- 'description': '商品编号,即审核页上的 SKU。',
- },
- 'departure_country': {
- 'type': 'string',
- 'maxLength': 100,
- 'description': '起运国,国家名或国家代码。同一个商品编号有多条时填写。',
- },
- 'destination_country': {
- 'type': 'string',
- 'maxLength': 100,
- 'description': '目的国,国家名或国家代码。同一个商品编号有多条时填写。',
- },
- },
- 'required': ['sku'],
- 'additionalProperties': False,
- },
- }
- def call(
- self,
- sku='',
- departure_country='',
- destination_country='',
- request_id='rq_open_goods_audit',
- **_ignored,
- ):
- if self.api_client is None:
- raise RuntimeError('api client is required for open_goods_audit')
- payload = {'sku': self._text(sku)}
- if departure_country:
- payload['departure_country'] = self._text(departure_country)
- if destination_country:
- payload['destination_country'] = self._text(destination_country)
- return self.api_client.call_tool(
- self.name, self.route_path, payload, request_id,
- )
- @staticmethod
- def _text(value):
- if not isinstance(value, str):
- raise ValueError('sku is invalid')
- text = value.strip()
- if not text or len(text) > 200:
- raise ValueError('sku is invalid')
- return text
|