Record Class BuiltinToolContext

java.lang.Object
java.lang.Record
eu.mrapik.minecraftservermcp.builtin.BuiltinToolContext
Record Components:
mcpPlugin - this MCP plugin instance (scheduler owner)
paths - resolved server root for file tools
settings - supplier returning current settings (e.g. settingsRef::get so reload applies)

public record BuiltinToolContext(JavaPlugin mcpPlugin, ServerFilePaths paths, Supplier<PluginSettings> settings) extends Record
Dependencies shared by built-in tool handlers: the MCP plugin, ServerFilePaths, and a live PluginSettings supplier.

runSync(Callable) schedules work on the server main thread and adapts the result to Mono for the MCP stack. Use it for Bukkit API calls that are not safe from async threads (e.g. dispatching commands).

  • Constructor Details

    • BuiltinToolContext

      public BuiltinToolContext(JavaPlugin mcpPlugin, ServerFilePaths paths, Supplier<PluginSettings> settings)
      Creates an instance of a BuiltinToolContext record class.
      Parameters:
      mcpPlugin - the value for the mcpPlugin record component
      paths - the value for the paths record component
      settings - the value for the settings record component
  • Method Details

    • runSync

      public reactor.core.publisher.Mono<io.modelcontextprotocol.spec.McpSchema.CallToolResult> runSync(Callable<io.modelcontextprotocol.spec.McpSchema.CallToolResult> task)
      Runs task synchronously on the main thread and completes the mono with its result or error.
      Parameters:
      task - blocking work that returns a tool result (or throws)
      Returns:
      mono completed on the reactor thread once the main-thread task finishes
    • runSyncValue

      public <T> reactor.core.publisher.Mono<T> runSyncValue(Callable<T> task)
      Runs arbitrary main-thread work (e.g. Bukkit player queries) and completes with the returned value.
      Type Parameters:
      T - result type
      Parameters:
      task - blocking work on the server thread
      Returns:
      mono completed after the task runs
    • 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. All components in this record class are compared with Objects::equals(Object,Object).
      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.
    • mcpPlugin

      public JavaPlugin mcpPlugin()
      Returns the value of the mcpPlugin record component.
      Returns:
      the value of the mcpPlugin record component
    • paths

      public ServerFilePaths paths()
      Returns the value of the paths record component.
      Returns:
      the value of the paths record component
    • settings

      public Supplier<PluginSettings> settings()
      Returns the value of the settings record component.
      Returns:
      the value of the settings record component