From 9b7b69d8c33de0a919e85491e3d2a51e87119239 Mon Sep 17 00:00:00 2001 From: Sucan126 <632190820@qq.com> Date: Sun, 28 Sep 2025 12:07:09 +0800 Subject: [PATCH] Update version to 0.1.17, enhance NavServer with patrol functionality, and modify MQTT broker default value. Added patrol command handling and updated documentation for new parameters. --- terminal_temi_mcp/pyproject.toml | 2 +- terminal_temi_mcp/terminal_temi_mcp/main.py | 52 +++++++++++++++++-- .../terminal_temi_mcp/mcp_mqtt.py | 2 +- 3 files changed, 49 insertions(+), 7 deletions(-) diff --git a/terminal_temi_mcp/pyproject.toml b/terminal_temi_mcp/pyproject.toml index 6eb468b..7095216 100644 --- a/terminal_temi_mcp/pyproject.toml +++ b/terminal_temi_mcp/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "terminal_temi_mcp" -version = "0.1.15" +version = "0.1.17" description = "MQTT-based navigation server for robot" requires-python = ">=3.10" dependencies = [ diff --git a/terminal_temi_mcp/terminal_temi_mcp/main.py b/terminal_temi_mcp/terminal_temi_mcp/main.py index 51e0753..b119b8e 100644 --- a/terminal_temi_mcp/terminal_temi_mcp/main.py +++ b/terminal_temi_mcp/terminal_temi_mcp/main.py @@ -90,8 +90,7 @@ class NavServer: """ 机器人接待客人。 Args: - - location (str): 机器人去这个位置接待客人 - - task_id (Optional[str]): 任务id,不传则自动生成 + - location (str): 机器人接待客人到这个位置 Returns: str: 命令执行结果消息 @@ -116,8 +115,7 @@ class NavServer: 机器人通知事情。 Args: - location (str): 机器人去这个位置通知事情 - - text (str): 通知事情的内容 - - task_id (Optional[str]): 任务id,不传则自动生成 + - text (str): 通知的内容 Returns: str: 命令执行结果消息 @@ -158,7 +156,6 @@ class NavServer: Args: - first_location (str): 机器人去这个位置取物品 - next_location (str): 机器人将物品送到这个位置 - - task_id (Optional[str]): 任务id,不传则自动生成 Returns: str: 命令执行结果消息 @@ -180,6 +177,28 @@ class NavServer: logger.error(f"Failed to call delivery mcp-tool: {str(e)} ", exc_info=True) raise + async def patrol(self, locations: list[str]): + """ + 机器人去巡逻。 + Args: + - locations (list[str]): 机器人巡逻经过的地点列表 + Returns: + str: 命令执行结果消息 + + Raises: + ValueError: 如果参数无效或为空 + Exception: 如果MQTT发布失败 + """ + if locations: + try: + params = { + "data": {"locations": locations} + } + return await self.publish_Cmd("123456", "patrol", params) + except Exception as e: + logger.error(f"Failed to call patrol mcp-tool: {str(e)} ", exc_info=True) + raise + async def startFaceRecognize(self, device_id: str): """ 机器人进行人脸识别。 @@ -374,6 +393,23 @@ async def serve() -> None: "required": ["first_location","next_location"] } ), + Tool( + name="patrol", + description="数字员工、终端、具身机器人、前台机器人、助手、机器人去巡逻:巡逻、巡查、去检查一下、去看看、去巡视", + inputSchema={ + "type": "object", + "properties": { + "locations": { + "type": "array", + "description": "机器人巡逻经过的地点列表", + "items": { + "type": "string" + } + } + }, + "required": ["locations"] + } + ), # Tool( # name="guide", # description="数字员工、终端、具身机器人、前台机器人、助手、机器人进行导览服务:导览、介绍、参观、带领参观、导游、讲解、展示、演示、介绍场所、带我看看", @@ -459,6 +495,12 @@ async def serve() -> None: first_location=arguments["first_location"], next_location=arguments["next_location"] ) + elif name == "patrol": + if "locations" not in arguments: + raise ValueError("缺少必要参数: locations") + result = await nav_server.patrol( + locations=arguments["locations"] + ) # elif name == "face": # if "device_id" not in arguments: # raise ValueError("缺少必要参数: device_id") diff --git a/terminal_temi_mcp/terminal_temi_mcp/mcp_mqtt.py b/terminal_temi_mcp/terminal_temi_mcp/mcp_mqtt.py index de99940..8febfee 100644 --- a/terminal_temi_mcp/terminal_temi_mcp/mcp_mqtt.py +++ b/terminal_temi_mcp/terminal_temi_mcp/mcp_mqtt.py @@ -32,7 +32,7 @@ class MQTTHandler: # 获取MQTT配置,提供默认值 self.mqtt_username = getenv('MQTT_USERNAME') or 'lzwc' self.mqtt_password = getenv('MQTT_PASSWORD') or 'Lzwc@4187.' - mqtt_broker_raw = getenv('MQTT_BROKER') or 'tcp://dempmana.lzwcai.com' + mqtt_broker_raw = getenv('MQTT_BROKER') or 'emqx' # 移除协议前缀,只保留主机名 self.mqtt_broker = mqtt_broker_raw.replace('tcp://', '').replace('mqtt://', '') mqtt_port_str = getenv('MQTT_PORT')