Class SpiToolRegistry
- All Implemented Interfaces:
ToolRegistry
ToolRegistry that discovers tool sources from the classpath via
ServiceLoader. Two SPIs are consulted in order:
ToolFactory— strictly 1:1 with a tool name. Existing built-ins (file/web/document/etc.) register this way and are unchanged.MultiToolProvider— contributes multiple names from one registration. Used for MCP bundles (e.g. all Gmail sub-tools share one provider and one cached connection), for built-in bundles that want to share resources, and for dynamic sources such as persisted workflows.
Provider names are resolved live: knownToolNames() and
resolve(ai.mindconnect.agent.tool.AgentTool, ai.mindconnect.common.Namespace, java.lang.String, java.util.UUID) ask each provider for its current toolNames() on
every call, so a provider backed by mutable data (a workflow store, a
remote catalog) surfaces additions and removals without a restart. Only
the provider set is fixed at construction (ServiceLoader scan).
ToolFactory wins on name collisions to keep behavior stable
during the gradual migration from single- to multi-tool registration;
between providers, the first registered provider claiming a name wins.
Adding a new tool source is purely additive: implement the SPI, list it
in META-INF/services/...ToolFactory or
META-INF/services/...MultiToolProvider. No runtime code change.
-
Constructor Summary
ConstructorsConstructorDescriptionSpiToolRegistry(ToolEnvironment environment) SpiToolRegistry(ToolEnvironment environment, ClassLoader classLoader) -
Method Summary
Modifier and TypeMethodDescriptionNames of all tools known to this registry.overridesSchema(String toolName) The config-overrides schema a tool declares (ToolFactory.overridesSchema()), so admin UIs can show which override keys a tool supports.Every resolvable tool name, grouped by its rubric (ToolFactory.group()/MultiToolProvider.group()) — for catalogs and pickers that present tools by category (agent functions, web tools, document tools, …).Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ai.mindconnect.agent.tool.ToolRegistry
resolveAll
-
Constructor Details
-
SpiToolRegistry
-
SpiToolRegistry
-
-
Method Details
-
knownToolNames
Description copied from interface:ToolRegistryNames of all tools known to this registry. Used by admin UIs to render a selection dropdown when configuring an agent's tool list. Order is deterministic (typically registration order). Default: empty for registries that don't enumerate.- Specified by:
knownToolNamesin interfaceToolRegistry
-
toolNamesByGroup
Description copied from interface:ToolRegistryEvery resolvable tool name, grouped by its rubric (ToolFactory.group()/MultiToolProvider.group()) — for catalogs and pickers that present tools by category (agent functions, web tools, document tools, …). Groups and names are sorted; likeToolRegistry.knownToolNames()the view reflects the registry's current state. Default: everything under "General".- Specified by:
toolNamesByGroupin interfaceToolRegistry
-
overridesSchema
Description copied from interface:ToolRegistryThe config-overrides schema a tool declares (ToolFactory.overridesSchema()), so admin UIs can show which override keys a tool supports. Empty for tools that declare none (e.g. MCP tools, whose knobs are all parameters).- Specified by:
overridesSchemain interfaceToolRegistry
-
resolve
public Optional<Tool> resolve(AgentTool agentTool, Namespace namespace, String userId, UUID sessionId) - Specified by:
resolvein interfaceToolRegistry
-