open_goods_audit.py 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. class OpenGoodsAuditTool:
  2. name = 'open_goods_audit'
  3. route_path = '/mcp/tools/openGoodsAudit'
  4. def __init__(self, api_client=None):
  5. self.api_client = api_client
  6. def metadata(self):
  7. return {
  8. 'name': self.name,
  9. 'description': (
  10. '使用场景:用户要打开一条商品的审核单时调用。'
  11. '必须使用待审核列表第一列的商品编号,或用户给出的商品编号。'
  12. '返回审核单、可选项和只看不提交的参考。'
  13. '禁止使用:在本工具里提交审核结果,不得改走后台商品审核页。'
  14. '参数只用于工具内部调用;最终回答只能展示中文业务名称。'
  15. ),
  16. 'input_schema': {
  17. 'type': 'object',
  18. 'properties': {
  19. 'goods_id': {
  20. 'type': 'integer',
  21. 'minimum': 1,
  22. 'description': '商品编号,来自待审核列表或用户给出的审核页编号。',
  23. },
  24. },
  25. 'required': ['goods_id'],
  26. 'additionalProperties': False,
  27. },
  28. }
  29. def call(self, goods_id, request_id='rq_open_goods_audit'):
  30. if self.api_client is None:
  31. raise RuntimeError('api client is required for open_goods_audit')
  32. if not isinstance(goods_id, int) or isinstance(goods_id, bool) or goods_id < 1:
  33. raise ValueError('goods_id is invalid')
  34. return self.api_client.call_tool(
  35. self.name, self.route_path, {'goods_id': goods_id}, request_id,
  36. )