Record Class ToolAccessConfig

java.lang.Object
java.lang.Record
eu.mrapik.minecraftservermcp.config.ToolAccessConfig
Record Components:
enabled - whether the tool is active for this profile
fileWhitelist - optional file path patterns; null means no whitelist rule
fileBlacklist - optional file path patterns
folderWhitelist - optional folder prefixes
folderBlacklist - optional folder prefixes
commandWhitelist - 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.&lt;profile&gt;.tools.&lt;toolId&gt;.

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 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 of extra.
  • Method Details

    • permissiveDefault

      public static ToolAccessConfig permissiveDefault()
      Used when a profile defines no tools.&lt;id&gt; section: tool allowed, lists unset (no restriction from lists).
      Returns:
      enabled config with all lists null and empty extra
    • fromSection

      public static ToolAccessConfig fromSection(@Nullable @Nullable ConfigurationSection sec)
      Parses a configuration section. Known keys (enabled, file/folder/command list keys) map to typed fields; any other keys are copied into extra().
      Parameters:
      sec - YAML section under a tool id, or null for default
      Returns:
      parsed policy, or permissiveDefault() when sec is 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

      @Nullable public @Nullable List<String> fileWhitelist()
      Optional file path allow list for filesystem tools.
      Returns:
      file allow list, or null if unset in YAML
    • fileBlacklist

      @Nullable public @Nullable List<String> fileBlacklist()
      Optional file path deny list for filesystem tools.
      Returns:
      file deny list, or null if unset
    • folderWhitelist

      @Nullable public @Nullable List<String> folderWhitelist()
      Optional folder prefix allow list for filesystem tools.
      Returns:
      folder allow list, or null if unset
    • folderBlacklist

      @Nullable public @Nullable List<String> folderBlacklist()
      Optional folder prefix deny list for filesystem tools.
      Returns:
      folder deny list, or null if unset
    • commandWhitelist

      @Nullable public @Nullable List<String> commandWhitelist()
      Optional console command allow list (root command names).
      Returns:
      console command allow list (root names), or null if unset
    • commandBlacklist

      @Nullable public @Nullable List<String> commandBlacklist()
      Optional console command deny list (root command names).
      Returns:
      console command deny list (root names), or null if unset
    • extra

      public Map<String,Object> extra()
      Custom configuration entries not mapped to built-in fields.
      Returns:
      immutable map of extra keys
    • toString

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.