Extend with tools
Scale to many tools with tool search
Scale to many tools with tool search 这一页讲的,就是 Scale to many tools with tool search 这件事在 Claude Code 里到底怎么用。
页面信息
这页不是官方原文,而是顺着官方文档结构做的中文解释版。命令、参数、配置名这些硬东西尽量保留,解释部分则尽量讲成人能照着做的话。
如果你碰到特别敏感的配置、权限或企业环境差异,最好顺手点上面的“查看原始文档”再核一遍。
这一页先讲明白
这页主要讲 Scale to many tools with tool search:Scale your agent to thousands of tools by discovering and loading only what's needed, on demand.
你可以把它当成"Extend with tools"这块里专门管这一摊事的说明书。
你可以把"Scale to many tools with tool search"理解成 Extend with tools 这一栏里的一把专门工具。这页不是让你背书,而是教你什么时候该把这把工具拿出来。
原文这页大多会按 How tool search works、Configure tool search、Optimize tool discovery、Limits 这些环节往下讲。
翻成人话,大概就是:How tool search works
第一,先别一上来全开全配。先按最小一步试通,确认没跑偏,再继续往下加。
第二,命令、配置名、参数名这些硬东西尽量保留原样。人话解释是帮你听懂,不是帮你改关键字。
第三,照着原文这几个环节挨个过:How tool search works -> Configure tool search -> Optimize tool discovery -> Limits。像下地先看水路、再试机器、再正式开干,一步一步最稳。
原页关键片段:Configure tool search
真到动手的时候了,下面这条直接敲一遍,看它回什么。
import { query } from "@anthropic-ai/claude-agent-sdk";
for await (const message of query({
prompt: "Find and run the appropriate database query",
options: {
mcpServers: {
"enterprise-tools": {
// Connect to a remote MCP server
type: "http",
url: "https://tools.example.com/mcp"
}
},
allowedTools: ["mcp__enterprise-tools__*"], // Wildcard pre-approves all tools from this server
env: {
ENABLE_TOOL_SEARCH: "auto:5" // Activate tool search when tools exceed 5% of context
}
}
})) {
if (message.type === "result" && message.subtype === "success") {
console.log(message.result);
}
} 原页关键片段:Optimize tool discovery
这一步不用你自己动手配什么,把下面这句话交出去就行。
You can search for tools to interact with Slack, GitHub, and Jira. Documentation Index
这里不是让你背"Documentation Index"这个词,而是让你看它真干活时怎么使。
看这段时要特别盯工具和权限边界,别为了省事一把全开。
How tool search works
看懂这里,后面出怪事时你心里会更有底。
看这段时要特别盯工具和权限边界,别为了省事一把全开。
Configure tool search
看到这类标题,就当是在调一个具体开关。
看这段时要特别盯工具和权限边界,别为了省事一把全开。
Configure tool search
真到动手的时候了,下面这条直接敲一遍,看它回什么。
import { query } from "@anthropic-ai/claude-agent-sdk";
for await (const message of query({
prompt: "Find and run the appropriate database query",
options: {
mcpServers: {
"enterprise-tools": {
// Connect to a remote MCP server
type: "http",
url: "https://tools.example.com/mcp"
}
},
allowedTools: ["mcp__enterprise-tools__*"], // Wildcard pre-approves all tools from this server
env: {
ENABLE_TOOL_SEARCH: "auto:5" // Activate tool search when tools exceed 5% of context
}
}
})) {
if (message.type === "result" && message.subtype === "success") {
console.log(message.result);
}
} Optimize tool discovery
别把这段只当成标题看,它其实是在给"Optimize tool discovery"划边界。
看这段时要特别盯工具和权限边界,别为了省事一把全开。
Optimize tool discovery
这一步不用你自己动手配什么,把下面这句话交出去就行。
You can search for tools to interact with Slack, GitHub, and Jira. Limits
这里不是让你背"Limits"这个词,而是让你看它真干活时怎么使。
看这段时要特别盯工具和权限边界,别为了省事一把全开。
Related documentation
看到这里,就把"Related documentation"当成一件真要上手的活来看。
看这段时要特别盯工具和权限边界,别为了省事一把全开。
照着做一遍
如果你不想来回翻,就先照这几步顺着做。
每做完一步就看一下结果,再决定要不要继续往下。
第 1 步:Configure tool search
真到动手的时候了,下面这条直接敲一遍,看它回什么。
import { query } from "@anthropic-ai/claude-agent-sdk";
for await (const message of query({
prompt: "Find and run the appropriate database query",
options: {
mcpServers: {
"enterprise-tools": {
// Connect to a remote MCP server
type: "http",
url: "https://tools.example.com/mcp"
}
},
allowedTools: ["mcp__enterprise-tools__*"], // Wildcard pre-approves all tools from this server
env: {
ENABLE_TOOL_SEARCH: "auto:5" // Activate tool search when tools exceed 5% of context
}
}
})) {
if (message.type === "result" && message.subtype === "success") {
console.log(message.result);
}
} 第 2 步:Optimize tool discovery
这一步不用你自己动手配什么,把下面这句话交出去就行。
You can search for tools to interact with Slack, GitHub, and Jira. 一眼看懂这一页
先把这页到底在讲什么看明白,再去碰具体命令和配置,最不容易绕晕。
Scale to many tools with tool search
|
v
这是 Extend with tools 里的一摊要紧活
|
v
先弄懂,再下手 文末提醒
这站会按官方 docs 的导航和内容变化继续重生成,原站加页、删页、改页时,这里会跟着更新。
人话解释会尽量顺着原页往下讲,但命令、参数名、配置名这些硬东西还是保留原样,免得你抄过去跑不起来。