# 工具参考

Anthropic 提供的工具目录以及可选工具定义属性的参考。

---

本页是 Anthropic 提供的工具以及你可以在任何工具定义上设置的可选属性的参考。有关工具使用的概念介绍，请参阅[Claude 的工具使用](/docs/en/agents-and-tools/tool-use/overview)。有关在应用程序中实现工具使用的指导，请参阅[定义工具](/docs/en/agents-and-tools/tool-use/define-tools)。

## Anthropic 提供的工具

Anthropic 提供两种工具：在 Anthropic 的基础设施上执行的**服务器端工具**，以及 Anthropic 定义 schema 但你的应用程序处理执行的**客户端工具**。两种工具都与任何用户定义的工具一起出现在请求的 `tools` 数组中。

| 工具                                                                          | `type`                                                                 | 执行方式 | 状态                                                        |
| ----------------------------------------------------------------------------- | ---------------------------------------------------------------------- | --------- | ------------------------------------------------------------- |
| [网络搜索工具](/docs/en/agents-and-tools/tool-use/web-search-tool)         | `web_search_20260209`<br/>`web_search_20250305`                        | 服务器端    | GA                                                            |
| [网页抓取工具](/docs/en/agents-and-tools/tool-use/web-fetch-tool)           | `web_fetch_20260209`<br/>`web_fetch_20250910`                          | 服务器端    | GA                                                            |
| [代码执行工具](/docs/en/agents-and-tools/tool-use/code-execution-tool) | `code_execution_20260120`<br/>`code_execution_20250825`                | 服务器端    | GA                                                            |
| [顾问工具](/docs/en/agents-and-tools/tool-use/advisor-tool)               | `advisor_20260301`                                                     | 服务器端    | Beta: `advisor-tool-2026-03-01`                               |
| [工具搜索工具](/docs/en/agents-and-tools/tool-use/tool-search-tool)       | `tool_search_tool_regex_20251119`<br/>`tool_search_tool_bm25_20251119` | 服务器端    | GA                                                            |
| [MCP 连接器](/docs/en/agents-and-tools/mcp-connector)                      | `mcp_toolset`                                                          | 服务器端    | Beta: `mcp-client-2025-11-20`                                 |
| [内存工具](/docs/en/agents-and-tools/tool-use/memory-tool)                 | `memory_20250818`                                                      | 客户端    | GA                                                            |
| [Bash 工具](/docs/en/agents-and-tools/tool-use/bash-tool)                     | `bash_20250124`                                                        | 客户端    | GA                                                            |
| [文本编辑器工具](/docs/en/agents-and-tools/tool-use/text-editor-tool)       | `text_editor_20250728`<br/>`text_editor_20250124`                      | 客户端    | GA                                                            |
| [计算机使用工具](/docs/en/agents-and-tools/tool-use/computer-use-tool)     | `computer_20251124`<br/>`computer_20250124`                            | 客户端    | Beta: `computer-use-2025-11-24`<br/>`computer-use-2025-01-24` |

有关模型兼容性，请参阅每个工具的页面。支持的模型因工具和工具版本而异。

<Note>
  工具搜索的 `type` 值也接受不带日期的别名：
  `tool_search_tool_regex` 和 `tool_search_tool_bm25`。这些解析为
  最新的带日期版本。
</Note>

### 工具版本控制

大多数 Anthropic 提供的工具在 `type` 字符串中带有 `_YYYYMMDD` 后缀。当工具的行为、schema 或模型支持发生变化时，会发布新版本。旧版本仍然可用，以便现有集成继续工作。

当工具有多个活动版本时，它们之间的关系各不相同：

- **功能键控：** `web_search_20260209` 和 `web_fetch_20260209` 在其前身之上添加了动态内容过滤。`code_execution_20260120` 添加了从沙箱内进行[程序化工具调用](/docs/en/agents-and-tools/tool-use/programmatic-tool-calling)。在每种情况下，新版本和旧版本都是当前的；你使用哪个取决于你是否需要新功能。
- **模型键控：** `text_editor_20250728` 用于 Claude 4 模型，`text_editor_20250124` 用于早期模型。你使用的版本取决于你目标的模型。
- **变体，而非版本：** `tool_search_tool_regex_20251119` 和 `tool_search_tool_bm25_20251119` 是同时发布的两种搜索算法。两者都不取代另一个。
- **遗留版本：** `code_execution_20250522` 仅支持 Python。`code_execution_20250825` 添加了 Bash 和文件操作。

