MCPTool
public class MCPTool extends SandboxTool
源码Source
io/agentscope/runtime/sandbox/tools/MCPTool.java:26–105MCP 工具,封装可被智能体调用的能力。位于 io.agentscope.runtime.sandbox.tools 包,继承自 SandboxTool。核心成员包括 getServerConfigs、setServerConfigs、executeMCPTool、getSandboxClass、bind、MCPTool。
A class in io.agentscope.runtime.sandbox.tools that lets agents invoke external capabilities under control. Declared in io.agentscope.runtime.sandbox.tools. Extends SandboxTool.
构造器摘要Constructor Summary
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public Map<String, Object> getServerConfigs() | 获取 `getServerConfigs`。 Returns the server configs. |
public void setServerConfigs(Map<String, Object> serverConfigs) | 设置 `setServerConfigs`。 Sets the server configs. |
public String executeMCPTool(Map<String, Object> arguments) | 执行MCP 工具。 Executes the MCP tool. |
public Class<? extends Sandbox> getSandboxClass() | 获取沙箱类。 Returns the sandbox class. |
public MCPTool bind(Sandbox sandbox) | 设置该参数。 Performs the bind operation. |
构造器详情Constructor Detail
MCPTool
public MCPTool(String name, String toolType, String description, Map<String, Object> schema, Map<String, Object> serverConfigs, String sandboxType)
初始化 MCPTool 实例。
Creates a new instance.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
name | String | 名称(类型 `String`)。The name. |
toolType | String | 工具类型(类型 `String`)。The tool type. |
description | String | 描述(类型 `String`)。The description. |
schema | Map<String, Object> | 模式定义(类型 `Map`)。The schema. |
serverConfigs | Map<String, Object> | 服务端 Configs(类型 `Map`)。The server configs. |
sandboxType | String | 沙箱类型(类型 `String`)。The sandbox type. |
源码Source
io/agentscope/runtime/sandbox/tools/MCPTool.java:34–42MCPTool
public MCPTool(String name, String toolType, String description, Map<String, Object> schema, Map<String, Object> serverConfigs, String sandboxType, SandboxService sandboxService)
初始化 MCPTool 实例。
Creates a new instance.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
name | String | 名称(类型 `String`)。The name. |
toolType | String | 工具类型(类型 `String`)。The tool type. |
description | String | 描述(类型 `String`)。The description. |
schema | Map<String, Object> | 模式定义(类型 `Map`)。The schema. |
serverConfigs | Map<String, Object> | 服务端 Configs(类型 `Map`)。The server configs. |
sandboxType | String | 沙箱类型(类型 `String`)。The sandbox type. |
sandboxService | SandboxService | 沙箱服务(类型 `SandboxService`)。The sandbox service. |
源码Source
io/agentscope/runtime/sandbox/tools/MCPTool.java:44–52方法详情Method Detail
getServerConfigs
public Map<String, Object> getServerConfigs()
获取 getServerConfigs。
Returns the server configs.
Map<String, Object>返回映射。Returns map.
源码Source
io/agentscope/runtime/sandbox/tools/MCPTool.java:54–56setServerConfigs
public void setServerConfigs(Map<String, Object> serverConfigs)
设置 setServerConfigs。
Sets the server configs.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
serverConfigs | Map<String, Object> | 服务端 Configs(类型 `Map`)。The server configs. |
源码Source
io/agentscope/runtime/sandbox/tools/MCPTool.java:58–65executeMCPTool
public String executeMCPTool(Map<String, Object> arguments)
执行MCP 工具。
Executes the MCP tool.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
arguments | Map<String, Object> | 参数(类型 `Map`)。The arguments. |
String返回字符串结果。Returns a string.
源码Source
io/agentscope/runtime/sandbox/tools/MCPTool.java:67–80getSandboxClass
public Class<? extends Sandbox> getSandboxClass()
获取沙箱类。
Returns the sandbox class.
Class<? extends Sandbox>返回类。Returns class.
源码Source
io/agentscope/runtime/sandbox/tools/MCPTool.java:82–85bind
public MCPTool bind(Sandbox sandbox)
设置该参数。
Performs the bind operation.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sandbox | Sandbox | 沙箱(类型 `Sandbox`)。The sandbox. |
MCPTool返回MCPTool。Returns MCP tool.
源码Source
io/agentscope/runtime/sandbox/tools/MCPTool.java:87–103