更新 MCP 工具
3.0 版本引入
这是一项实验性功能,不建议在生产环境中使用。有关该功能的最新进展或您希望提供反馈,请加入 OpenSearch 论坛的讨论。
使用此 API 更新一个或多个基于模型上下文协议 (MCP) 的工具。有关支持工具的更多信息,请参阅工具。
端点
POST /_plugins/_ml/mcp/tools/_update
请求正文字段
下表列出了可用的请求字段。
字段 | 数据类型 | 必需/可选 | 描述 |
---|---|---|---|
工具 | 数组 | 必需 | 工具列表。 |
tools
数组包含一个工具列表。每个工具包含以下字段。
字段 | 数据类型 | 必需/可选 | 描述 |
---|---|---|---|
名称 | 字符串 | 必需 | 要更新的工具名称。 |
类型 | 字符串 | 可选 | 工具类型。有关支持的工具列表,请参阅 工具。 |
描述 | 字符串 | 可选 | 工具的描述。 |
参数 | 对象 | 可选 | 工具的参数。参数取决于工具类型。有关特定工具类型的信息,请参阅相应的工具文档。 |
属性 | 对象 | 可选 | 工具的配置属性(attributes)。此字段中最重要的属性是工具的 input_schema ,它定义了工具所需的参数格式。此架构被发送到大型语言模型 (LLM),以便在执行工具时正确格式化参数。 |
示例请求
以下部分提供了更新工具的示例请求。有关工具特定参数的信息,请参阅相应的工具文档。
WebSearchTool
POST /_plugins/_ml/mcp/tools/_update
{
"tools": [
{
"type": "WebSearchTool",
"name": "GoogleSearchTool",
"description": "This tool can be used to perform search via google engine and parse the content of the searched results",
"attributes": {
"input_schema": {
"type": "object",
"properties": {
"engine": {
"type": "string",
"description": "The search engine that will be used by the tool."
},
"query": {
"type": "string",
"description": "The search query parameter that will be used by the engine to perform the search."
},
"next_page": {
"type": "string",
"description": "The search result's next page link. If this is provided, the WebSearchTool will fetch the next page results using this link and crawl the links on the page."
}
},
"required": [
"engine",
"query"
]
},
"strict": false
}
}
]
}
PPLTool
POST /_plugins/_ml/mcp/tools/_update
{
"type": "PPLTool",
"name": "TransferQuestionToPPLAndExecuteTool",
"description": "Use this tool to convert natural language into PPL queries and execute them. Use this tool after you know the index name; otherwise, call IndexRoutingTool first. The input parameters are: {index: IndexName, question: UserQuestion}",
"parameters": {
"model_id": "${your_model_id}",
"model_type": "FINETUNE"
},
"attributes": {
"input_schema": {
"type": "object",
"properties": {
"question": {
"type": "string",
"description": "The user's natural language question that needs to be converted to PPL."
},
"index": {
"type": "string",
"description": "The index on which the generated PPL query will be executed."
}
}
}
}
}
示例响应
对于每个节点,OpenSearch 返回节点 ID 和所有工具的更新操作状态。
{
"_ZNV5BrNTVm6ilcM7Jn1pw": {
"updated": true
},
"NZ9aiUCrSp2b5KBqdJGJKw": {
"updated": true
}
}