元鉴
返回中文阅读流

Hugging Face Blog

为 Reachy Mini 添加 MCP 工具

来自 Hugging Face Blog 的最新公开更新。

中文内容

已翻译official company source英文原文2026-06-03

为 Reachy Mini 添加 MCP 工具

发布于 2026 年 6 月 3 日
Update on GitHub
Reachy Mini looking out the window
Reachy Mini 不必再望向窗外才能告诉你天气

内置工具;配置文件如何控制工具;本地工具的限制;从 Spaces 调用工具;安装、列出、移除;清单存放位置;工具命名;示例配置文件;为什么提示词很重要;目前可用与不可用的内容;发布工具 Space 的提示;结论。Reachy Mini 对话应用现在可以使用托管在公共 Hugging Face Spaces 中、通过 MCP 调用的工具。你可以通过从 Hub 添加一个 Space,而不是编辑应用,为机器人赋予一种新能力,例如查询天气或搜索网页。该工具会继续在 Space 本身中运行,因此不会将代码下载到你的机器上。你也可以发布自己的工具供其他人使用。

添加工具只需一条命令:

reachy-mini-conversation-app tool-spaces add pollen-robotics/reachy-mini-weather-tool

然后像往常一样启动应用:

reachy-mini-conversation-app

现在你可以直接询问:

What's the weather in Paris today?

下面,我们将介绍什么是工具、配置文件如何控制机器人可使用的内容,以及远程路径当前的限制。

内置工具

当你与机器人交谈时,得到的并不只是一段语音,而是一个会对对话作出反应的系统:在适用时,机器人可以移动并以非语言方式回应。这里我们想重点介绍的是让这些成为可能的工具。工具是模型在对话期间可以执行的事情:播放一种情绪、移动头部、通过摄像头查看。每个工具都有名称和简短描述。模型会读取这些信息,判断何时有用,调用它,并使用返回的结果。

目前,每个工具都是本地的,并随应用一起提供,其中大多数与机器人的身体有关:

Tool What it does move_head Queue a head pose change dance / stop_dance Play or clear a dance from the dances library play_emotion / stop_emotion Play or clear a recorded emotion clip head_tracking Toggle head-tracking offsets camera Capture a frame and analyze it idle_do_nothing Explicitly stay idle on an idle turn

配置文件如何控制工具

代码中的工具只有在配置文件中启用后才能使用。配置文件是一个文件夹,这里相关的有两个文件:instructions.txt(提示词)和 tools.txt(已启用的工具)。

默认配置文件会启用完整集合:

# profiles/default/tools.txt
dance
stop_dance
play_emotion
stop_emotion
camera
idle_do_nothing
head_tracking
move_head

如果某个名称不在 tools.txt 中,模型就无法调用它。

你也可以编写自己的工具:向配置文件(或 external_tools/)添加一个 Python 文件,为它提供名称和描述,并在 tools.txt 中列出该名称。

目前有内置工具和自定义本地工具,tools.txt 决定哪些工具处于活动状态。这对机器人的身体控制很适用,并能保持受信任核心较小。

本地工具的限制

这里的约束是,每个工具都必须是本地 Python。对于 move_head 或 play_emotion 来说这是合理的:它们与硬件通信,属于应用的一部分。但许多有用的功能与身体无关,例如网页搜索、天气或查询。对这些功能来说,把所有内容都保持在本地主要会带来摩擦:

  • 共享工具意味着把你的 Python 文件交给别人
  • 更新工具意味着再次发送这些文件
  • 更改工具意味着编辑应用,尽管该能力实际上与应用是分离的

从 Spaces 调用工具

远程工具在你已有的内置工具和自定义本地工具之外增加了第三种类型,用于那些更容易独立发布、共享和更新的能力:

  • 内置机器人工具保持本地且可信
  • 可共享的远程工具可以存在于公共 Hugging Face Spaces 中
  • 你仍然可以使用来自 external_tools/ 的自定义一次性工具。它非常适合搜索、天气和查询等无状态能力:也就是任何你希望在不触碰应用本身的情况下迭代的内容。而且由于任何人都可以发布兼容的 Space,共享工具并在彼此工作的基础上继续构建会很容易。

