类 McpTool
- 所有已实现的接口:
AgentTool
ToolBase subclass that wraps an MCP (Model Context Protocol) tool.
Bridges remote MCP tools to the AgentScope tool system so they participate in permission
evaluation and the agent's pending-confirmation flow alongside built-in and @Tool tools.
Features:
- Translates AgentScope tool calls into MCP protocol calls.
- Merges caller arguments with preset arguments configured at registration time.
- Converts MCP results into AgentScope
ToolResultBlocks. - Surfaces permission policy via
checkPermissions(Map, PermissionContextState): read-only MCP tools auto-allow; everything else requires explicit user authorization (matches the PythonMCPTooldefault).
-
嵌套类概要
从类继承的嵌套类/接口 io.agentscope.core.tool.ToolBase
ToolBase.Builder -
字段概要
从类继承的字段 io.agentscope.core.tool.ToolBase
dangerousDirectories, dangerousFiles -
构造器概要
构造器构造器说明McpTool(String name, String description, Map<String, Object> parameters, McpClientWrapper clientWrapper) 已过时。McpTool(String name, String description, Map<String, Object> parameters, McpClientWrapper clientWrapper, Map<String, Object> presetArguments) 已过时。UseMcpTool(String, String, Map, Map, McpClientWrapper, Map, String, boolean)so the MCP server name and read-only hint are propagated.McpTool(String name, String description, Map<String, Object> parameters, Map<String, Object> outputSchema, McpClientWrapper clientWrapper, Map<String, Object> presetArguments) 已过时。UseMcpTool(String, String, Map, Map, McpClientWrapper, Map, String, boolean)so the MCP server name and read-only hint are propagated.McpTool(String name, String description, Map<String, Object> parameters, Map<String, Object> outputSchema, McpClientWrapper clientWrapper, Map<String, Object> presetArguments, String mcpName, boolean readOnly) Preferred constructor used byMcpClientManager. -
方法概要
修饰符和类型方法说明reactor.core.publisher.Mono<ToolResultBlock> callAsync(ToolCallParam param) Executes this MCP tool asynchronously with the given parameters.reactor.core.publisher.Mono<PermissionDecision> checkPermissions(Map<String, Object> toolInput, PermissionContextState context) Tool self-check invoked by the permission engine whenallowRules/askRulesneither allow nor reject the call outright.convertMcpSchemaToParameters(io.modelcontextprotocol.spec.McpSchema.JsonSchema inputSchema, Set<String> excludeParams) Converts MCP JsonSchema to AgentScope parameters format.Gets the name of the MCP client that provides this tool.Gets the optional output schema for this tool in JSON Schema format.Gets the preset arguments configured for this tool.从类继承的方法 io.agentscope.core.tool.ToolBase
builder, generateSuggestions, getDescription, getMcpName, getName, getParameters, isConcurrencySafe, isDangerousPath, isExternalTool, isMcp, isReadOnly, isStateInjected, matchRule
-
构造器详细资料
-
McpTool
public McpTool(String name, String description, Map<String, Object> parameters, Map<String, Object> outputSchema, McpClientWrapper clientWrapper, Map<String, Object> presetArguments, String mcpName, boolean readOnly) Preferred constructor used byMcpClientManager. -
McpTool
@Deprecated(since="2.0.0") public McpTool(String name, String description, Map<String, Object> parameters, McpClientWrapper clientWrapper) 已过时。UseMcpTool(String, String, Map, Map, McpClientWrapper, Map, String, boolean)so the MCP server name and read-only hint are propagated. Kept for source compatibility with callers that pre-date theToolBaseintegration. -
McpTool
@Deprecated(since="2.0.0") public McpTool(String name, String description, Map<String, Object> parameters, McpClientWrapper clientWrapper, Map<String, Object> presetArguments) 已过时。UseMcpTool(String, String, Map, Map, McpClientWrapper, Map, String, boolean)so the MCP server name and read-only hint are propagated. -
McpTool
@Deprecated(since="2.0.0") public McpTool(String name, String description, Map<String, Object> parameters, Map<String, Object> outputSchema, McpClientWrapper clientWrapper, Map<String, Object> presetArguments) 已过时。UseMcpTool(String, String, Map, Map, McpClientWrapper, Map, String, boolean)so the MCP server name and read-only hint are propagated.
-
-
方法详细资料
-
getOutputSchema
从接口复制的说明:AgentToolGets the optional output schema for this tool in JSON Schema format.Most tools do not expose a structured output schema to models, so the default implementation returns
null. MCP tools can override this to surface the server-providedoutputSchemadefinition.- 返回:
- Map representing the JSON Schema for tool outputs, or null if unsupported
-
checkPermissions
public reactor.core.publisher.Mono<PermissionDecision> checkPermissions(Map<String, Object> toolInput, PermissionContextState context) 从类复制的说明:ToolBaseTool self-check invoked by the permission engine whenallowRules/askRulesneither allow nor reject the call outright.The default implementation returns
PermissionDecision.passthrough(String), delegating the decision to the engine's rule tables and mode defaults. Tools with fine-grained semantics (Bash, file writers, MCP tools) should override this to surface their own ALLOW / ASK / DENY policy.- 覆盖:
checkPermissions在类中ToolBase- 参数:
toolInput- the parsed tool argumentscontext- current permission evaluation context- 返回:
- a Mono emitting the decision; never
null
-
callAsync
Executes this MCP tool asynchronously with the given parameters.This method merges any preset arguments with the input arguments (input takes precedence), calls the remote MCP tool via the client wrapper, and converts the result to a
ToolResultBlock. If an error occurs, it returns an error result instead of failing. -
getClientName
Gets the name of the MCP client that provides this tool.- 返回:
- the MCP client name
-
getPresetArguments
Gets the preset arguments configured for this tool.- 返回:
- the preset arguments, or null if none configured
-
convertMcpSchemaToParameters
public static Map<String,Object> convertMcpSchemaToParameters(io.modelcontextprotocol.spec.McpSchema.JsonSchema inputSchema, Set<String> excludeParams) Converts MCP JsonSchema to AgentScope parameters format.- 参数:
inputSchema- the MCP JsonSchema- 返回:
- parameters map in AgentScope format
-
McpTool(String, String, Map, Map, McpClientWrapper, Map, String, boolean)so the MCP server name and read-only hint are propagated.