Interface MinecraftServerMcp
- All Known Implementing Classes:
MinecraftServerMcpImpl
The MCP plugin exposes an implementation of this interface through Bukkit's
ServicesManager. Obtain it after the MCP plugin has enabled, for example:
Bukkit.getServicesManager().load(MinecraftServerMcp.class).
Built-in tools (e.g. fs_write, console command, logs) are registered like third-party tools via
registerTool(McpToolDefinition). Built-in filesystem and player data are MCP
resources registered at startup (see plugin sources);
they use the same access.*.tools.* keys for policy.
Every registered tool is wrapped so that each tools/call runs only after the HTTP bearer token
has been resolved to an access profile and the per-tool policy in config.yml has been applied
(see McpToolInvocation).
-
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 inunregisterToolAs(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 (seetoolOwningPlugin(String)).
-
Method Details
-
registerTool
@NotNull @NotNull reactor.core.publisher.Mono<Void> registerTool(@NotNull @NotNull McpToolDefinition definition) Adds 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.- Parameters:
definition- tool metadata and handler; not null- Returns:
- completes when the tool is visible to MCP clients (may notify list changes)
-
unregisterTool
Removes a tool from the MCP server by its advertised MCP name.This is unconditional (operator/trusted caller). Plugins that registered a tool should prefer
unregisterToolAs(String, Plugin)so only the owning plugin can remove it.- Parameters:
toolId- same string asMcpToolDefinition.id()/McpSchema.Tool.name()- Returns:
- completes when the tool has been removed
-
unregisterToolAs
@NotNull @NotNull reactor.core.publisher.Mono<Void> unregisterToolAs(@NotNull @NotNull String toolId, @NotNull @NotNull Plugin caller) Removes a tool only ifcaller's name matches the plugin that registered it (seetoolOwningPlugin(String)).- 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
Returns which Bukkit plugin registered the given MCP tool name, for ownership checks inunregisterToolAs(java.lang.String, org.bukkit.plugin.Plugin).- Parameters:
toolId- MCP tool name (same asMcpToolDefinition.id())- Returns:
- the registering plugin's name, or
nullif no such tool is registered
-
reloadConfiguration
void reloadConfiguration()Reloads 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. -
mcpServer
@NotNull @NotNull io.modelcontextprotocol.server.McpAsyncServer mcpServer()Direct access to the underlying Model Context Protocol async server.Use this for advanced integration (sessions, capabilities) if you need more than
registerTool(eu.mrapik.minecraftservermcp.api.McpToolDefinition). Typical plugin code only needsregisterTool(eu.mrapik.minecraftservermcp.api.McpToolDefinition)andunregisterTool(java.lang.String).- Returns:
- the non-null MCP server instance used by this plugin
-