feat(lark_mcp): 更新飞书卡片消息发送工具以支持单接收者
- 将send_card_message工具从接收ID列表改为单个接收者ID - 修复test.py中导入并调用send_card_message的测试逻辑 - 新增机器人充电、终止任务、通知播放功能 - 扩展迎宾和巡逻功能参数,提供默认值和更灵活的配置 - 更新项目版本号至0.1.13和0.1.9
This commit is contained in:
@@ -23,6 +23,24 @@ async def serve() -> None:
|
||||
async def list_tools() -> list[Tool]:
|
||||
"""列出所有工具"""
|
||||
return [
|
||||
Tool(
|
||||
name="recharge",
|
||||
description="轮足机器人充电",
|
||||
inputSchema={
|
||||
"type": "object",
|
||||
"properties": {},
|
||||
"required": []
|
||||
}
|
||||
),
|
||||
Tool(
|
||||
name="terminate",
|
||||
description="轮足机器人终止当前任务",
|
||||
inputSchema={
|
||||
"type": "object",
|
||||
"properties": {},
|
||||
"required": []
|
||||
}
|
||||
),
|
||||
Tool(
|
||||
name="goto",
|
||||
description="轮足机器人导航到指定地点为用户引路。触发关键词:带我去、导航、引路、带路、怎么走、在哪里。",
|
||||
@@ -61,16 +79,41 @@ async def serve() -> None:
|
||||
"properties": {
|
||||
"location": {
|
||||
"type": "string",
|
||||
"description": "引导接待客人到这个位置",
|
||||
"description": "在这个位置接待贵宾",
|
||||
"minLength": 1
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"description": "客人姓名",
|
||||
"minLength": 1
|
||||
},
|
||||
"destination": {
|
||||
"type": "string",
|
||||
"description": "接待贵宾到这个位置",
|
||||
"minLength": 1
|
||||
}
|
||||
},
|
||||
"required": ["location", "name"]
|
||||
"required": ["location", "name", "destination"]
|
||||
}
|
||||
),
|
||||
Tool(
|
||||
name="notification",
|
||||
description="轮足机器人去指定地点播放通知:通知、去那里说、去某地播报、传达消息",
|
||||
inputSchema={
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"location": {
|
||||
"type": "string",
|
||||
"description": "机器人需要前往的目标地点名称",
|
||||
"minLength": 1
|
||||
},
|
||||
"text": {
|
||||
"type": "string",
|
||||
"description": "到达地点后需要播放的文本内容",
|
||||
"minLength": 1
|
||||
}
|
||||
},
|
||||
"required": ["location", "text"]
|
||||
}
|
||||
),
|
||||
Tool(
|
||||
@@ -84,19 +127,23 @@ async def serve() -> None:
|
||||
),
|
||||
Tool(
|
||||
name="patrol",
|
||||
description="轮足机器人、助手、机器人去巡逻:巡逻、巡查、去检查一下、去看看、去巡视",
|
||||
description="轮足机器人、助手、机器人去巡逻:巡逻、巡查、去检查一下、去看看、去巡视。支持按路线巡逻或随机巡逻。",
|
||||
inputSchema={
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"locations": {
|
||||
"type": "array",
|
||||
"description": "机器人巡逻经过的地点列表",
|
||||
"description": "机器人巡逻经过的地点列表。如果不提供,则默认进行随机巡逻。",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"flag": {
|
||||
"type": "boolean",
|
||||
"description": "是否随机巡逻。True为随机巡逻,False为按locations指定的路线巡逻。"
|
||||
}
|
||||
},
|
||||
"required": ["locations"]
|
||||
"required": []
|
||||
}
|
||||
)
|
||||
]
|
||||
@@ -106,7 +153,11 @@ async def serve() -> None:
|
||||
"""处理工具调用"""
|
||||
try:
|
||||
result = ""
|
||||
if name == "goto":
|
||||
if name == "recharge":
|
||||
result = await nav_server.recharge()
|
||||
elif name == "terminate":
|
||||
result = await nav_server.terminate()
|
||||
elif name == "goto":
|
||||
if "location" not in arguments:
|
||||
raise ValueError("缺少必要参数: location")
|
||||
result = await nav_server.goto(
|
||||
@@ -122,16 +173,25 @@ async def serve() -> None:
|
||||
if "location" not in arguments:
|
||||
raise ValueError("缺少必要参数: location")
|
||||
result = await nav_server.reception(
|
||||
location=arguments.get("location", "前台"),
|
||||
name=arguments.get("name", "贵宾"),
|
||||
destination=arguments.get("destination", "会议室")
|
||||
)
|
||||
elif name == "notification":
|
||||
if "location" not in arguments or "text" not in arguments:
|
||||
raise ValueError("缺少必要参数: location or text")
|
||||
result = await nav_server.notification(
|
||||
location=arguments["location"],
|
||||
name=arguments.get("name", "贵宾")
|
||||
text=arguments["text"]
|
||||
)
|
||||
elif name == "repose":
|
||||
result = await nav_server.repose()
|
||||
elif name == "patrol":
|
||||
if "locations" not in arguments:
|
||||
raise ValueError("缺少必要参数: locations")
|
||||
locations = arguments.get("locations", [])
|
||||
flag = arguments.get("flag", True if not locations else False)
|
||||
result = await nav_server.patrol(
|
||||
locations=arguments["locations"]
|
||||
locations=locations,
|
||||
flag=flag
|
||||
)
|
||||
else:
|
||||
raise ValueError(f"未知工具: {name}")
|
||||
|
||||
@@ -31,6 +31,25 @@ class NavServer:
|
||||
logger.error(f"Failed to publish command: {str(e)}", exc_info=True)
|
||||
return f"Failed to publish command: {str(e)}"
|
||||
|
||||
|
||||
async def recharge(self):
|
||||
"""轮足机器人充电"""
|
||||
try:
|
||||
params = {}
|
||||
return await self.pub_cmd("temi-test", "recharge", params)
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to call recharge mcp-tool: {str(e)} ", exc_info=True)
|
||||
return f"Failed to call recharge mcp-tool: {str(e)}"
|
||||
|
||||
async def terminate(self):
|
||||
"""轮足机器人终止当前任务"""
|
||||
try:
|
||||
params = {}
|
||||
return await self.pub_cmd("temi-test", "terminate", params)
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to call terminate mcp-tool: {str(e)} ", exc_info=True)
|
||||
return f"Failed to call terminate mcp-tool: {str(e)}"
|
||||
|
||||
async def goto(self, location: str, flag: bool = False):
|
||||
"""轮足导航到指定位置"""
|
||||
try:
|
||||
@@ -62,21 +81,34 @@ class NavServer:
|
||||
logger.error(f"Failed to call speak mcp-tool: {str(e)} ", exc_info=True)
|
||||
return f"Failed to call speak mcp-tool: {str(e)}"
|
||||
|
||||
async def reception(self, location: str, name: str = "贵宾"):
|
||||
async def reception(self, location: str = "前台", name: str = "贵宾", destination: str = "会议室"):
|
||||
"""轮足机器人移动到指定位置迎宾"""
|
||||
try:
|
||||
if not location:
|
||||
return "Location is not specified."
|
||||
|
||||
params = {
|
||||
"location": location,
|
||||
"text": f"您好,{name},我是接待机器人。",
|
||||
"destination": destination
|
||||
}
|
||||
return await self.pub_cmd("temi-test", "reception", params)
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to call reception mcp-tool: {str(e)} ", exc_info=True)
|
||||
return f"Failed to call reception mcp-tool: {str(e)}"
|
||||
|
||||
async def notification(self, location: str, text: str):
|
||||
"""轮足机器人移动到指定位置并播放通知文本"""
|
||||
try:
|
||||
if not location or not text:
|
||||
return "Location or text is not specified."
|
||||
|
||||
params = {
|
||||
"location": location,
|
||||
"text": text
|
||||
}
|
||||
return await self.pub_cmd("temi-test", "notification", params)
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to call notification mcp-tool: {str(e)} ", exc_info=True)
|
||||
return f"Failed to call notification mcp-tool: {str(e)}"
|
||||
|
||||
async def repose(self):
|
||||
"""轮足机器人重新定位"""
|
||||
try:
|
||||
@@ -86,14 +118,12 @@ class NavServer:
|
||||
logger.error(f"Failed to call repose mcp-tool: {str(e)} ", exc_info=True)
|
||||
return f"Failed to call repose mcp-tool: {str(e)}"
|
||||
|
||||
async def patrol(self, locations: list):
|
||||
"""轮足机器人巡逻"""
|
||||
async def patrol(self, locations: list = None, flag: bool = False):
|
||||
"""轮足机器人巡逻 why !!! """
|
||||
try:
|
||||
if not locations:
|
||||
return "locations is not specified."
|
||||
params = {
|
||||
"flag": False,
|
||||
"locations": locations
|
||||
"flag": True,
|
||||
"locations": locations or []
|
||||
}
|
||||
return await self.pub_cmd("temi-test", "patrol", params)
|
||||
except Exception as e:
|
||||
|
||||
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
||||
|
||||
[project]
|
||||
name = "lzwcai_temi_mcp"
|
||||
version = "0.1.1"
|
||||
version = "0.1.9"
|
||||
description = "MQTT-based navigation server for robot"
|
||||
requires-python = ">=3.10"
|
||||
dependencies = [
|
||||
|
||||
Reference in New Issue
Block a user