Record Class ToolAccessConfig
java.lang.Object
java.lang.Record
eu.mrapik.minecraftservermcp.config.ToolAccessConfig
- Record Components:
enabled- whether the tool is active for this profilefileWhitelist- optional file path patterns;nullmeans no whitelist rulefileBlacklist- optional file path patternsfolderWhitelist- optional folder prefixesfolderBlacklist- optional folder prefixescommandWhitelist- optional root command names (lowercase)commandBlacklist- optional root command names (lowercase)extra- custom keys copied from YAML
public record ToolAccessConfig(boolean enabled, @Nullable List<String> fileWhitelist, @Nullable List<String> fileBlacklist, @Nullable List<String> folderWhitelist, @Nullable List<String> folderBlacklist, @Nullable List<String> commandWhitelist, @Nullable List<String> commandBlacklist, Map<String,Object> extra)
extends Record
Policy for a single MCP tool id under
access.<profile>.tools.<toolId>.
Built-in tools and resources use the list fields: file and folder white/blacklists for filesystem policy keys
(fs_read, fs_list, fs_write), and command lists for server_command. Lists are
optional; see FilesystemPolicy and CommandPolicy for semantics.
Custom tools may add arbitrary keys; anything not in KNOWN_KEYS is stored in extra() so handlers
can read plugin-specific options without changing this class.
If there is no YAML section for a given tool id, TokenAccessProfile.toolConfig(String) returns
permissiveDefault(): enabled, no filters, empty extra.
-
Constructor Summary
ConstructorsConstructorDescriptionToolAccessConfig(boolean enabled, @Nullable List<String> fileWhitelist, @Nullable List<String> fileBlacklist, @Nullable List<String> folderWhitelist, @Nullable List<String> folderBlacklist, @Nullable List<String> commandWhitelist, @Nullable List<String> commandBlacklist, Map<String, Object> extra) Canonical constructor; stores an unmodifiable copy ofextra. -
Method Summary
Modifier and TypeMethodDescriptionOptional console command deny list (root command names).Optional console command allow list (root command names).booleanenabled()Global enable flag for this tool under the profile.final booleanIndicates whether some other object is "equal to" this one.extra()Custom configuration entries not mapped to built-in fields.Optional file path deny list for filesystem tools.Optional file path allow list for filesystem tools.Optional folder prefix deny list for filesystem tools.Optional folder prefix allow list for filesystem tools.static ToolAccessConfigfromSection(@Nullable ConfigurationSection sec) Parses a configuration section.final inthashCode()Returns a hash code value for this object.static ToolAccessConfigUsed when a profile defines notools.<id>section: tool allowed, lists unset (no restriction from lists).final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
ToolAccessConfig
public ToolAccessConfig(boolean enabled, @Nullable @Nullable List<String> fileWhitelist, @Nullable @Nullable List<String> fileBlacklist, @Nullable @Nullable List<String> folderWhitelist, @Nullable @Nullable List<String> folderBlacklist, @Nullable @Nullable List<String> commandWhitelist, @Nullable @Nullable List<String> commandBlacklist, Map<String, Object> extra) Canonical constructor; stores an unmodifiable copy ofextra.
-
-
Method Details
-
permissiveDefault
Used when a profile defines notools.<id>section: tool allowed, lists unset (no restriction from lists).- Returns:
- enabled config with all lists null and empty
extra
-
fromSection
Parses a configuration section. Known keys (enabled, file/folder/command list keys) map to typed fields; any other keys are copied intoextra().- Parameters:
sec- YAML section under a tool id, or null for default- Returns:
- parsed policy, or
permissiveDefault()whensecis null
-
enabled
public boolean enabled()Global enable flag for this tool under the profile.- Returns:
- whether invocations for this tool id are allowed (before list checks)
-
fileWhitelist
Optional file path allow list for filesystem tools.- Returns:
- file allow list, or null if unset in YAML
-
fileBlacklist
Optional file path deny list for filesystem tools.- Returns:
- file deny list, or null if unset
-
folderWhitelist
Optional folder prefix allow list for filesystem tools.- Returns:
- folder allow list, or null if unset
-
folderBlacklist
Optional folder prefix deny list for filesystem tools.- Returns:
- folder deny list, or null if unset
-
commandWhitelist
Optional console command allow list (root command names).- Returns:
- console command allow list (root names), or null if unset
-
commandBlacklist
Optional console command deny list (root command names).- Returns:
- console command deny list (root names), or null if unset
-
extra
Custom configuration entries not mapped to built-in fields.- Returns:
- immutable map of extra keys
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='.
-