- All Implemented Interfaces:
Serializable,Cloneable,Iterable<String>,Collection<String>,List<String>,RandomAccess
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddBuiltIn(String name) Adds a built-in tool pattern.addBuiltIn(Collection<String> names) Adds a list of built-in tool patterns (e.g.Adds a custom tool pattern.Adds an MCP tool pattern.Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, equals, forEach, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSizeMethods inherited from class java.util.AbstractCollection
containsAll, toStringMethods inherited from interface java.util.Collection
parallelStream, stream, toArrayMethods inherited from interface java.util.List
containsAll
-
Constructor Details
-
ToolSet
public ToolSet()
-
-
Method Details
-
addBuiltIn
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
ToolSetfor chaining - Throws:
IllegalArgumentException- if name is null, empty, or contains invalid characters
-
addBuiltIn
Adds a list of built-in tool patterns (e.g.BuiltInTools.ISOLATED).- Parameters:
names- built-in tool names to add- Returns:
- this
ToolSetfor chaining - Throws:
NullPointerException- if names is null
-
addCustom
Adds a custom tool pattern. Matches tools registered via the SDK'sSessionConfig.setTools(java.util.List)option or via custom agents.- Parameters:
name- a specific custom tool name or"*"to match all custom tools- Returns:
- this
ToolSetfor chaining - Throws:
IllegalArgumentException- if name is null, empty, or contains invalid characters
-
addMcp
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
ToolSetfor chaining - Throws:
IllegalArgumentException- if toolName is null, empty, or contains invalid characters
-