Class DefaultToolRegistry

java.lang.Object
dev.tachyonmcp.core.server.features.AbstractRegistry<ToolDescriptor,ToolHandler>
dev.tachyonmcp.core.server.features.tools.DefaultToolRegistry
All Implemented Interfaces:
Tools, ToolRegistry

@InternalApi public class DefaultToolRegistry extends AbstractRegistry<ToolDescriptor,ToolHandler> implements ToolRegistry
AbstractRegistry for tool handlers with input/output schema validation.
  • Field Details

    • MAX_DESCRIPTION_LENGTH

      public static final int MAX_DESCRIPTION_LENGTH
      Maximum description length before a warning is logged. MCP clients may truncate descriptions beyond this length.
      See Also:
  • Constructor Details

    • DefaultToolRegistry

      public DefaultToolRegistry(JsonSchemaFactory<String> schemaFactory, FeatureConfig config)
      Creates a tool registry with the given schema validators and payload serde.
  • Method Details

    • register

      public Tools register(ToolDescriptor descriptor, ToolFn fn)
      Description copied from interface: Tools
      Registers a tool descriptor with a synchronous function.
      Specified by:
      register in interface Tools
      Parameters:
      descriptor - the tool descriptor
      fn - the tool function
      Returns:
      this registry
    • registerAsync

      public Tools registerAsync(ToolDescriptor descriptor, AsyncToolFn fn)
      Description copied from interface: Tools
      Registers a tool descriptor with an asynchronous function.
      Specified by:
      registerAsync in interface Tools
      Parameters:
      descriptor - the tool descriptor
      fn - the asynchronous tool function
      Returns:
      this registry
    • unregister

      public boolean unregister(String name)
      Removes the registered tool with the specified name.
      Specified by:
      unregister in interface Tools
      Parameters:
      name - the name of the tool to remove
      Returns:
      true if a tool was removed, false otherwise
    • find

      public Optional<ToolDescriptor> find(String name)
      Finds the descriptor for a registered tool by name.
      Specified by:
      find in interface Tools
      Parameters:
      name - the tool name to find
      Returns:
      the tool descriptor if registered, or an empty optional otherwise
    • descriptors

      public List<ToolDescriptor> descriptors()
      Retrieves all registered tool descriptors in name order.
      Specified by:
      descriptors in interface Tools
      Returns:
      the registered tool descriptors sorted by name