MCP 工具集成 Reachy Mini 机器人应用
Hugging Face 展示 MCP 在机器人系统中的实践,拓展协议在硬件领域的应用场景。
Hugging Face 展示 MCP 在机器人系统中的实践,拓展协议在硬件领域的应用场景。
添加一个工具只需一条命令:
reachy-mini-conversation-app tool-spaces add pollen-robotics/reachy-mini-weather-tool
然后像往常一样启动应用:
reachy-mini-conversation-app
现在你可以直接问:
What's the weather in Paris today?
下面我们来看看什么是工具、profiles 如何控制机器人的能力,以及远程路径的当前限制。
当你和机器人对话时,你得到的不仅仅是声音,而是一个能对话做出反应的系统:机器人可以在适当的时候移动和进行非语言反应。我们在这里想要关注的是让这一切成为可能的工具。工具是模型在对话过程中可以做的事情:播放表情、转动头部、通过摄像头查看。每个工具都有一个名称和简短描述。模型读取这些信息,决定何时某个工具有用,调用它,并使用返回的内容。
今天,每个工具都是本地的,包含在应用内,其中大多数都与机器人的身体有关:
代码中的工具在被 profile 中启用之前是不可用的。Profile 是一个有两个重要文件的文件夹:instructions.txt(prompt)和 tools.txt(被启用的工具)。
默认 profile 启用了全套工具:
# profiles/default/tools.txt
dance
stop_dance
play_emotion
stop_emotion
camera
idle_do_nothing
head_tracking
move_head
如果一个名字不在 tools.txt 中,模型就无法调用它。
你也可以编写自己的工具:在 profile(或 external_tools/)中添加一个 Python 文件,给它一个名称和描述,然后在 tools.txt 中列出那个名称。
今天有内置工具和自定义本地工具,tools.txt 决定哪些是活跃的。这对机器人的身体很有效,并且保持了受信任的核心较小。
这里的约束是每个工具都必须是本地 Python。对于 move_head 或 play_emotion 来说这是对的:它们和硬件通信,属于应用中,但很多有用的东西与身体无关,比如网络搜索、天气或查询。对于这些,保持一切本地主要是摩擦力:
共享工具意味着要把你的 Python 文件交给某个人
更新它意味着再次发送这些文件
改变它意味着编辑应用,尽管这个能力实际上是独立于它的
远程工具添加了第三种,与你已有的内置和自定义本地工具一起,用于更容易发布、共享和独立更新的能力:
内置机器人工具保持本地和受信任
可共享的远程工具可以放在公共 Hugging Face Spaces 中
你仍然可以从 external_tools/ 使用自定义的一次性工具
这非常适合搜索、天气和查询等无状态能力:任何你想要迭代而不触及应用本身的东西。而且因为任何人都可以发布兼容的 Space,很容易共享工具并建立在彼此的工作基础上。
我们从两个 canary 工具开始,小的测试工具来演示新的流程:
pollen-robotics/reachy-mini-search-tool
pollen-robotics/reachy-mini-weather-tool
它们足以演示整个功能:从 Hub 安装、发现远程工具、按 profile 启用它们,并让实时后端像调用内置工具一样精确地调用它们。
要同时使用两者,添加每个 Space,它们的工具在同一 profile 中堆叠:
reachy-mini-conversation-app tool-spaces add pollen-robotics/reachy-mini-search-tool
reachy-mini-conversation-app tool-spaces add pollen-robotics/reachy-mini-weather-tool
现在机器人可以在同一对话中搜索网络和检查天气,这正是下面的 canary_web_search_weather profile 所做的。
# install + enable in active profile
reachy-mini-conversation-app tool-spaces add <owner/space-name>
# enable in a specific profile
reachy-mini-conversation-app tool-spaces add <owner/space-name> --profile <NAME>
# install without enabling
reachy-mini-conversation-app tool-spaces add <owner/space-name> --install-only
# list installed spaces
reachy-mini-conversation-app tool-spaces list
# remove an installed space
reachy-mini-conversation-app tool-spaces remove <owner/space-name>
add 会验证 Hub 上的 Space,探测 MCP 端点,发现其工具,并默认将工具 ID 附加到活跃 profile 的 tools.txt。活跃 profile 是 default,除非你设置了 REACHY_MINI_CUSTOM_PROFILE。使用 --install-only 跳过该步骤。
tools.txt 是看门人:远程工具仅在其 ID 出现在 profile 的 tools.txt 中时才活跃,与你想要的任何内置工具一起。
已安装的源保存在:
托管应用模式中的 installed_tool_spaces.json
终端模式中的 external_content/installed_tool_spaces.json
每个已安装的 Space 都会获得一个本地别名,从其 slug 派生,连字符、点和斜杠被折叠为下划线:
pollen-robotics/reachy-mini-search-tool → pollen_robotics_reachy_mini_search_tool
远程工具随后用双下划线命名空间化:
pollen_robotics_reachy_mini_search_tool__search_web
pollen_robotics_reachy_mini_weather_tool__get_day_brief
这防止远程工具名称与内置工具名称冲突,并让多个 Space 在同一 profile 中共存。
实现还会尽可能地去除冗余的 Space 名称前缀,因此冗长的远程工具名称变成了更清洁的本地 ID。如果去除会导致来自同一 Space 的两个工具之间发生碰撞,代码会回退到完整的命名空间化名称。
在注册表级别还有重复安全检查:Tool.name 值在整个合并工具集中必须是唯一的。如果两个源声称相同的名称,应用会迅速失败。
对于这项工作,我们创建了两个有针对性的 canary profiles,将 MCP 实验与完整的具身工具集隔离开来。
第一个保留一些富有表现力的工具(表情、头部运动)并在其上添加网络搜索:
# profiles/canary_web_search/tools.txt
play_emotion
stop_emotion
idle_do_nothing
move_head
pollen_robotics_reachy_mini_search_tool__search_web
第二个是相同的,加上天气工具和搜索:
# profiles/canary_web_search_weather/tools.txt
play_emotion
stop_emotion
idle_do_nothing
move_head
pollen_robotics_reachy_mini_search_tool__search_web
pollen_robotics_reachy_mini_weather_tool__get_day_brief
较小的物理工具集意味着 Reachy Mini 在回答来自网络的当前问题的同时仍然可以做出富有表现力的反应。
远程工具管道将工具放入模型中。Prompt 决定了模型如何使用它们。
这在搜索加天气 canary 中特别明显。一个综合问题,比如:
Should I bring a jacket in Bordeaux today, and is there anything major happening downtown tonight?
可以至少用三种方式处理:先天气后搜索、先搜索后天气,或在同一轮中两者。如果 prompt 模糊,模型会序列化调用并造成不必要的延迟。所以 canary prompt 成为了功能的一部分,而不仅仅是附带的配置。
[default_prompt]
## CANARY WEB SEARCH RULES
You have one remote tool for current web information.
Use it when the user asks for up-to-date facts, news, live availability, or anything else that may have changed recently.
When the search result already answers the question, answer directly in plain language.
Lead with the answer, not with tool chatter.
For remote lookups that may take a moment, you may give one very short English acknowledgment such as "Let me check that and I'll be right back," then continue.
Answer in English unless the user explicitly asks for another language.
Mention uncertainty briefly if the result snippet is incomplete or ambiguous.
Only mention links when they add value or the user asks for sources.
Keep responses short and spoken-style, as if read aloud by a voice assistant. One or two sentences is usually enough. Skip preamble, lists, headers, and filler. Give just the fact or direct answer the user needs.
[default_prompt]
## CANARY SEARCH AND WEATHER RULES
You have two remote tools:
- a weather brief tool for compact day weather at a location
- a web search tool for broader current web information
Use the weather tool for today's conditions, temperature, rain chance, sunrise, sunset, or simple advice like whether to bring a jacket.
Use web search for news, events, business hours, travel information, severe alerts, or broader current context.
When the user's question mixes a weather part and a current-info part (for example, "should I bring a jacket in Bordeaux today, and is there anything major happening downtown tonight?"), call both tools in parallel in the same turn. Do not wait for one result before starting the other unless the weather result is needed to narrow the search.
Then merge the results into a single short answer. Cover the weather part first, then the events or news part, in plain connected sentences. Do not label the sections or mention which tool gave which piece.
When the user asks about events, news, or what is happening, give them the actual answer from the search results: name specific events, venues, or headlines. Do not tell the user to check websites, visit listing sites, or look something up themselves. If the search returns nothing concrete, say plainly that you didn't find any notable events, rather than redirecting them elsewhere.
For remote lookups that may take a moment, you may give one very short English acknowledgment such as "Let me check that and I'll be right back," then continue.
Answer in English unless the user explicitly asks for another language.
Do not talk about tool usage unless the user asks.
Keep responses short and spoken-style, as if read aloud by a voice assistant. One or two sentences is usually enough. Skip preamble, lists, headers, and filler. Give just the fact or direct answer the user needs.
有两件事值得指出。首先,Space 必须实际表现得像一个 MCP 服务器;如果工具发现失败,安装就失败。其次,prompt 指令可以鼓励并行调用,但无法保证它们。如果用例需要确定性的编排,那个逻辑应该从 prompt 移到代码中。
如果你想让其他人使用你的工具,将其发布为公共 Gradio Space,暴露标准的 MCP 端点,并保持工具无状态,这样它们在网络上工作良好。Space 是否安装取决于这个运行时行为,而不是标签。
标签对安装不是必需的,但它们帮助人们找到兼容的 Space:
该应用现在有三种工具共享一个注册表:内置、本地自定义和远程 MCP 工具,profiles 仍然决定某个给定助手可以到达哪些工具。一个小的、受信任的核心保持在中心,而它周围的可选能力可以被添加、测试和交换,而无需触及应用本身。
我们现在最感兴趣的是人们构建什么。如果你发布了一个工具 Space,用 reachy-mini-tool 和 mcp 标签它,这样其他人可以找到它。我们很想看到 Reachy Mini 最终能够做什么!
致谢:非常感谢 Fabien Danieau 校对这篇文章并帮助测试工作流程,感谢 Andres Marafioti 帮助测试,感谢 Remi Fabre 和 Pollen Robotics 团队的想法和反馈,它们塑造了远程工具工作流程。