HigressMcpClientWrapper
public class HigressMcpClientWrapper extends McpClientWrapper
io/agentscope/extensions/higress/HigressMcpClientWrapper.java:57–354Higress MCP 客户端包装器,把智能体接入外部消息渠道与企业平台。位于 io.agentscope.extensions.higress 包,继承自 McpClientWrapper。核心成员包括 initialize、listTools、callTool、close、isToolSearchEnabled、searchTools。
MCP client wrapper for Higress AI Gateway.
This wrapper extends McpClientWrapper to connect to Higress's unified MCP service
endpoint (union-tools-search). When semantic search is enabled in Higress, the gateway provides
a special tool x_higress_tool_search that can automatically select the most suitable
MCP tools based on user requests.
The wrapper delegates all MCP operations to an underlying McpClientWrapper instance
(either async or sync), providing a consistent interface for Higress-specific functionality.
Example usage:
`HigressMcpClientWrapper client = HigressMcpClientBuilder
.create("higress-mcp")
.sseEndpoint("http://higress-gateway/mcp-servers/union-tools-search/sse")
.build();
// Initialize and list tools
client.initialize().block();
List<McpSchema.Tool> tools = client.listTools().block();
// Call x_higress_tool_search to get recommended tools
McpSchema.CallToolResult result = client.callTool("x_higress_tool_search",
Map.of("query", "查询北京天气")).block();
`
字段摘要Field Summary
| 字段Field | 类型Type | 说明Description |
|---|---|---|
TOOL_SEARCH_NAMEstaticfinal | String | 工具搜索名称字段。 The name of the Higress tool search tool. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public Mono<Void> initialize() | 初始化 `HigressMcpClientWrapper` 实例。 Initializes the Higress MCP client connection. |
public Mono<List<McpSchema.Tool>> listTools() | 列出工具。 Lists tools available from the Higress gateway. |
public Mono<McpSchema.CallToolResult> callTool(String toolName, Map<String, Object> arguments) | 调用工具。 Invokes a tool on the Higress gateway. |
public Mono<McpSchema.CallToolResult> callTool(String toolName, Map<String, Object> arguments, Map<String, Object> meta) | 调用工具。 Calls the tool. |
public void close() | 关闭连接并释放相关资源。 Closes the Higress MCP client and releases all resources. |
public boolean isToolSearchEnabled() | 检查if x_Higress_工具_搜索模式是已启用 in 此客户端。 Checks if x_higress_tool_search mode is enabled in this client. |
public Mono<HigressToolSearchResult> searchTools(String query) | 搜索工具。 Searches for tools matching the query and returns parsed result. |
public Mono<HigressToolSearchResult> searchTools(String query, int topK) | 搜索工具。 Searches for tools matching the query with topK limit. |
字段详情Field Detail
TOOL_SEARCH_NAME
public static final String TOOL_SEARCH_NAME
工具搜索名称字段。声明为 public static final String TOOL_SEARCH_NAME。
The name of the Higress tool search tool.
io/agentscope/extensions/higress/HigressMcpClientWrapper.java:64方法详情Method Detail
initialize
public Mono<Void> initialize()
初始化 HigressMcpClientWrapper 实例。
Initializes the Higress MCP client connection.
Mono<Void>io/agentscope/extensions/higress/HigressMcpClientWrapper.java:116–139listTools
public Mono<List<McpSchema.Tool>> listTools()
列出工具。
Lists tools available from the Higress gateway.
Mono<List<McpSchema.Tool>>io/agentscope/extensions/higress/HigressMcpClientWrapper.java:155–205callTool
public Mono<McpSchema.CallToolResult> callTool(String toolName, Map<String, Object> arguments)
调用工具。
Invokes a tool on the Higress gateway.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
toolName | String | 工具到调用的名称。the name of the tool to call |
arguments | Map<String, Object> | 参数(类型 `Map`)。the arguments to pass to the tool |
Mono<McpSchema.CallToolResult>io/agentscope/extensions/higress/HigressMcpClientWrapper.java:260–263callTool
public Mono<McpSchema.CallToolResult> callTool(String toolName, Map<String, Object> arguments, Map<String, Object> meta)
调用工具。
Calls the tool.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
toolName | String | 工具名称(类型 `String`)。The tool name. |
arguments | Map<String, Object> | 参数(类型 `Map`)。The arguments. |
meta | Map<String, Object> | 元数据(类型 `Map`)。The meta. |
Mono<McpSchema.CallToolResult>io/agentscope/extensions/higress/HigressMcpClientWrapper.java:265–293close
public void close()
关闭连接并释放相关资源。
Closes the Higress MCP client and releases all resources.
io/agentscope/extensions/higress/HigressMcpClientWrapper.java:300–315isToolSearchEnabled
public boolean isToolSearchEnabled()
检查if x_Higress_工具_搜索模式是已启用 in 此客户端。
Checks if x_higress_tool_search mode is enabled in this client.
booleanio/agentscope/extensions/higress/HigressMcpClientWrapper.java:325–327searchTools
public Mono<HigressToolSearchResult> searchTools(String query)
搜索工具。
Searches for tools matching the query and returns parsed result.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
query | String | 查询文本(类型 `String`)。the user query to find matching tools (required) |
Mono<HigressToolSearchResult>io/agentscope/extensions/higress/HigressMcpClientWrapper.java:338–341searchTools
public Mono<HigressToolSearchResult> searchTools(String query, int topK)
搜索工具。
Searches for tools matching the query with topK limit.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
query | String | 查询文本(类型 `String`)。the user query to find matching tools (required) |
topK | int | top K(类型 `int`)。the maximum number of tools to return |
Mono<HigressToolSearchResult>io/agentscope/extensions/higress/HigressMcpClientWrapper.java:350–353