我们从两个 canary 工具开始,它们是用于测试新流程的小型测试工具:

  • 正文:pollen-robotics/reachy-mini-search-tool
  • 正文:pollen-robotics/reachy-mini-weather-tool

它们足以覆盖整个功能:从 Hub 安装、发现远程工具、按配置文件启用它们,并让实时后端像调用内置工具一样调用它们。

要同时使用两者,请添加每个 Space,并将它们的工具堆叠在同一个配置文件中:

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 配置文件所做的。

安装、列出、移除

# 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 追加到活动配置文件的 tools.txt 中。除非你设置了 REACHY_MINI_CUSTOM_PROFILE,否则活动配置文件为 default。使用 --install-only 可跳过这一步。

tools.txt 是守门人:只有当远程工具的 ID 出现在配置文件的 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

这可以避免远程工具名称与内置工具冲突,并允许多个 Spaces 在同一个配置文件中共存。

实现中还会在可能时去除冗余的 Space 名称前缀,因此一个冗长的远程工具名会变成更简洁的本地 ID。如果去除前缀会导致同一 Space 中两个工具之间发生冲突,代码会回退到完整命名空间名称。

注册表层面还有重复安全检查:Tool.name 值在整个合并工具集中必须唯一。如果两个来源声明了相同名称,应用会快速失败。

示例配置文件

为了这项工作,我们创建了两个聚焦的 canary 配置文件,以将 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 仍然可以在回答来自网页的当前问题时作出富有表现力的反应。

为什么提示词很重要

远程工具管线会把工具交给模型。提示词决定模型如何使用这些工具。

这一点在搜索加天气的 canary 中尤其明显。一个组合问题,例如:

Should I bring a jacket in Bordeaux today, and is there anything major happening downtown tonight?

至少可以用三种方式处理:先天气后搜索、先搜索后天气,或在同一轮中同时处理。如果提示词含糊,模型会将调用串行化并造成不必要的延迟。因此,canary 提示词成为该功能的一部分,而不只是偶然的配置。

正文:canary_web_search/instructions.txt

[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.

正文:canary_web_search_weather/instructions.txt

[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.

目前可用与不可用的内容

Capability Supported Install by slug for public, MCP-compatible Gradio Spaces (standard /gradio_api/mcp/ endpoint) ✅ Multiple Spaces at once ✅ Per-profile enablement via tools.txt ✅ Namespaced remote tool IDs ✅ Backend-agnostic registration (OpenAI, Gemini, Hugging Face) ✅ No arbitrary code downloaded into the local app ✅ Private or authenticated Spaces ❌ Non-Gradio Spaces ❌ Arbitrary raw MCP URLs or non-Hugging Face MCP servers ❌ Guaranteed parallel tool orchestration ❌

有两点值得特别指出。首先,Space 必须确实表现得像一个 MCP 服务器;如果工具发现失败,安装就会失败。其次,提示词指令可以鼓励并行调用,但无法保证并行调用。如果某个用例需要确定性的编排,该逻辑应从提示词转移到代码中。

发布工具 Space 的提示

如果你希望其他人使用你的工具,请将其发布为公开的 Gradio Space,暴露标准 MCP 端点,并保持工具无状态,以便它们能很好地通过网络工作。一个 Space 能否安装取决于这种运行时行为,而不是标签。

安装不需要标签,但标签有助于人们找到兼容的 Spaces:

  • 正文:reachy-mini-tool
  • 正文:mcp

结论

该应用现在有三类工具共享同一个注册表:内置工具、本地自定义工具和远程 MCP 工具,而配置文件仍然决定某个给定助手可以访问哪些工具。一个小型、受信任的核心保持在中心位置,而其周围的可选能力可以在不触碰应用本身的情况下被添加、测试和替换。

我们现在最感兴趣的是人们会构建什么。如果你发布了工具 Space,请为其标记 reachy-mini-tool 和 mcp,方便其他人找到。我们很期待看到 Reachy Mini 最终能够做些什么!

致谢:非常感谢 Fabien Danieau 校对本文并帮助测试工作流,感谢 Andres Marafioti 帮助测试,也感谢 Remi Fabre 和 Pollen Robotics 团队提出想法和反馈,塑造了远程工具工作流。

原文标题

Adding MCP Tools to Reachy Mini