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 toolssettings- supplier returning current settings (e.g.settingsRef::getso 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 Summary
ConstructorsConstructorDescriptionBuiltinToolContext(JavaPlugin mcpPlugin, ServerFilePaths paths, Supplier<PluginSettings> settings) Creates an instance of aBuiltinToolContextrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.Returns the value of themcpPluginrecord component.paths()Returns the value of thepathsrecord component.reactor.core.publisher.Mono<io.modelcontextprotocol.spec.McpSchema.CallToolResult> Runstasksynchronously on the main thread and completes the mono with its result or error.<T> reactor.core.publisher.Mono<T> runSyncValue(Callable<T> task) Runs arbitrary main-thread work (e.g.settings()Returns the value of thesettingsrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
BuiltinToolContext
public BuiltinToolContext(JavaPlugin mcpPlugin, ServerFilePaths paths, Supplier<PluginSettings> settings) Creates an instance of aBuiltinToolContextrecord class.
-
-
Method Details
-
runSync
public reactor.core.publisher.Mono<io.modelcontextprotocol.spec.McpSchema.CallToolResult> runSync(Callable<io.modelcontextprotocol.spec.McpSchema.CallToolResult> task) Runstasksynchronously 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
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
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. All components in this record class are compared withObjects::equals(Object,Object). -
mcpPlugin
Returns the value of themcpPluginrecord component.- Returns:
- the value of the
mcpPluginrecord component
-
paths
Returns the value of thepathsrecord component.- Returns:
- the value of the
pathsrecord component
-
settings
Returns the value of thesettingsrecord component.- Returns:
- the value of the
settingsrecord component
-