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:

  1. The runtime instantiates the provider via its public no-arg constructor.
  2. bind(ToolEnvironment) is invoked once; the provider captures only the dependencies it needs.
  3. isAvailable() decides whether the provider participates at all (e.g. credentials missing → the whole bundle disappears).
  4. For each agent-configured tool the runtime calls create(String, AgentTool, ToolCallScope) to build a fresh Tool instance.
  • Method Details

    • toolNames

      Set<String> 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 at bind(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

      default String 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 as group() + "_" + localName (group "workflow", workflow "pipeline" → tool "workflow_pipeline"; group "gmail" → "gmail_search_messages"). Lowercase; UIs capitalize for display. Default "general".
    • bind

      default void bind(ToolEnvironment env)
      Optional capture of runtime dependencies; default is a no-op.
    • isAvailable

      default boolean isAvailable()
      False disables the entire bundle — neither toolNames() nor create(java.lang.String, ai.mindconnect.agent.tool.AgentTool, ai.mindconnect.agent.tool.ToolCallScope) will be honored by the registry. Default true.
    • create

      Optional<Tool> create(String toolName, AgentTool agentTool, ToolCallScope scope)
      Build a tool for the given name. Returns Optional.empty() if the name is not served by this provider; the registry then continues with the next provider.