Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

MCP

ZeroClaw 支持 模型上下文协议 (MCP),允许您通过外部工具和上下文提供程序扩展代理的功能。本指南说明了如何注册和配置 MCP 服务器。

概述

MCP 服务器可以通过三种传输类型进行连接:

  • stdio:长期运行的本地进程(例如 Node.js 或 Python 脚本)。
  • sse:通过服务器发送事件(Server-Sent Events)连接远程服务器。
  • http:基于简单 HTTP POST 的服务器。

配置

MCP 服务器在 config.toml[mcp][[mcp.servers]] 下进行配置。显示 name(用作工具前缀 name__tool_name)是必需的,此外还需要 transportstdio | sse | http)以及传输特定的字段。有关完整的字段索引和默认值,请参阅 配置参考

保持 deferred_loading = true(默认值)以按需加载工具模式——这可以最小化初始令牌开销。

安全与自动审批

By default, any tool execution from an MCP server requires manual approval unless the agent’s risk-profile level is set to full.

To automatically approve specific tools from an MCP server, add them to auto_approve on the agent’s risk profile ([risk_profiles.<alias>]):

[risk_profiles.assistant]
auto_approve = [
  "my_local_tool__read_file",   # tool from `my_local_tool` MCP server
  "my_remote_tool__get_weather" # tool from `my_remote_tool` MCP server
]

See Autonomy levels for the full surface of per-profile fields.

提示

  • 工具过滤:您可以通过项目配置中的 tool_filter_groups 限制暴露给 LLM 的 MCP 工具。
  • 延迟加载:将 deferred_loading = true 设置为启用状态,可以通过仅向 LLM 发送工具名称来减少初始令牌开销。智能体将在决定使用工具时再获取完整的模式。