| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- class MaintainRemoteAddressTool:
- name = 'maintain_remote_address'
- route_path = '/mcp/tools/maintainRemoteAddress'
- backend = 'base'
- def __init__(self, api_client=None):
- self.api_client = api_client
- def metadata(self):
- return {
- 'name': self.name,
- 'description': (
- '使用场景:查看某个已有偏远地址库的名称、状态和地址明细。'
- '编号格式为PY加数字,例如PY12,必须来自query_remote_address_list的结果。'
- '新增地址库,或修改名称和状态,请使用save_remote_address。'
- '禁止使用:手填不存在的编号、导入文件、删除明细、保存名称。'
- '临时键是内部字段,不要向用户展示。'
- '参数只用于工具内部调用;最终回答只能展示中文业务名称和偏远地址库编号。'
- ),
- 'input_schema': {
- 'type': 'object',
- 'properties': {
- 'address_no': {
- 'type': 'string',
- 'minLength': 1,
- 'maxLength': 20,
- 'description': '要维护的偏远地址库编号。不传表示准备新增。',
- },
- 'page': {
- 'type': 'integer', 'minimum': 1, 'maximum': 100, 'default': 1,
- },
- 'limit': {
- 'type': 'integer', 'minimum': 1, 'maximum': 100, 'default': 20,
- },
- },
- 'additionalProperties': False,
- },
- }
- def call(
- self,
- address_no=None,
- page=1,
- limit=20,
- request_id='rq_maintain_remote_address',
- ):
- if self.api_client is None:
- raise RuntimeError(
- 'api client is required for maintain_remote_address'
- )
- payload = {
- 'page': QueryPage.page(page),
- 'limit': QueryPage.limit(limit),
- }
- if address_no is not None:
- if not isinstance(address_no, str):
- raise ValueError('address_no is invalid')
- address_no = address_no.strip()
- if address_no:
- payload['address_no'] = address_no
- return self.api_client.call_tool(
- self.name, self.route_path, payload, request_id,
- )
- class QueryPage:
- @staticmethod
- def page(value):
- if isinstance(value, bool) or not isinstance(value, int) or value < 1 or value > 100:
- raise ValueError('page is invalid')
- return value
- @staticmethod
- def limit(value):
- if isinstance(value, bool) or not isinstance(value, int) or value < 1 or value > 100:
- raise ValueError('limit is invalid')
- return value
|