| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- class ListInboundReceiptTemplatesTool:
- name = 'list_inbound_receipt_templates'
- route_path = '/mcp/tools/listInboundReceiptTemplates'
- def __init__(self, api_client=None):
- self.api_client = api_client
- def metadata(self):
- return {
- 'name': self.name,
- 'description': (
- '按柜号返回这一次对应的入仓单模板。不要让用户声明直送或非直送,'
- '系统会根据柜号自己判断。用户选定模板名称后,把同一批柜号和返回的模板编码'
- '交给 export_inbound_receipt。没有柜号时先询问柜号,不得猜测。'
- '直送和非直送混在一起,或有柜号对不上时,整次失败,按返回说明拆开再查。'
- '参数名仅用于工具调用;向用户回答时只能使用中文业务名称。'
- ),
- 'input_schema': {
- 'type': 'object',
- 'properties': {
- 'container_codes': self.number_array(
- '柜号数组。只放用户明确说出的柜号。'
- ),
- },
- 'required': ['container_codes'],
- 'additionalProperties': False,
- },
- }
- @staticmethod
- def number_array(description):
- return {
- 'type': 'array',
- 'minItems': 1,
- 'maxItems': 200,
- 'description': description,
- 'items': {
- 'type': 'string',
- 'minLength': 1,
- 'maxLength': 100,
- 'pattern': '.*\\S.*',
- },
- }
- @staticmethod
- def clean_container_codes(container_codes):
- if not isinstance(container_codes, list) or not container_codes:
- raise ValueError('container_codes is required')
- if len(container_codes) > 200:
- raise ValueError('container_codes exceeds 200 items')
- cleaned = []
- for item in container_codes:
- if not isinstance(item, str):
- raise ValueError('container code must be a string')
- text = item.strip()
- if not text or len(text) > 100:
- raise ValueError('container code length is invalid')
- if text not in cleaned:
- cleaned.append(text)
- if not cleaned or len(cleaned) > 200:
- raise ValueError('container_codes is required')
- return cleaned
- def call(self, container_codes=None, request_id='rq_list_inbound_receipt_templates'):
- if self.api_client is None:
- raise RuntimeError(
- 'api client is required for list_inbound_receipt_templates'
- )
- payload = {
- 'container_codes': self.clean_container_codes(container_codes),
- }
- return self.api_client.call_tool(
- self.name, self.route_path, payload, request_id,
- )
|