AS AgentScopeAPI 手册 / API Reference

HigressMcpClientWrapper

public class HigressMcpClientWrapper extends McpClientWrapper
源码Source io/agentscope/extensions/higress/HigressMcpClientWrapper.java:57–354

Higress 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_NAME
staticfinal
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
staticfinal

工具搜索名称字段。声明为 public static final String TOOL_SEARCH_NAME。

The name of the Higress tool search tool.

源码Source io/agentscope/extensions/higress/HigressMcpClientWrapper.java:64

方法详情Method Detail

initialize

public Mono<Void> initialize()

初始化 HigressMcpClientWrapper 实例。

Initializes the Higress MCP client connection.

返回Returns Mono<Void>
返回Mono。a Mono that completes when initialization is finished
源码Source io/agentscope/extensions/higress/HigressMcpClientWrapper.java:116–139

listTools

public Mono<List<McpSchema.Tool>> listTools()

列出工具。

Lists tools available from the Higress gateway.

返回Returns Mono<List<McpSchema.Tool>>
返回Mono>。a Mono emitting the list of available tools
源码Source io/agentscope/extensions/higress/HigressMcpClientWrapper.java:155–205

callTool

public Mono<McpSchema.CallToolResult> callTool(String toolName, Map<String, Object> arguments)

调用工具。

Invokes a tool on the Higress gateway.

参数Parameters
名称Name类型Type说明Description
toolNameString工具到调用的名称。the name of the tool to call
argumentsMap<String, Object>参数(类型 `Map`)。the arguments to pass to the tool
返回Returns Mono<McpSchema.CallToolResult>
返回Mono。a Mono emitting the tool call result
源码Source io/agentscope/extensions/higress/HigressMcpClientWrapper.java:260–263

callTool

public Mono<McpSchema.CallToolResult> callTool(String toolName, Map<String, Object> arguments, Map<String, Object> meta)

调用工具。

Calls the tool.

参数Parameters
名称Name类型Type说明Description
toolNameString工具名称(类型 `String`)。The tool name.
argumentsMap<String, Object>参数(类型 `Map`)。The arguments.
metaMap<String, Object>元数据(类型 `Map`)。The meta.
返回Returns Mono<McpSchema.CallToolResult>
返回Mono。Returns mono.
源码Source io/agentscope/extensions/higress/HigressMcpClientWrapper.java:265–293

close

public void close()

关闭连接并释放相关资源。

Closes the Higress MCP client and releases all resources.

源码Source io/agentscope/extensions/higress/HigressMcpClientWrapper.java:300–315

isToolSearchEnabled

public boolean isToolSearchEnabled()

检查if x_Higress_工具_搜索模式是已启用 in 此客户端。

Checks if x_higress_tool_search mode is enabled in this client.

返回Returns boolean
返回布尔值,表示判断结果。true if tool search mode is enabled
源码Source io/agentscope/extensions/higress/HigressMcpClientWrapper.java:325–327

searchTools

public Mono<HigressToolSearchResult> searchTools(String query)

搜索工具。

Searches for tools matching the query and returns parsed result.

参数Parameters
名称Name类型Type说明Description
queryString查询文本(类型 `String`)。the user query to find matching tools (required)
返回Returns Mono<HigressToolSearchResult>
返回Mono。a Mono emitting the parsed tool search result
源码Source io/agentscope/extensions/higress/HigressMcpClientWrapper.java:338–341

searchTools

public Mono<HigressToolSearchResult> searchTools(String query, int topK)

搜索工具。

Searches for tools matching the query with topK limit.

参数Parameters
名称Name类型Type说明Description
queryString查询文本(类型 `String`)。the user query to find matching tools (required)
topKinttop K(类型 `int`)。the maximum number of tools to return
返回Returns Mono<HigressToolSearchResult>
返回Mono。a Mono emitting the parsed tool search result
源码Source io/agentscope/extensions/higress/HigressMcpClientWrapper.java:350–353

继承成员Inherited Members

基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.