Package ai.mindconnect.agent.tool
Interface MultiToolProvider
public interface MultiToolProvider
SPI for tool sources that contribute multiple tool names from a
single registration — complement to
ToolFactory (which is strictly
1:1 with a name).
Use cases:
- An MCP-server adapter that exposes a fixed bundle of sub-tools
(e.g.
gmail_search_messages,gmail_read_message,gmail_send_message) sharing one underlying connection. - Built-in tool bundles where several related tools share resources and want one place to manage them.
- Dynamic sources whose tool set changes at runtime — e.g. persisted workflows, where every workflow in the store is one tool.
Discovery: standard ServiceLoader, with
META-INF/services/ai.mindconnect.agent.tool.MultiToolProvider
listing one FQN per line, exactly like ToolFactory.
Lifecycle is symmetric to ToolFactory:
- The runtime instantiates the provider via its public no-arg constructor.
bind(ToolEnvironment)is invoked once; the provider captures only the dependencies it needs.isAvailable()decides whether the provider participates at all (e.g. credentials missing → the whole bundle disappears).- For each agent-configured tool the runtime calls
create(String, AgentTool, ToolCallScope)to build a freshToolinstance.
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidbind(ToolEnvironment env) Optional capture of runtime dependencies; default is a no-op.create(String toolName, AgentTool agentTool, ToolCallScope scope) Build a tool for the given name.default Stringgroup()The provider's group — both the rubric under which its tools appear in catalogs/pickers and the machine namespace its tool names live in: by convention a provider's tool names compose asgroup() + "_" + localName(group"workflow", workflow"pipeline"→ tool"workflow_pipeline"; group"gmail"→"gmail_search_messages").default booleanFalse disables the entire bundle — neithertoolNames()norcreate(java.lang.String, ai.mindconnect.agent.tool.AgentTool, ai.mindconnect.agent.tool.ToolCallScope)will be honored by the registry.Tool names this provider serves right now.
-
Method Details
-
toolNames
Tool names this provider serves right now. The registry consults this on every lookup (ToolRegistry.knownToolNames()aggregation, the admin UI dropdown, and name→provider resolution), so the returned set may change over the provider's lifetime — a provider backed by mutable data should re-read its source here rather than caching atbind(ai.mindconnect.agent.tool.ToolEnvironment). Keep it cheap (an in-memory map or a directory listing, not a network round-trip per call) and its order stable. -
group
The provider's group — both the rubric under which its tools appear in catalogs/pickers and the machine namespace its tool names live in: by convention a provider's tool names compose asgroup() + "_" + localName(group"workflow", workflow"pipeline"→ tool"workflow_pipeline"; group"gmail"→"gmail_search_messages"). Lowercase; UIs capitalize for display. Default"general". -
bind
Optional capture of runtime dependencies; default is a no-op. -
isAvailable
default boolean isAvailable()False disables the entire bundle — neithertoolNames()norcreate(java.lang.String, ai.mindconnect.agent.tool.AgentTool, ai.mindconnect.agent.tool.ToolCallScope)will be honored by the registry. Defaulttrue. -
create
Build a tool for the given name. ReturnsOptional.empty()if the name is not served by this provider; the registry then continues with the next provider.
-