prepare_headhaul_document_upload.py 2.6 KB

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