ToolRegistration
public static class ToolRegistration
io/agentscope/core/tool/Toolkit.java:981–1281工具注册,让智能体以受控方式调用外部能力。位于 io.agentscope.core.tool 包。核心成员包括 tool、agentTool、mcpClient、subAgent、mcpToolNamePrefix、enableTools。
Fluent builder for registering tools with optional configuration.
This builder provides a clear, type-safe way to register tools with various options without method proliferation.
方法摘要Method Summary
方法详情Method Detail
tool
public ToolRegistration tool(Object toolObject)
设置工具。
Set the tool object to register (scans for @Tool methods).
| 名称Name | 类型Type | 说明Description |
|---|---|---|
toolObject | Object | 工具对象(类型 `Object`)。Object containing @Tool annotated methods |
ToolRegistrationio/agentscope/core/tool/Toolkit.java:1007–1010agentTool
public ToolRegistration agentTool(AgentTool agentTool)
设置AgentTool 实例到注册。
Set the AgentTool instance to register.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
agentTool | AgentTool | AgentTool 实例。The AgentTool instance |
ToolRegistrationio/agentscope/core/tool/Toolkit.java:1018–1021mcpClient
public ToolRegistration mcpClient(McpClientWrapper mcpClientWrapper)
设置MCP 客户端到注册。
Set the MCP client to register.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
mcpClientWrapper | McpClientWrapper | MCP 客户端包装器。The MCP client wrapper |
ToolRegistrationio/agentscope/core/tool/Toolkit.java:1029–1032subAgent
public ToolRegistration subAgent(SubAgentProvider<?> provider)
设置子智能体。
Register a sub-agent as a tool with default configuration.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
provider | SubAgentProvider<?> | 提供者(类型 `SubAgentProvider`)。Factory for creating agent instances (called for each invocation) |
ToolRegistrationio/agentscope/core/tool/Toolkit.java:1054–1056subAgent
public ToolRegistration subAgent(SubAgentProvider<?> provider, SubAgentConfig config)
执行子智能体相关操作。
Register a sub-agent as a tool with custom configuration.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
provider | SubAgentProvider<?> | 提供者(类型 `SubAgentProvider`)。Factory for creating agent instances (called for each session) |
config | SubAgentConfig | 配置对象(类型 `SubAgentConfig`)。Configuration for the sub-agent tool, or null to use defaults (tool name derived from agent name, InMemoryAgentStateStore for state, events forwarded) |
ToolRegistrationio/agentscope/core/tool/Toolkit.java:1098–1102mcpToolNamePrefix
public ToolRegistration mcpToolNamePrefix(String prefix)
设置该参数。
Optional namespace for model-facing MCP tool names; wire names remain unchanged.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
prefix | String | prefix(类型 `String`)。The prefix. |
ToolRegistrationio/agentscope/core/tool/Toolkit.java:1105–1108enableTools
public ToolRegistration enableTools(List<String> enableTools)
启用工具。
Selects remote tool names; an absent or empty list enables all tools.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
enableTools | List<String> | 启用工具(类型 `List`)。The enable tools. |
ToolRegistrationio/agentscope/core/tool/Toolkit.java:1111–1114disableTools
public ToolRegistration disableTools(List<String> disableTools)
设置列出的工具到禁用来自 MCP 客户端。
Set the list of tools to disable from the MCP client.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
disableTools | List<String> | 禁用工具(类型 `List`)。List of tool names to disable |
ToolRegistrationio/agentscope/core/tool/Toolkit.java:1124–1127propagateMeta
public ToolRegistration propagateMeta(boolean propagateMeta)
设置该参数。
Controls whether request metadata is propagated to the MCP server registered through this builder.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
propagateMeta | boolean | propagate 元数据(类型 `boolean`)。true to propagate metadata, false to omit the `meta` field entirely from tool call requests |
ToolRegistrationio/agentscope/core/tool/Toolkit.java:1148–1151propagateMeta
public ToolRegistration propagateMeta(String toolName, boolean propagateMeta)
执行 propagateMeta 方法。
Controls request metadata propagation for a single MCP tool of this client.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
toolName | String | 远程 MCP 工具名称。the remote MCP tool name |
propagateMeta | boolean | propagate 元数据(类型 `boolean`)。true to allow metadata propagation for this tool, false to omit the `meta` field from this tool's requests |
ToolRegistrationIllegalArgumentException可能抛出 `IllegalArgumentException`。if `toolName` is `null` or blank
io/agentscope/core/tool/Toolkit.java:1179–1185group
public ToolRegistration group(String groupName)
设置工具组名称。
Set the tool group name.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
groupName | String | 组名称(类型 `String`)。The group name (null for ungrouped) |
ToolRegistrationio/agentscope/core/tool/Toolkit.java:1193–1196presetParameters
public ToolRegistration presetParameters(Map<String, Map<String, Object>> presetParameters)
设置该参数。
Set preset parameters that will be automatically injected during tool execution.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
presetParameters | Map<String, Map<String, Object>> | preset 参数(类型 `Map >`)。Map from tool name to its preset parameters |
ToolRegistrationio/agentscope/core/tool/Toolkit.java:1214–1218extendedModel
public ToolRegistration extendedModel(ExtendedModel extendedModel)
设置该参数。
Set the extended model for dynamic schema extension.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
extendedModel | ExtendedModel | extended 模型(类型 `ExtendedModel`)。The extended model |
ToolRegistrationio/agentscope/core/tool/Toolkit.java:1226–1229apply
public void apply()
执行 apply 方法。
Apply the registration with all configured options.
IllegalStateException可能抛出 `IllegalStateException`。if set multiple of: tool(), agentTool(), mcpClient(), or subAgent().
io/agentscope/core/tool/Toolkit.java:1237–1280