Class MinecraftServerMcpImpl
- All Implemented Interfaces:
MinecraftServerMcp
MinecraftServerMcp: tools are added through
ToolInvocationGate, while built-in resources are registered separately in
McpHttpServer using ResourceInvocationGate.
Reloading configuration updates PluginSettings for subsequent invocations; it does not unregister tools or
resources.
-
Constructor Summary
ConstructorsConstructorDescriptionMinecraftServerMcpImpl(JavaPlugin mcpPlugin, AtomicReference<PluginSettings> settingsRef, ServerFilePaths paths, io.modelcontextprotocol.server.McpAsyncServer mcpServer) Creates the service implementation registered underMinecraftServerMcp. -
Method Summary
Modifier and TypeMethodDescription@NotNull io.modelcontextprotocol.server.McpAsyncServerDirect access to the underlying Model Context Protocol async server.@NotNull reactor.core.publisher.Mono<Void> registerTool(@NotNull McpToolDefinition definition) Adds a tool to the MCP server, or replaces an existing tool with the same MCP tool name.voidReloads this plugin'sconfig.ymlfrom disk and replaces the in-memoryPluginSettings.@Nullable StringtoolOwningPlugin(@NotNull String toolId) Returns which Bukkit plugin registered the given MCP tool name, for ownership checks inMinecraftServerMcp.unregisterToolAs(java.lang.String, org.bukkit.plugin.Plugin).@NotNull reactor.core.publisher.Mono<Void> unregisterTool(@NotNull String toolId) Removes a tool from the MCP server by its advertised MCP name.@NotNull reactor.core.publisher.Mono<Void> unregisterToolAs(@NotNull String toolId, @NotNull Plugin caller) Removes a tool only ifcaller's name matches the plugin that registered it (seeMinecraftServerMcp.toolOwningPlugin(String)).
-
Constructor Details
-
MinecraftServerMcpImpl
public MinecraftServerMcpImpl(JavaPlugin mcpPlugin, AtomicReference<PluginSettings> settingsRef, ServerFilePaths paths, io.modelcontextprotocol.server.McpAsyncServer mcpServer) Creates the service implementation registered underMinecraftServerMcp.- Parameters:
mcpPlugin- plugin instance that owns logging and service registrationsettingsRef- atomic holder ofPluginSettings, updated when configuration reloadspaths- resolved server directory for tool invocations that need filesystem contextmcpServer- MCP async server instance tools are registered against
-
-
Method Details
-
registerTool
@NotNull public @NotNull reactor.core.publisher.Mono<Void> registerTool(@NotNull @NotNull McpToolDefinition definition) Description copied from interface:MinecraftServerMcpAdds a tool to the MCP server, or replaces an existing tool with the same MCP tool name.The definition's
McpToolDefinition.id()must equalMcpSchema.Tool.name(). Configuration for that tool is read fromaccess.<profile>.tools.<id>for each token profile.- Specified by:
registerToolin interfaceMinecraftServerMcp- Parameters:
definition- tool metadata and handler; not null- Returns:
- completes when the tool is visible to MCP clients (may notify list changes)
-
unregisterTool
@NotNull public @NotNull reactor.core.publisher.Mono<Void> unregisterTool(@NotNull @NotNull String toolId) Description copied from interface:MinecraftServerMcpRemoves a tool from the MCP server by its advertised MCP name.This is unconditional (operator/trusted caller). Plugins that registered a tool should prefer
MinecraftServerMcp.unregisterToolAs(String, Plugin)so only the owning plugin can remove it.- Specified by:
unregisterToolin interfaceMinecraftServerMcp- Parameters:
toolId- same string asMcpToolDefinition.id()/McpSchema.Tool.name()- Returns:
- completes when the tool has been removed
-
unregisterToolAs
@NotNull public @NotNull reactor.core.publisher.Mono<Void> unregisterToolAs(@NotNull @NotNull String toolId, @NotNull @NotNull Plugin caller) Description copied from interface:MinecraftServerMcpRemoves a tool only ifcaller's name matches the plugin that registered it (seeMinecraftServerMcp.toolOwningPlugin(String)).- Specified by:
unregisterToolAsin interfaceMinecraftServerMcp- Parameters:
toolId- MCP tool namecaller- plugin that must own the tool- Returns:
- completes when removed, or errors if the tool is unknown or not owned by
caller
-
toolOwningPlugin
Description copied from interface:MinecraftServerMcpReturns which Bukkit plugin registered the given MCP tool name, for ownership checks inMinecraftServerMcp.unregisterToolAs(java.lang.String, org.bukkit.plugin.Plugin).- Specified by:
toolOwningPluginin interfaceMinecraftServerMcp- Parameters:
toolId- MCP tool name (same asMcpToolDefinition.id())- Returns:
- the registering plugin's name, or
nullif no such tool is registered
-
reloadConfiguration
public void reloadConfiguration()Description copied from interface:MinecraftServerMcpReloads this plugin'sconfig.ymlfrom disk and replaces the in-memoryPluginSettings. Already-registered tools stay registered; subsequent tool invocations use the new token and policy values.- Specified by:
reloadConfigurationin interfaceMinecraftServerMcp
-
mcpServer
@NotNull public @NotNull io.modelcontextprotocol.server.McpAsyncServer mcpServer()Description copied from interface:MinecraftServerMcpDirect access to the underlying Model Context Protocol async server.Use this for advanced integration (sessions, capabilities) if you need more than
MinecraftServerMcp.registerTool(eu.mrapik.minecraftservermcp.api.McpToolDefinition). Typical plugin code only needsMinecraftServerMcp.registerTool(eu.mrapik.minecraftservermcp.api.McpToolDefinition)andMinecraftServerMcp.unregisterTool(java.lang.String).- Specified by:
mcpServerin interfaceMinecraftServerMcp- Returns:
- the non-null MCP server instance used by this plugin
-