prepare_headhaul_document_upload.py 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. class PrepareHeadhaulDocumentUploadTool:
  2. name = 'prepare_headhaul_document_upload'
  3. route_path = '/mcp/tools/prepareHeadhaulDocumentUpload'
  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. '签发后由宿主把窗口里的文件 POST 到返回的上传地址,并带上upload_token。'
  13. '禁止使用:选文件框、把文件内容放进工具参数、打开独立上传页、'
  14. '改走报关资料或订单附件、让用户去 home 后台上传。'
  15. '参数只用于工具内部调用;最终回答只能展示中文业务名称。'
  16. ),
  17. 'input_schema': {
  18. 'type': 'object',
  19. 'properties': {
  20. 'document_type_id': {
  21. 'type': 'integer',
  22. 'minimum': 1,
  23. 'description': (
  24. '要添加的文档类型。必须先调用'
  25. 'list_headhaul_document_filter_options并选择“添加文档类型”。'
  26. ),
  27. },
  28. },
  29. 'required': ['document_type_id'],
  30. 'additionalProperties': False,
  31. },
  32. }
  33. def call(
  34. self,
  35. document_type_id,
  36. request_id='rq_prepare_headhaul_document_upload',
  37. ):
  38. if self.api_client is None:
  39. raise RuntimeError(
  40. 'api client is required for prepare_headhaul_document_upload'
  41. )
  42. if (
  43. isinstance(document_type_id, bool)
  44. or not isinstance(document_type_id, int)
  45. or document_type_id < 1
  46. ):
  47. raise ValueError('document_type_id is invalid')
  48. return self.api_client.call_tool(
  49. self.name,
  50. self.route_path,
  51. {'document_type_id': document_type_id},
  52. request_id,
  53. )