search_tools
在搜索模式下按关键词查找 API 操作。操作数量达到数百个时,列出所有工具会在代理开始工作前占满其上下文。在搜索模式下,代理会在此处找到所需的少数操作,通过 describe_tool 读取它们,再通过 call_tool 运行其中一个。
何时会列出
在搜索模式下:当工具模式为 search,或者为 auto 且服务器上的操作工具数量超过搜索阈值(默认 40,可更改)时提供。这些工具会取代列表中的操作工具。参见搜索和代码模式。
参数
querystring用几个词描述操作的作用,例如 create invoice。搜索会匹配名称、描述、路径和分组。
groupstring仅搜索来自list_tool_groups 此分组的操作。只有当操作分属两个或更多分组时才会提供。
limitinteger要返回的结果数量,范围为 1 到 25。
offsetinteger跳过的结果数量,用于翻阅较长的匹配结果。
返回值
先显示匹配的操作数量,然后每个操作占一行,并按相关度从高到低排列:名称、方法和路径、摘要、必需参数,以及调用是否会先询问用户。
提示
客户端读取的注解,用于判断哪些操作可以在不询问用户的情况下运行。
| 提示 | 值 | 为 true 时,表示 |
|---|---|---|
readOnlyHint | true | 不会产生任何更改 |
openWorldHint | false | 会通过网络访问服务器以外的资源 |
示例
查找操作
Call
{
"name": "search_tools",
"arguments": {
"query": "cancel a subscription",
"limit": 4
}
}Result
8 operations of 23 match "cancel a subscription" (showing 1 to 4):
cancelSubscription · POST /subscriptions/{subscriptionId}/cancel · Cancel a subscription · requires: subscriptionId · asks the user first
listSubscriptions · GET /subscriptions · List subscriptions · no required arguments
createSubscription · POST /subscriptions · Start a subscription · requires: body · asks the user first
updateSubscription · PATCH /subscriptions/{subscriptionId} · Change a subscription · requires: subscriptionId, body · asks the user first
Next: describe_tool with the names you need, then call_tool. Pass offset 4 for more.相关内容
- 搜索模式工具:
describe_tool、call_tool、list_tool_groups。 - 搜索和代码模式:服务器何时切换模式,以及如何选择。
- 权限和限制:每次调用都遵循的规则。