`mcp_toolset` 类型不使用日期版本控制；版本控制通过 `anthropic-beta` 头部传递。

## 工具定义属性

`tools` 数组中的每个工具，包括用户定义的工具，都接受可选属性来控制工具的加载方式、谁可以调用它以及如何验证其输入。这些属性是可组合的：你可以在同一个工具上设置 `defer_loading`、`cache_control` 和 `strict`。

| 属性                | 用途                                                                                                               | 可用于                                                                                                               | 详细指南                                                                                                      |
| ----------------------- | --------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- |
| `cache_control`         | 在此工具定义处设置提示缓存断点                                                                 | 所有工具                                                                                                                  | [提示缓存](/docs/en/build-with-claude/prompt-caching)                                                         |
| `strict`                | 保证工具名称和输入的 schema 验证                                                                  | 除 `mcp_toolset` 外的所有工具                                                                                             | [严格工具使用](/docs/en/agents-and-tools/tool-use/strict-tool-use)                                               |
| `defer_loading`         | 从初始系统提示中排除工具；当工具搜索返回该工具的 `tool_reference` 时按需加载 | 所有工具（对于 `mcp_toolset`，请参阅[工具配置](/docs/en/agents-and-tools/mcp-connector#mcp-toolset-configuration)） | [工具搜索工具](/docs/en/agents-and-tools/tool-use/tool-search-tool)                                             |
| `allowed_callers`       | 限制哪些调用者可以调用该工具                                                                              | 除 `mcp_toolset` 外的所有工具                                                                                             | [程序化工具调用](/docs/en/agents-and-tools/tool-use/programmatic-tool-calling#the-allowed-callers-field) |
| `input_examples`        | 提供示例输入对象以帮助 Claude 理解如何调用该工具                                          | 用户定义和 Anthropic-schema 客户端工具。服务器端工具不可用。                                             | [定义工具](/docs/en/agents-and-tools/tool-use/define-tools#providing-tool-use-examples)                         |
| `eager_input_streaming` | 为此工具启用细粒度输入流（`true`）或保持标准缓冲流（`false`）              | 仅限用户定义工具                                                                                                    | [细粒度工具流](/docs/en/agents-and-tools/tool-use/fine-grained-tool-streaming)                       |

### `allowed_callers` 值

`allowed_callers` 是一个接受任意组合的数组：

| 值                       | 含义                                                                                                           |
| --------------------------- | ----------------------------------------------------------------------------------------------------------------- |
| `"direct"`                  | 模型可以在 `tool_use` 块中直接调用此工具。如果省略 `allowed_callers`，这是默认值。 |
| `"code_execution_20260120"` | 在 `code_execution_20260120` 沙箱内运行的代码可以调用此工具。                                       |

从数组中省略 `"direct"`（例如 `"allowed_callers": ["code_execution_20260120"]`）意味着该工具只能从代码执行内部调用。响应的 `tool_use` 块包含一个 `caller` 字段，标识哪个调用者调用了该工具。有关完整处理，包括 `caller` 响应形状和错误行为，请参阅[程序化工具调用](/docs/en/agents-and-tools/tool-use/programmatic-tool-calling#the-allowed-callers-field)。

### `defer_loading` 和提示缓存

带有 `defer_loading: true` 的工具在计算缓存键之前会从渲染的工具部分中移除。它们根本不会出现在系统提示前缀中。当工具搜索发现延迟工具并返回其 `tool_reference` 时，该工具的完整定义会在对话主体中的该点展开，而不是在前缀中。

这意味着 `defer_loading: true` 保留了你的提示缓存。你可以向请求添加延迟工具而不会使现有缓存条目失效，并且缓存从发现工具的回合到调用工具的回合之间保持有效。

有关如何将 `defer_loading` 与 `cache_control` 断点结合使用，请参阅[工具搜索工具提示缓存指导](/docs/en/agents-and-tools/tool-use/tool-search-tool#prompt-caching)。
