from tools.list_inbound_receipt_templates import ListInboundReceiptTemplatesTool class ExportInboundReceiptTool: name = 'export_inbound_receipt' route_path = '/mcp/tools/exportInboundReceipt' def __init__(self, api_client=None): self.api_client = api_client def metadata(self): return { 'name': self.name, 'description': ( '本工具只提交异步导出任务,不会在本次调用中等待文件生成,也禁止在一次调用内' '轮询任务状态。成功后返回任务引用(task_ref)和建议等待时间' '(retry_after_seconds)。稍后单独使用 query_export_task 查询任务状态或下载链接。' '使用场景:用户已经从 list_inbound_receipt_templates 的结果里选定一张入仓单模板,' '并明确要求导出文件。必须传同一批柜号和用户选中的模板编码。' '不得改用直送或非直送以外的模板,不得在没有查到模板时自行挑选编码。' '参数名仅用于工具调用;向用户回答时只能使用中文业务名称。' ), 'input_schema': { 'type': 'object', 'properties': { 'container_codes': ListInboundReceiptTemplatesTool.number_array( '与查模板时相同的柜号数组。' ), 'template_code': { 'type': 'string', 'minLength': 1, 'maxLength': 100, 'description': '用户从查模板结果里选定的模板编码。', }, }, 'required': ['container_codes', 'template_code'], 'additionalProperties': False, }, } def call( self, container_codes=None, template_code=None, request_id='rq_export_inbound_receipt', ): if self.api_client is None: raise RuntimeError('api client is required for export_inbound_receipt') code = template_code.strip() if isinstance(template_code, str) else '' if not code or len(code) > 100: raise ValueError('template_code is required') payload = { 'container_codes': ListInboundReceiptTemplatesTool.clean_container_codes( container_codes ), 'template_code': code, } return self.api_client.call_tool( self.name, self.route_path, payload, request_id, )