Class ToolSet

All Implemented Interfaces:
Serializable, Cloneable, Iterable<String>, Collection<String>, List<String>, RandomAccess

public class ToolSet extends ArrayList<String>
Builder for SessionConfig.setAvailableTools(java.util.List) / SessionConfig.setExcludedTools(java.util.List) using source-qualified filter patterns (builtin:*, mcp:<name>, custom:*, etc.).

Tools are classified by the runtime at registration time (not from name parsing), so addBuiltIn(String) matches only tools the runtime registered as built-in, even if an MCP server or custom-agent extension happens to register a tool with the same wire name.

ToolSet extends ArrayList so instances can be passed directly to SessionConfig.setAvailableTools(java.util.List) or SessionConfig.setExcludedTools(java.util.List).

Example


 var session = client
 		.createSession(new SessionConfig()
 				.setAvailableTools(new ToolSet().addBuiltIn(BuiltInTools.ISOLATED).addMcp("*").addCustom("*")))
 		.get();
 
Since:
1.3.0
See Also:
  • Constructor Details

    • ToolSet

      public ToolSet()
  • Method Details

    • addBuiltIn

      public ToolSet addBuiltIn(String name)
      Adds a built-in tool pattern.
      Parameters:
      name - a specific built-in tool name (e.g. "bash") or "*" to match all built-in tools
      Returns:
      this ToolSet for chaining
      Throws:
      IllegalArgumentException - if name is null, empty, or contains invalid characters
    • addBuiltIn

      public ToolSet addBuiltIn(Collection<String> names)
      Adds a list of built-in tool patterns (e.g. BuiltInTools.ISOLATED).
      Parameters:
      names - built-in tool names to add
      Returns:
      this ToolSet for chaining
      Throws:
      NullPointerException - if names is null
    • addCustom

      public ToolSet addCustom(String name)
      Adds a custom tool pattern. Matches tools registered via the SDK's SessionConfig.setTools(java.util.List) option or via custom agents.
      Parameters:
      name - a specific custom tool name or "*" to match all custom tools
      Returns:
      this ToolSet for chaining
      Throws:
      IllegalArgumentException - if name is null, empty, or contains invalid characters
    • addMcp

      public ToolSet addMcp(String toolName)
      Adds an MCP tool pattern. Matches tools advertised by any configured MCP server.
      Parameters:
      toolName - the runtime's canonical wire name for the MCP tool (e.g. "github-list_issues"), or "*" to match all MCP tools from any server
      Returns:
      this ToolSet for chaining
      Throws:
      IllegalArgumentException - if toolName is null, empty, or contains invalid characters